level 4 walls, good laser still under development (algorithm discovered,

implementation next up)
This commit is contained in:
Niels Serup
2012-08-13 00:05:44 +02:00
parent 4a8a5b5d70
commit 9d7bb2e946
3 changed files with 58 additions and 48 deletions

View File

@@ -29,6 +29,10 @@ class Direction(object):
def next_pos(pos):
raise NotImplementedError
@staticmethod
def to_str():
raise NotImplementedError
@staticmethod
def from_sakse(p):
return {(0, -1): Up,
@@ -42,24 +46,40 @@ class Up(Direction):
x, y = pos
return x, y - 1
@staticmethod
def to_str():
return 'up'
class Right(Direction):
@staticmethod
def next_pos(pos):
x, y = pos
return x + 1, y
@staticmethod
def to_str():
return 'right'
class Down(Direction):
@staticmethod
def next_pos(pos):
x, y = pos
return x, y + 1
@staticmethod
def to_str():
return 'down'
class Left(Direction):
@staticmethod
def next_pos(pos):
x, y = pos
return x - 1, y
@staticmethod
def to_str():
return 'left'
all_directions = (Up, Right, Down, Left)
_sp = lambda n: lambda d: all_directions[(all_directions.index(d) + n) % 4]
succ, pred = _sp(1), _sp(-1)