Re-architecting of the game backend interface. make_move() has been
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 27 Jun 2005 19:34:54 +0000 (19:34 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 27 Jun 2005 19:34:54 +0000 (19:34 +0000)
commitdf11cd4e43b66b17df44a1e933f5c71361dc13a4
tree59c00829783f7e4eb069cc6f527193dbd6a64827
parentcbdf34a00c780fff5c06c9d9c24ab7f53d141bbd
Re-architecting of the game backend interface. make_move() has been
split into two functions. The first, interpret_move(), takes all the
arguments that make_move() used to get and may have the usual side
effects of modifying the game_ui, but instead of returning a
modified game_state it instead returns a string description of the
move to be made. This string description is then passed to a second
function, execute_move(), together with an input game_state, which
is responsible for actually producing the new state. (solve_game()
also returns a string to be passed to execute_move().)

The point of this is to work towards being able to serialise the
whole of a game midend into a byte stream such as a disk file, which
will eventually support save and load functions in the desktop
puzzles, as well as restoring half-finished games after a quit and
restart in James Harvey's Palm port. Making each game supply a
convert-to-string function for its game_state format would have been
an unreliable way to do this, since those functions would not have
been used in normal play, so they'd only have been tested when you
actually tried to save and load - a recipe for latent bugs if ever I
heard one. This way, you won't even be able to _make_ a move if
execute_move() doesn't work properly, which means that if you can
play a game at all I can have pretty high confidence that
serialising it will work first time.

This is only the groundwork; there will be more checkins to come on
this theme. But the major upheaval should now be done, and as far as
I can tell everything's still working normally.

git-svn-id: svn://svn.tartarus.org/sgt/puzzles@6024 cda61777-01e9-0310-a592-d414129be87e
16 files changed:
cube.c
fifteen.c
flip.c
guess.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