Пример #1
0
 def create_side_stones(self, stone_size):
     hstones = {
         "bee": hs.hexagon_stone(stone_size, "bee"),
         "ant": hs.hexagon_stone(stone_size, "ant"),
         "hopper": hs.hexagon_stone(stone_size, "hopper"),
         "spider": hs.hexagon_stone(stone_size, "spider"),
         "bug": hs.hexagon_stone(stone_size, "bug")
     }  #bug stone here does not need init underlaying stones
     for hstone in hstones.values():
         hstone.set_color(self.color)
         hstone.is_empty = False
     return hstones
Пример #2
0
 def __init__(self, locator=None):
     self.locator = locator
     self.board = self.locator.board  #note that the locator always contains the board object of the actual game
     self.empty_help_stone = hs.hexagon_stone(self.board.hexagon_size,
                                              "empty", 99)
     self.graph = hg.Hexagon_Graph(
         self.board)  #doesnt contain points or edges yet
Пример #3
0
 def set_empty_hexagon_board(self):
     hexagon_board = {}
     for i in range(self.size):
         for j in range(self.size):
             hexagon_board[(i,j)] = hs.hexagon_stone(self.hexagon_size)
             hexagon_board[(i,j)].set_board_pos((i,j))
     return hexagon_board
Пример #4
0
 def copy_board_matrix(board_matrix):
     copied_board = {}
     for hstone in board_matrix.values():
         hexagon_copy = hs.hexagon_stone(hstone.size)
         hexagon_copy.copy_hexagon(hstone)
         copied_board[hstone.board_pos] = hexagon_copy
     return copied_board
Пример #5
0
 def execute_stone_move(self, player, fhex, shex):
     
     old_board_pos = fhex.board_pos
     old_pixel_pos = fhex.pixel_pos
     fhex.set_board_pos(shex.board_pos)
     fhex.set_pixel_pos(shex.pixel_pos)
     #refill "old" place with empty stone
     new_empty_stone = hs.hexagon_stone(fhex.size)
     new_empty_stone.set_pixel_pos(old_pixel_pos)
     new_empty_stone.set_board_pos(old_board_pos)
     self.board[old_board_pos] = new_empty_stone
     #fill "new" place with fhex
     self.board[fhex.board_pos] = fhex
     #actualize board.nonempty_fields
     self.nonempty_fields.append(fhex.board_pos)
     self.nonempty_fields.remove(old_board_pos)
Пример #6
0
 def move_bug_on_nonempty_stone(self, player, fhex, shex):
     
     old_board_pos = fhex.board_pos
     old_pixel_pos = fhex.pixel_pos
     fhex.set_board_pos(shex.board_pos)
     fhex.set_pixel_pos(shex.pixel_pos)
     
     if fhex.underlaying_stones: #case: fhex sits on at least one stone
         #get stone which lies directly under the bug
         last_stone = fhex.underlaying_stones[-1]
         fhex.underlaying_stones.clear()
         #define new stones under the bug
         if shex.type == "bug":
             fhex.underlaying_stones = shex.underlaying_stones.copy()
         if not shex.is_empty:
             fhex.underlaying_stones.append(shex)
             shex.has_bug_on = True
         if shex.is_empty:
             self.nonempty_fields.append(fhex.board_pos)
         last_stone.has_bug_on = False
         #check whether fhex is mosquito. if it is and shex.is_empty then reput "mosquito" type
         if fhex.is_mosquito and shex.is_empty: fhex.type = "mosquito"
         #refill old place with last_stone and new place with fhex
         self.board[old_board_pos] = last_stone
         self.board[fhex.board_pos] = fhex
         #no adaptation for nonempty_fields needed
         
     else: #case: bug will certainly move from an empty field onto a nonempty field
         if shex.type == "bug":
             fhex.underlaying_stones = shex.underlaying_stones.copy()
         fhex.underlaying_stones.append(shex)
         shex.has_bug_on = True
         #check mosquito.
         if fhex.is_mosquito: fhex.type = "bug"
         #refill "old" place with empty stone
         new_empty_stone = hs.hexagon_stone(fhex.size)
         new_empty_stone.set_pixel_pos(old_pixel_pos)
         new_empty_stone.set_board_pos(old_board_pos)
         self.board[old_board_pos] = new_empty_stone
         #fill "new" place with fhex
         self.board[fhex.board_pos] = fhex
         #actualize board.nonempty_fields
         self.nonempty_fields.remove(old_board_pos)
Пример #7
0
 def create_stones(self, stone_size):
     hstones = {
         "bee": {
             1: hs.hexagon_stone(stone_size, "bee", 1)
         },
         "ant": {
             1: hs.hexagon_stone(stone_size, "ant", 1),
             2: hs.hexagon_stone(stone_size, "ant", 2),
             3: hs.hexagon_stone(stone_size, "ant", 3)
         },
         "hopper": {
             1: hs.hexagon_stone(stone_size, "hopper", 1),
             2: hs.hexagon_stone(stone_size, "hopper", 2),
             3: hs.hexagon_stone(stone_size, "hopper", 3)
         },
         "spider": {
             1: hs.hexagon_stone(stone_size, "spider", 1),
             2: hs.hexagon_stone(stone_size, "spider", 2)
         },
         "bug": {
             1: hs.hexagon_stone(stone_size, "bug", 1),
             2: hs.hexagon_stone(stone_size, "bug", 2)
         }
     }
     for hstones1 in hstones.values():
         for hstone in hstones1.values():
             hstone.set_color(self.color)
             hstone.is_empty = False
     for hstone in hstones["bug"].values():
         hstone.init_underlaying_stones(
         )  #initialize underlying stones with empty list
     return hstones
Пример #8
0
 def create_stones(self, stone_size):
     hstones = {
         "bee": {
             1: hs.hexagon_stone(stone_size, "bee", 1)
         },
         "ant": {
             1: hs.hexagon_stone(stone_size, "ant", 1),
             2: hs.hexagon_stone(stone_size, "ant", 2),
             3: hs.hexagon_stone(stone_size, "ant", 3)
         },
         "hopper": {
             1: hs.hexagon_stone(stone_size, "hopper", 1),
             2: hs.hexagon_stone(stone_size, "hopper", 2),
             3: hs.hexagon_stone(stone_size, "hopper", 3)
         },
         "spider": {
             1: hs.hexagon_stone(stone_size, "spider", 1),
             2: hs.hexagon_stone(stone_size, "spider", 2)
         },
         "bug": {
             1: hs.hexagon_stone(stone_size, "bug", 1),
             2: hs.hexagon_stone(stone_size, "bug", 2)
         },
         "mosquito": {
             1: hs.hexagon_stone(stone_size, "mosquito", 1)
         },
         "ladybug": {
             1: hs.hexagon_stone(stone_size, "ladybug", 1)
         }
     }
     for hstones1 in hstones.values():
         for hstone in hstones1.values():
             hstone.set_color(self.color)
             hstone.is_empty = False
     for hstone in hstones["bug"].values():
         hstone.init_underlaying_stones(
         )  #initialize underlying stones with empty list
     #care about mosquito attributes
     hstones["mosquito"][1].init_underlaying_stones()
     hstones["mosquito"][1].is_mosquito = True
     return hstones