[Commit] rrsolve/src rrsolve.c,1.8,1.9
Carl Worth
commit at keithp.com
Thu Jul 10 19:03:17 PDT 2003
- Previous message: [Commit] rrsolve/boards min01_solution, NONE, 1.1 min17-2, NONE,
1.1 min17-2_solution, NONE, 1.1 min17-3, NONE,
1.1 min17-3_solution, NONE, 1.1 min20, NONE,
1.1 min20_solution, NONE, 1.1 min20~, NONE, 1.1 test, NONE,
1.1 min09, 1.1, 1.2
- Next message: [Commit] grrobot ChangeLog,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: cworth
Update of /local/src/CVS/rrsolve/src
In directory home.keithp.com:/tmp/cvs-serv11640/src
Modified Files:
rrsolve.c
Log Message:
Small cleanups.
Index: rrsolve.c
===================================================================
RCS file: /local/src/CVS/rrsolve/src/rrsolve.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- rrsolve.c 3 Jul 2003 18:19:13 -0000 1.8
+++ rrsolve.c 11 Jul 2003 01:03:15 -0000 1.9
@@ -85,8 +85,10 @@
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);
@@ -165,18 +167,8 @@
}
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);
@@ -206,19 +198,21 @@
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:
@@ -291,11 +285,13 @@
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
@@ -420,7 +416,7 @@
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;
@@ -547,6 +543,9 @@
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++) {
- Previous message: [Commit] rrsolve/boards min01_solution, NONE, 1.1 min17-2, NONE,
1.1 min17-2_solution, NONE, 1.1 min17-3, NONE,
1.1 min17-3_solution, NONE, 1.1 min20, NONE,
1.1 min20_solution, NONE, 1.1 min20~, NONE, 1.1 test, NONE,
1.1 min09, 1.1, 1.2
- Next message: [Commit] grrobot ChangeLog,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Commit
mailing list