Commit 29bcdf83 authored by Oskar Skog's avatar Oskar Skog

0.4.13: Use a loop instead of recursion in the reveal method to allow really low mine densities

parent ddecc1f8
2016-12-25 Oskar Skog <[email protected]>
0.4.13
* anonymine_fields.py (generic_field.reveal): Use a loop instead of
recursion. Allows really low mine densities.
2016-12-23 Oskar Skog <[email protected]>
0.4.12
* RELEASE-NOTES: Added some old notes.
......
......@@ -15,7 +15,7 @@
NAME := anonymine
NAME_C := Anonymine
DESCRIPTION = Minesweeper without guessing
VERSION := pre-0.4.13
VERSION := 0.4.13
# Four more variables are required: sysconfdir, vargamesdir, EXECUTABLES and
# MODULES
......
......@@ -887,14 +887,17 @@ class game_engine():
while self.game_status in ('pre-game', 'play-game'):
interface.output(self)
interface.input(self)
# Won? Time?
game_won = self.game_status == 'game-won'
delta_time = time.time() - self.start
# Show everything.
if self.game_status == 'game-lost':
# This takes a long time in some really weird configurations.
# anonymine -m 1 -s 100x100
for cell in self.field.all_cells():
self.field.reveal(cell)
interface.output(self)
# Won? Time?
game_won = self.game_status == 'game-won'
delta_time = time.time() - self.start
# Create a proper paramstring for the hiscores object.
paramstring = '{0}{1}@{2}x{3}-{4}'.format(
{True: "", False: "lost/"}[game_won],
......
......@@ -23,7 +23,6 @@ import anonymine_engine
import random
import signal
import pprint
import profile
import os
def output(field, argument):
......@@ -86,6 +85,22 @@ def runmoore(x=78, y=18, m=225):
print(solver.solve())
def profile_solver(x, y, m):
field = anonymine_fields.generic_field([x, y])
mines = field.all_cells()
random.shuffle(mines)
field.fill(mines[:m])
for mine in mines[m:]:
for neighbour in field.get_neighbours(mine):
if neighbour in mines[:m]:
break
else:
field.reveal(mine)
break
solver = anonymine_solver.solver()
solver.field = field
solver.solve()
def run623():
field = anonymine_fields.generic_field([6, 6, 6])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment