aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-06-17 18:54:58 +0000
committerSimon Tatham <anakin@pobox.com>2005-06-17 18:54:58 +0000
commitf01f82105e5feb2586a2ca257947d76e9b982d04 (patch)
treef1a99cc46e8a333c750616969d740dd540f0f44b
parent32111ef901daba8b9168736f9a52bec8f6e95c98 (diff)
downloadpuzzles-f01f82105e5feb2586a2ca257947d76e9b982d04.zip
puzzles-f01f82105e5feb2586a2ca257947d76e9b982d04.tar.gz
puzzles-f01f82105e5feb2586a2ca257947d76e9b982d04.tar.bz2
puzzles-f01f82105e5feb2586a2ca257947d76e9b982d04.tar.xz
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]
-rw-r--r--cube.c4
-rw-r--r--fifteen.c4
-rw-r--r--flip.c4
-rw-r--r--midend.c4
-rw-r--r--mines.c4
-rw-r--r--net.c4
-rw-r--r--netslide.c4
-rw-r--r--nullgame.c4
-rw-r--r--pattern.c4
-rw-r--r--puzzles.h3
-rw-r--r--rect.c4
-rw-r--r--samegame.c4
-rw-r--r--sixteen.c4
-rw-r--r--solo.c4
-rw-r--r--twiddle.c4
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;