for (i = 0; args.files[i]; i++) {
board = rr_board_create_from_file (args.files[i]);
- if (board == NULL)
+ if (board == NULL) {
+ fprintf (stderr, "Failed to parse board in %s\n", args.files[i]);
continue;
+ }
rrs_solution_init (&solution);
solve_board (board, &solution);
rrs_solution_print (&solution);
}
switch (notice->type) {
- /* XXX: The processing needed for GAMEOVER, JOIN, and TURN
- is a mess right now. There should be one NOTICE to say
- the board has changed and one to say a TURN has started,
- rather than the current mess. */
- case RR_NOTICE_GAMEOVER:
- status = rr_client_show (client, &diagram);
- if (status) {
- fprintf (stderr, "Error in rr_client_show: %s\n", rr_status_str (status));
- goto DONE;
- }
- rr_board_parse (board, diagram);
- free (diagram);
+ case RR_NOTICE_BOARD:
+ rr_board_parse (board, notice->u.string);
break;
case RR_NOTICE_TURN:
rr_board_set_goal_target (board, notice->u.target);
rr_client_nobid (client);
break;
case RR_NOTICE_POSITION:
- rr_board_position_robot (board,
- notice->u.position.robot,
- notice->u.position.x,
- notice->u.position.y);
+ rr_board_add_robot (board,
+ notice->u.position.robot,
+ notice->u.position.x,
+ notice->u.position.y);
break;
case RR_NOTICE_GAMESTATE:
- if (notice->u.gamestate == RR_GAMESTATE_SHOW) {
+ if (notice->u.gamestate == RR_GAMESTATE_DONE
+ || notice->u.gamestate == RR_GAMESTATE_SHOW) {
if (solution.num_moves) {
printf ("My solution (%d moves):", solution.num_moves);
rrs_solution_print (&solution);
}
}
break;
+ case RR_NOTICE_GAMEOVER:
case RR_NOTICE_GAME:
case RR_NOTICE_USER:
case RR_NOTICE_JOIN:
int i;
int x, y;
+ for (i=0; i < RR_NUM_ROBOTS; i++)
+ rr_board_remove_robot (board, rr_robot_from_idx (i));
+
for (i=0; i < RR_NUM_ROBOTS; i++) {
RRS_STATE_GET_ROBOT (state, i, x, y);
- rr_board_position_robot (board, rr_robot_from_idx (i), x, y);
+ rr_board_add_robot (board, rr_robot_from_idx (i), x, y);
}
-
}
static rr_status_t
rr_status_t status;
int i, j;
rrs_state_buf_t *buf;
- int found_move;
+ int found_move = 0;
rr_robot_t robot, robot_found, last_robot_found = RR_ROBOT_NONE;
rr_direction_t dir, dir_found;
rrs_state_t state_found;
state = initial->state[i];
rrs_state_set_board (state, board);
+
+ if (state == 0x611a4350)
+ printf ("I'm within one move now\n");
for (ri = 0; ri < RR_NUM_ROBOTS; ri++) {
robot = rr_robot_from_idx (ri);
for (dir = RR_DIRECTION_NORTH; dir <= RR_DIRECTION_EAST; dir++) {