simon-svn: puzzles: simon

Commits to Tartarus CVS repository. tartarus-commits at lists.tartarus.org
Fri Apr 12 17:28:53 BST 2013


SVN root:       svn://svn.tartarus.org/sgt
Changes by:     simon
Revision:       9826
Date:           2013-04-12 17:28:52 +0100 (Fri, 12 Apr 2013)

Log message (14 lines):
Apply some optimisation to Undead's get_unique() function, which was
not only enumerating all possible arrangements of monsters along a
sight-line in O(3^n) time, but also allocated memory for them all and
then does a quadratic-time loop over that list to find arrangements
with a unique visibility count from both ends. Spotted by the new
'make test', which observed that 7x7dn#517035041807425 took 45 seconds
to generate.

This revised version still does the initial O(3^n) enumeration, which
can probably be got rid of as well with a bit more thought, but it now
doesn't allocate nearly so much memory and it spots uniques
efficiently. The above random seed now generates the same game ID in
less than a second, which drops this puzzle off the 'make test' hit
list of things most obviously needing speedup.

Modified files:
U   puzzles/undead.c

Links:
http://svn.tartarus.org/sgt/?rev=9826&view=rev
http://svn.tartarus.org/sgt/puzzles/undead.c?rev=9826&r1=9825&r2=9826



More information about the tartarus-commits mailing list