level 4 walls, good laser still under development (algorithm discovered,
implementation next up)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user