chiark / gitweb /
Infrastructure change which I've been thinking about for a while:
authorSimon Tatham <anakin@pobox.com>
Fri, 17 Jun 2005 18:54:58 +0000 (18:54 +0000)
committerSimon Tatham <anakin@pobox.com>
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.

[originally from svn r5969]

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 e1c28658580ca081e8fcfd98956c23bbed16e716..0658970e40a247185af13349c3320b3b4a576285 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 226de305cf6500e55fb024e931bbdab2cbffe793..d8ba3b0eb7ada4445f3cd6badc7780c79d1deb8e 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 04c08d06cfd2879c356c15438ec43446cadeea16..9876e1dbd82c619873a57cb94470863e6bccf8bf 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 f4eeb6160b8651645a5c26f63a1a975956b4706a..dec0cc955955ac7be676f40a26ed4201978a2c74 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 01415176d88688fa846e03f52bdc6574b2f31395..388a7d55430cd3c016d8e4ccc9ef59c8c52e446b 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 cf453402eb4fe0c2209498c2832649247655cbac..8bfd899a29a0a803925e990f63eca2ae74bc404c 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 d19bdbb4863a0d5e7873b925a6c4a3657a786bd9..5aa58b62a5f7d26f10b4bf8fb94bfd29140cdfec 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 92bdf32a6d2523a8547dd2a3302855d31ec6a7e9..e2c4a74bd87bbb3289850374163a8677035ff549 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 523374d6727a84ac06be2e40217874757ea8340a..6f0b8fd2ce0eff1c2b0c40e484e8e89ebef4c57f 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 f3aee1ad1d25168e2544c9a926c69c8fc39ad4c0..0dbc7f883cd3bc928f23df91598f45dc28122997 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 46060a4fd0fcf4b0afe20e84fa560dc4917dc91b..0940cdd839cca12feb2642d57b08a6de1e0408c6 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 8b4379d4f56d19a2831b5e7209f47bb13e6a3aef..6294a3dabcf51c19109a3048aa7751a9c3292088 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 1aec630250ff90c80f0c78f601522066d9a23194..9e93b2fa9ff2a9690050b71533b129478e762844 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 615d87300172a0d0db960ebb24cbaa91485de1d9..4255c02a4d5efe38f4d57b000ecf66b237696545 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 58b4cb5e05a7766843f633bf97c1a4240da46635..8000780f13989923dd6a41b7c1d61cdb351382fb 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;