Tobis Programm forked to not destroy your golden files
Fork of Robocode by
source/Mapping.cpp
- Committer:
- cittecla
- Date:
- 2017-04-11
- Revision:
- 44:7118b23b0fd7
- Parent:
- 41:462d379e85c4
File content as of revision 44:7118b23b0fd7:
/** * Mapping function library * Handels Mapping of the arena and LEGO-stones **/ //Obstacle_list --> 0 = free | 1 = hard surface object | 2 = inaccesable (robot diameter) | 3 = LEGO undefined | 4 = LEGO red #include "Mapping.h" #include "Pathfinding.h" uint8_t obstacle_list_superpos[7][7] = {{0,0,2,2,2,0,0}, {0,2,2,2,2,2,0}, {2,2,2,2,2,2,2}, {2,2,2,1,2,2,2}, {2,2,2,2,2,2,2}, {0,2,2,2,2,2,0}, {0,0,2,2,2,0,0}}; void mapping() { //pseudo code // check_sensor(left); //check_sensor(right); } int select_target() { position myPos = get_current_pos(); position diff = {0}; target.x = 0; int closest_dist = 10000; int current_dist = 0; for(int i = 0; i < row; i++) { for(int j = 0; j < col; j++) { if(obstacle_list[i][j] == 3) { diff.x = abs(myPos.x - j); diff.y = abs(myPos.y - i); current_dist = diff.x * diff.y; if(current_dist < closest_dist) { closest_dist = current_dist; target.x = j; target.y = i; } } } } if(target.x == 0) { return 47; // No Target found } else { return 36; // Target found } } int remove_target() { obstacle_list[target.y][target.x] = 0; return 0; } int switch_target_red() { obstacle_list[target.y][target.x] = 0; return 0; } /* void chack_sensor(sensor) { get_distance(); if(sensor < 80cm || sensor > 10cm) { calculate_position(sensor, distance); check_map(position.this, obstacle); if(map.no-entry){ check_if_obstacle(distance); update_map(); } } } void get_distance(sensor) { sensor.value; return value; } void calcualte_position(sensor, distance) { do math; return position; } void check_if_obstacle(distance) { move_scanner(); distance2 = get_distance(sensor); reset_scanner(); if(distance -5cm < distance2 && distance +5cm > distance2) { return 1; } else { return 0; } }*/