Beispiel #1
0
 def remove(self, hex):
     remove = self.state[hex]
     if hexes.add(hex, hexes.down) in self.state:
         self.state[hex] = self.remove(hexes.add(hex, hexes.down))
     else:
         del self.state[hex]
     return remove
Beispiel #2
0
 def hopper_moves(self, hex):
     hopper_moves = set()
     for offset in hexes.offsets:
         destination = hexes.add(hex, offset)
         if destination in self.state:
             while destination in self.state:
                 destination = hexes.add(destination, offset)
             hopper_moves.add(destination)
     return hopper_moves
Beispiel #3
0
def test_spider_moves_middle(m):
    set_state(m, 'ws wa', step=3)
    assert len(m.spider_moves(hexes.centre)) == 2
    left, right = m.spider_moves(hexes.centre)
    assert hexes.add(left, right) == hexes.centre
Beispiel #4
0
 def add(self, token, hex):
     if hex in self.state:
         self.add(self.state[hex], hexes.add(hex, hexes.down))
     self.state[hex] = token
Beispiel #5
0
 def beetle_moves(self, hex):
     if hexes.add(hex, hexes.down) in self.state:
         return hexes.neighbours(hex)
     else:
         return hexes.merge(
             self.crawl_moves(hex)) | self.occupied_neighbours(hex)
Beispiel #6
0
def test_up_down():
    assert hexes.add(hexes.up, hexes.down) == hexes.centre
Beispiel #7
0
def test_opposite():
    for offset in hexes.offsets:
        assert hexes.opposite(hexes.opposite(offset)) == offset
        assert hexes.add(hexes.opposite(offset), offset) == hexes.centre
Beispiel #8
0
def test_add():
    assert hexes.add((1, 2, 3), (4, 5, 6)) == (5, 7, 9)