chiark / gitweb /
Re-architecting of the game backend interface. make_move() has been
authorSimon Tatham <anakin@pobox.com>
Mon, 27 Jun 2005 19:34:54 +0000 (19:34 +0000)
committerSimon Tatham <anakin@pobox.com>
Mon, 27 Jun 2005 19:34:54 +0000 (19:34 +0000)
commit76d50e69059aeebe8b47089615518a8b9e225d40
tree59c00829783f7e4eb069cc6f527193dbd6a64827
parent7cb29412c1a57a07730c1fee0c9e9fbfebb0b6b2
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.

[originally from svn r6024]
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