11.07.2015 Views

Builders guide robot pacman.pdf

Builders guide robot pacman.pdf

Builders guide robot pacman.pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

if ( is_neighbour(curr_cell_x, curr_cell_y, W) ){neigh_cell_x = curr_cell_x - 1;neigh_cell_y = curr_cell_y;curr_cell_dist + 1;}}}if ( goal_distance[point_to_cell_number(neigh_cell_x, neigh_cell_y)] == 0xFF ){goal_distance[point_to_cell_number(neigh_cell_x, neigh_cell_y)] =}queue_x[queue_index + queue_count] = neigh_cell_x;queue_y[queue_index + queue_count] = neigh_cell_y;queue_count++;// create roadmapcurr_pos_dist = goal_distance[point_to_cell_number(current_x_pos, current_y_pos)];curr_cell_x = current_x_pos;curr_cell_y = current_y_pos;for ( i= 0; curr_pos_dist > 0; i++ ){// check northneigh_cell_x = curr_cell_x;neigh_cell_y = curr_cell_y - 1;if ( (neigh_cell_x < NUM_X_CELLS) && (neigh_cell_y < NUM_Y_CELLS) ){if ( goal_distance[point_to_cell_number(neigh_cell_x, neigh_cell_y)] < curr_pos_dist ){// add to roadmapcurr_pos_dist = goal_distance[point_to_cell_number(neigh_cell_x, neigh_cell_y)];write_bank(3, i, NORTH);curr_cell_x = neigh_cell_x;curr_cell_y = neigh_cell_y;continue;}}// check eastneigh_cell_x = curr_cell_x + 1;neigh_cell_y = curr_cell_y;if ( (neigh_cell_x < NUM_X_CELLS) && (neigh_cell_y < NUM_Y_CELLS) ){if ( goal_distance[point_to_cell_number(neigh_cell_x, neigh_cell_y)] < curr_pos_dist ){// add to roadmapcurr_pos_dist = goal_distance[point_to_cell_number(neigh_cell_x, neigh_cell_y)];write_bank(3, i, EAST);curr_cell_x = neigh_cell_x;curr_cell_y = neigh_cell_y;continue;}}// check southneigh_cell_x = curr_cell_x;neigh_cell_y = curr_cell_y + 1;if ( (neigh_cell_x < NUM_X_CELLS) && (neigh_cell_y < NUM_Y_CELLS) ){if ( goal_distance[point_to_cell_number(neigh_cell_x, neigh_cell_y)] < curr_pos_dist ){// add to roadmapcurr_pos_dist = goal_distance[point_to_cell_number(neigh_cell_x, neigh_cell_y)];write_bank(3, i, SOUTH);curr_cell_x = neigh_cell_x;curr_cell_y = neigh_cell_y;continue;}}// check westneigh_cell_x = curr_cell_x - 1;neigh_cell_y = curr_cell_y;if ( (neigh_cell_x < NUM_X_CELLS) && (neigh_cell_y < NUM_Y_CELLS) ){if ( goal_distance[point_to_cell_number(neigh_cell_x, neigh_cell_y)] < curr_pos_dist ){// add to roadmapcurr_pos_dist = goal_distance[point_to_cell_number(neigh_cell_x, neigh_cell_y)];write_bank(3, i, WEST);curr_cell_x = neigh_cell_x;curr_cell_y = neigh_cell_y;continue;}}}write_bank(3, i, 0);// clean up

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!