shithub: puzzles

Download patch

ref: f01f82105e5feb2586a2ca257947d76e9b982d04
parent: 32111ef901daba8b9168736f9a52bec8f6e95c98
author: Simon Tatham <anakin@pobox.com>
date: Fri Jun 17 14:54:58 EDT 2005

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.

[originally from svn r5969]

--- a/cube.c
+++ b/cube.c
@@ -984,8 +984,8 @@
     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;
 }
--- a/fifteen.c
+++ b/fifteen.c
@@ -379,8 +379,8 @@
     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;
--- a/flip.c
+++ b/flip.c
@@ -670,8 +670,8 @@
     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;
 }
--- a/midend.c
+++ b/midend.c
@@ -947,7 +947,9 @@
 	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;
 
--- a/mines.c
+++ b/mines.c
@@ -2385,8 +2385,8 @@
     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
--- a/net.c
+++ b/net.c
@@ -1666,8 +1666,8 @@
     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;
 
--- a/netslide.c
+++ b/netslide.c
@@ -893,8 +893,8 @@
     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;
 
--- a/nullgame.c
+++ b/nullgame.c
@@ -122,8 +122,8 @@
     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;
 }
--- a/pattern.c
+++ b/pattern.c
@@ -664,8 +664,8 @@
     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;
 
--- a/puzzles.h
+++ b/puzzles.h
@@ -248,7 +248,8 @@
     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);
--- a/rect.c
+++ b/rect.c
@@ -1769,8 +1769,8 @@
     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;
 
--- a/samegame.c
+++ b/samegame.c
@@ -354,8 +354,8 @@
     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;
 }
--- a/sixteen.c
+++ b/sixteen.c
@@ -510,8 +510,8 @@
     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;
--- a/solo.c
+++ b/solo.c
@@ -1759,8 +1759,8 @@
     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;
--- a/twiddle.c
+++ b/twiddle.c
@@ -546,8 +546,8 @@
 	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;