Tobis Programm forked to not destroy your golden files
Fork of Robocode by
Diff: source/Pathfinding.cpp
- Revision:
- 128:6bde4483ce7b
- Parent:
- 113:c7afe49752b9
- Child:
- 129:0f60bf9640bb
diff -r d05c45917280 -r 6bde4483ce7b source/Pathfinding.cpp --- a/source/Pathfinding.cpp Sun May 14 13:40:17 2017 +0000 +++ b/source/Pathfinding.cpp Sun May 14 14:40:12 2017 +0000 @@ -31,6 +31,7 @@ //global position walkpath[3 * row] = { 0 }; position target = {0}; +position start = {0}; //should be local static uint16_t open_list[row][col] = { 0 }; // contains open slots marked with their F value (G + H) @@ -39,8 +40,8 @@ static uint16_t open_list_count = 0; static uint16_t counter; -static int path_found = 0; -static int no_path_possible = 1; +static int path_found = 45; +static int no_path_possible = 48; /************************************************************************************************************ @@ -49,9 +50,9 @@ int pathfinding() { define_obst(); - position start = { 1,1 }; //start - target.x = 198; target.y = 198; - position current = { 0 }; //current pos + //start = get_current_pos(); + //target.x = 198; target.y = 198; + position current = { 0 }; //current pos of the pathfinder memset(open_list, 0, sizeof(open_list)); memset(g_list, 0, sizeof(g_list)); @@ -118,24 +119,6 @@ obstacle_list[row - 1][i] = 1; } - obstacle_list[1][5] = 1; - obstacle_list[2][5] = 1; - //obstacle_list[3][5] = 1; - obstacle_list[4][5] = 1; - //obstacle_list[5][5] = 1; - - obstacle_list[5][0] = 1; - obstacle_list[5][1] = 1; - obstacle_list[5][2] = 1; - obstacle_list[5][3] = 1; - obstacle_list[5][4] = 1; - - obstacle_list[7][6] = 1; - obstacle_list[7][4] = 1; - obstacle_list[7][5] = 1; - obstacle_list[7][6] = 1; - obstacle_list[7][7] = 1; - obstacle_list[7][8] = 1; } @@ -191,7 +174,7 @@ corner2.y = current.y - 1; break; default: - printf("Fatal Error, unknown position"); + printf("Fatal Error, unknown position\r\n"); break; } if (obstacle_list[adjacent.x][adjacent.y] == 0 && ((obstacle_list[corner1.x][corner1.y] == 0 && obstacle_list[corner2.x][corner2.y] == 0) || @@ -291,7 +274,7 @@ x.y = y.y + 1; break; default: - printf("Fatal Error, unknown position"); + printf("Fatal Error, unknown position\r\n"); break; } if (g_list[x.x][x.y] < g_list[y.x][y.y] && g_list[x.x][x.y] != 0 && g_list[s.x][s.y] > g_list[x.x][x.y]) {