Infrastructure change which I've been thinking about for a while:
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 17 Jun 2005 18:54:58 +0000 (18:54 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Fri, 17 Jun 2005 18:54:58 +0000 (18:54 +0000)
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

15 files changed:
cube.c
fifteen.c
flip.c
midend.c
mines.c
net.c
netslide.c
nullgame.c
pattern.c
puzzles.h
rect.c
samegame.c
sixteen.c
solo.c
twiddle.c

diff --git a/cube.c b/cube.c
index e1c2865..0658970 100644 (file)
--- 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;
 }
index 226de30..d8ba3b0 100644 (file)
--- 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 (file)
--- 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;
 }
index f4eeb61..dec0cc9 100644 (file)
--- 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 (file)
--- 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 (file)
--- 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;
 
index d19bdbb..5aa58b6 100644 (file)
@@ -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;
 
index 92bdf32..e2c4a74 100644 (file)
@@ -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;
 }
index 523374d..6f0b8fd 100644 (file)
--- 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;
 
index f3aee1a..0dbc7f8 100644 (file)
--- 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 (file)
--- 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;
 
index 8b4379d..6294a3d 100644 (file)
@@ -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;
 }
index 1aec630..9e93b2f 100644 (file)
--- 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 (file)
--- 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;
index 58b4cb5..8000780 100644 (file)
--- 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;