From 4a29930e1b9db1332c93244365db1642fcfac1cd Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 17 Jun 2005 18:54:58 +0000 Subject: [PATCH] Infrastructure change which I've been thinking about for a while: the back end function solve_game() now takes the _current_ game_state in addition to the initial one. git-svn-id: svn://svn.tartarus.org/sgt/puzzles@5969 cda61777-01e9-0310-a592-d414129be87e --- cube.c | 4 ++-- fifteen.c | 4 ++-- flip.c | 4 ++-- midend.c | 4 +++- mines.c | 4 ++-- net.c | 4 ++-- netslide.c | 4 ++-- nullgame.c | 4 ++-- pattern.c | 4 ++-- puzzles.h | 3 ++- rect.c | 4 ++-- samegame.c | 4 ++-- sixteen.c | 4 ++-- solo.c | 4 ++-- twiddle.c | 4 ++-- 15 files changed, 31 insertions(+), 28 deletions(-) diff --git a/cube.c b/cube.c index e1c2865..0658970 100644 --- a/cube.c +++ b/cube.c @@ -984,8 +984,8 @@ static void free_game(game_state *state) sfree(state); } -static game_state *solve_game(game_state *state, game_aux_info *aux, - char **error) +static game_state *solve_game(game_state *state, game_state *currstate, + game_aux_info *aux, char **error) { return NULL; } diff --git a/fifteen.c b/fifteen.c index 226de30..d8ba3b0 100644 --- a/fifteen.c +++ b/fifteen.c @@ -379,8 +379,8 @@ static void free_game(game_state *state) sfree(state); } -static game_state *solve_game(game_state *state, game_aux_info *aux, - char **error) +static game_state *solve_game(game_state *state, game_state *currstate, + game_aux_info *aux, char **error) { game_state *ret = dup_game(state); int i; diff --git a/flip.c b/flip.c index 04c08d0..9876e1d 100644 --- a/flip.c +++ b/flip.c @@ -670,8 +670,8 @@ static void free_game(game_state *state) sfree(state); } -static game_state *solve_game(game_state *state, game_aux_info *aux, - char **error) +static game_state *solve_game(game_state *state, game_state *currstate, + game_aux_info *aux, char **error) { return NULL; } diff --git a/midend.c b/midend.c index f4eeb61..dec0cc9 100644 --- a/midend.c +++ b/midend.c @@ -947,7 +947,9 @@ char *midend_solve(midend_data *me) return "No game set up to solve"; /* _shouldn't_ happen! */ msg = "Solve operation failed"; /* game _should_ overwrite on error */ - s = me->ourgame->solve(me->states[0].state, me->aux_info, &msg); + s = me->ourgame->solve(me->states[0].state, + me->states[me->statepos-1].state, + me->aux_info, &msg); if (!s) return msg; diff --git a/mines.c b/mines.c index 0141517..388a7d5 100644 --- a/mines.c +++ b/mines.c @@ -2385,8 +2385,8 @@ static void free_game(game_state *state) sfree(state); } -static game_state *solve_game(game_state *state, game_aux_info *aux, - char **error) +static game_state *solve_game(game_state *state, game_state *currstate, + game_aux_info *aux, char **error) { /* * Simply expose the entire grid as if it were a completed diff --git a/net.c b/net.c index cf45340..8bfd899 100644 --- a/net.c +++ b/net.c @@ -1666,8 +1666,8 @@ static void free_game(game_state *state) sfree(state); } -static game_state *solve_game(game_state *state, game_aux_info *aux, - char **error) +static game_state *solve_game(game_state *state, game_state *currstate, + game_aux_info *aux, char **error) { game_state *ret; diff --git a/netslide.c b/netslide.c index d19bdbb..5aa58b6 100644 --- a/netslide.c +++ b/netslide.c @@ -893,8 +893,8 @@ static void free_game(game_state *state) sfree(state); } -static game_state *solve_game(game_state *state, game_aux_info *aux, - char **error) +static game_state *solve_game(game_state *state, game_state *currstate, + game_aux_info *aux, char **error) { game_state *ret; diff --git a/nullgame.c b/nullgame.c index 92bdf32..e2c4a74 100644 --- a/nullgame.c +++ b/nullgame.c @@ -122,8 +122,8 @@ static void free_game(game_state *state) sfree(state); } -static game_state *solve_game(game_state *state, game_aux_info *aux, - char **error) +static game_state *solve_game(game_state *state, game_state *currstate, + game_aux_info *aux, char **error) { return NULL; } diff --git a/pattern.c b/pattern.c index 523374d..6f0b8fd 100644 --- a/pattern.c +++ b/pattern.c @@ -664,8 +664,8 @@ static void free_game(game_state *state) sfree(state); } -static game_state *solve_game(game_state *state, game_aux_info *ai, - char **error) +static game_state *solve_game(game_state *state, game_state *currstate, + game_aux_info *ai, char **error) { game_state *ret; diff --git a/puzzles.h b/puzzles.h index f3aee1a..0dbc7f8 100644 --- a/puzzles.h +++ b/puzzles.h @@ -248,7 +248,8 @@ struct game { game_state *(*dup_game)(game_state *state); void (*free_game)(game_state *state); int can_solve; - game_state *(*solve)(game_state *state, game_aux_info *aux, char **error); + game_state *(*solve)(game_state *orig, game_state *curr, + game_aux_info *aux, char **error); int can_format_as_text; char *(*text_format)(game_state *state); game_ui *(*new_ui)(game_state *state); diff --git a/rect.c b/rect.c index 46060a4..0940cdd 100644 --- a/rect.c +++ b/rect.c @@ -1769,8 +1769,8 @@ static void free_game(game_state *state) sfree(state); } -static game_state *solve_game(game_state *state, game_aux_info *ai, - char **error) +static game_state *solve_game(game_state *state, game_state *currstate, + game_aux_info *ai, char **error) { game_state *ret; diff --git a/samegame.c b/samegame.c index 8b4379d..6294a3d 100644 --- a/samegame.c +++ b/samegame.c @@ -354,8 +354,8 @@ static void free_game(game_state *state) sfree(state); } -static game_state *solve_game(game_state *state, game_aux_info *aux, - char **error) +static game_state *solve_game(game_state *state, game_state *currstate, + game_aux_info *aux, char **error) { return NULL; } diff --git a/sixteen.c b/sixteen.c index 1aec630..9e93b2f 100644 --- a/sixteen.c +++ b/sixteen.c @@ -510,8 +510,8 @@ static void free_game(game_state *state) sfree(state); } -static game_state *solve_game(game_state *state, game_aux_info *aux, - char **error) +static game_state *solve_game(game_state *state, game_state *currstate, + game_aux_info *aux, char **error) { game_state *ret = dup_game(state); int i; diff --git a/solo.c b/solo.c index 615d873..4255c02 100644 --- a/solo.c +++ b/solo.c @@ -1759,8 +1759,8 @@ static void free_game(game_state *state) sfree(state); } -static game_state *solve_game(game_state *state, game_aux_info *ai, - char **error) +static game_state *solve_game(game_state *state, game_state *currstate, + game_aux_info *ai, char **error) { game_state *ret; int c = state->c, r = state->r, cr = c*r; diff --git a/twiddle.c b/twiddle.c index 58b4cb5..8000780 100644 --- a/twiddle.c +++ b/twiddle.c @@ -546,8 +546,8 @@ static int compare_int(const void *av, const void *bv) return 0; } -static game_state *solve_game(game_state *state, game_aux_info *aux, - char **error) +static game_state *solve_game(game_state *state, game_state *currstate, + game_aux_info *aux, char **error) { game_state *ret = dup_game(state); int i; -- 2.11.0