simon-svn: puzzles: simon

tartarus-commits at lists.tartarus.org tartarus-commits at lists.tartarus.org
Mon May 30 14:10:39 BST 2005


SVN root:       svn://ixion.tartarus.org/main
Changes by:     simon
Revision:       5862
Date:           2005-05-30 14:10:37 +0100 (Mon, 30 May 2005)

Log message (29 lines):
Mines now follows the conventional approach of offering a completely
blank grid until you make the first click; to ensure solubility, it
does not generate the mine layout until that click, and then ensures
it is solvable starting from that position.

This has involved three infrastructure changes:

 - random.c now offers functions to encode and decode an entire
   random_state as a string
 - each puzzle's new_game() is now passed a pointer to the midend
   itself, which most of them ignore
 - there's a function in the midend which a game can call back to
   _rewrite_ its current game description.

So Mines now has two entirely separate forms of game ID. One
contains the generation-time parameters (n and unique) plus an
encoding of a random_state; the other actually encodes the grid once
it's been generated, and also contains the initial click position.
When called with the latter, new_game() does plausibly normal stuff.
When called with the former, it notes down all the details and waits
until the first square is opened, and _then_ does the grid
generation and updates the game description in the midend. So if,
_after_ your first click, you decide you want to share this
particular puzzle with someone else, you can do that fine.

Also in this checkin, the mine layout is no longer _copied_ between
all the game_states on the undo chain. Instead, it's in a separate
structure and all game_states share a pointer to it - and the
structure is reference-counted to ensure deallocation.

Modified files:
U   puzzles/cube.c
U   puzzles/fifteen.c
U   puzzles/midend.c
U   puzzles/mines.c
U   puzzles/net.c
U   puzzles/netslide.c
U   puzzles/nullgame.c
U   puzzles/pattern.c
U   puzzles/puzzles.h
U   puzzles/random.c
U   puzzles/rect.c
U   puzzles/sixteen.c
U   puzzles/solo.c
U   puzzles/twiddle.c

Links:
http://www.tartarus.org/~simon-anonsvn/viewcvs.cgi?rev=5862&view=rev
http://www.tartarus.org/~simon-anonsvn/viewcvs.cgi/puzzles/cube.c?rev=5862&r1=5861&r2=5862
http://www.tartarus.org/~simon-anonsvn/viewcvs.cgi/puzzles/fifteen.c?rev=5862&r1=5861&r2=5862
http://www.tartarus.org/~simon-anonsvn/viewcvs.cgi/puzzles/midend.c?rev=5862&r1=5861&r2=5862
http://www.tartarus.org/~simon-anonsvn/viewcvs.cgi/puzzles/mines.c?rev=5862&r1=5861&r2=5862
http://www.tartarus.org/~simon-anonsvn/viewcvs.cgi/puzzles/net.c?rev=5862&r1=5861&r2=5862
http://www.tartarus.org/~simon-anonsvn/viewcvs.cgi/puzzles/netslide.c?rev=5862&r1=5861&r2=5862
http://www.tartarus.org/~simon-anonsvn/viewcvs.cgi/puzzles/nullgame.c?rev=5862&r1=5861&r2=5862
http://www.tartarus.org/~simon-anonsvn/viewcvs.cgi/puzzles/pattern.c?rev=5862&r1=5861&r2=5862
http://www.tartarus.org/~simon-anonsvn/viewcvs.cgi/puzzles/puzzles.h?rev=5862&r1=5861&r2=5862
http://www.tartarus.org/~simon-anonsvn/viewcvs.cgi/puzzles/random.c?rev=5862&r1=5861&r2=5862
http://www.tartarus.org/~simon-anonsvn/viewcvs.cgi/puzzles/rect.c?rev=5862&r1=5861&r2=5862
http://www.tartarus.org/~simon-anonsvn/viewcvs.cgi/puzzles/sixteen.c?rev=5862&r1=5861&r2=5862
http://www.tartarus.org/~simon-anonsvn/viewcvs.cgi/puzzles/solo.c?rev=5862&r1=5861&r2=5862
http://www.tartarus.org/~simon-anonsvn/viewcvs.cgi/puzzles/twiddle.c?rev=5862&r1=5861&r2=5862



More information about the tartarus-commits mailing list