本文整理汇总了Python中game_state.GameState.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python GameState.__init__方法的具体用法?Python GameState.__init__怎么用?Python GameState.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类game_state.GameState
的用法示例。
在下文中一共展示了GameState.__init__方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from game_state import GameState [as 别名]
# 或者: from game_state.GameState import __init__ [as 别名]
def __init__(self, p, interactive=False, board_size=3, current_board=None):
''' (TippyGameState, str, int, list) -> NoneType
Initialize TippyGameState self with board_size '3x3'
Assume: '3x3' <= board_size is an str
p in {'p1', 'p2'}
'''
if interactive:
board_size = int(input('Board size? '))
GameState.__init__(self, p)
if not current_board: # if board is not created, create it
self.current_board = []
for x in range(board_size):
d = []
for y in range(board_size):
d.append('_ ')
self.current_board.append(d)
self.board_size = board_size
else:
self.current_board = deepcopy(current_board)
self.board_size = len(self.current_board)
# check if the game is over
self.over = self.winner(self.next_player) or self.winner(
self.opponent()) or self.possible_next_moves() == []
self.instructions = ('On your turn, you may put your symbol'
'on any empty position of the game board ')
示例2: __init__
# 需要导入模块: from game_state import GameState [as 别名]
# 或者: from game_state.GameState import __init__ [as 别名]
def __init__(self, p, interactive=False, grid_num=None, _grid=None):
'''
(TippyState, str)-> NoneType
Initialize the class TippyState with grid_num as the size of the grid
to be played on to form a Tippy.
'''
if interactive:
start_grid_num = input('Maximum grid number which is equal '
'or greater than 3? ')
while not start_grid_num.isnumeric():
start_grid_num = input('Maximum grid number which is equal '
'or greater than 3? ')
grid_num = randint(3, int(start_grid_num))
GameState.__init__(self, p)
self.grid_num = grid_num
self.instructions = ('On your turn, you may place at any position '
'so long as the row number and column number '
'not greater than the grid number.')
self._grid = {}
if _grid is None:
for i in range(grid_num + 1):
for j in range(grid_num + 1):
if j == 0:
self._grid[(i, j)] = i
elif i == 0:
self._grid[(i, j)] = j
else:
self._grid[(i, j)] = ' '
else:
self._grid = _grid
self.over = not self.possible_next_moves()
示例3: __init__
# 需要导入模块: from game_state import GameState [as 别名]
# 或者: from game_state.GameState import __init__ [as 别名]
def __init__(self, p, interactive=False, board=[], turn=0):
'''(TippyGameState, str, bool, list of list of str, int) -> None Type
Initialize TippyGameState self with a empty board on the first turn
'''
GameState.__init__(self, p)
'''
Create a 2D board. ' ' means empty, 'x' means a x piece on the
board, 'o' means a o piece on the board
'''
self.board = deepcopy(board)
if interactive:
size = int(input('Enter board size. 3 or greater\n'))
while size < 3:
print('It has to be greater or equal to 3')
size = int(input('Enter board size. 3 or greater\n'))
self.board = [[TippyGameState.EMPTY] * size for i in range(size)]
if p == 'p1':
self.P1 = TippyGameState.PIECES[turn]
self.P2 = TippyGameState.PIECES[turn - 1]
else:
self.P2 = TippyGameState.PIECES[turn]
self.P1 = TippyGameState.PIECES[turn - 1]
self.turn = turn
self.over = self.game_over()
self.instructions = ('play to form a s-shaped or z-shaped tippy'
'\n'
'on your turn, you can choose a coordinate '
'on the board with no x or o piece on it')
示例4: __init__
# 需要导入模块: from game_state import GameState [as 别名]
# 或者: from game_state.GameState import __init__ [as 别名]
def __init__(self):
GameState.__init__(self, GameState.STATE_MENU, GameState.STATE_LOAD)
self.player_num = 1
self.background = None
self.title = None
self.title_rect = None
self.init_background()
self.text_helper = TextHelper()
item_objects_ss = SpriteSheet("data/item_objects.png")
self.selector_frame = item_objects_ss.get_image(coords.TITLE_SELECTOR, constants.IMG_MULTIPLIER)
示例5: __init__
# 需要导入模块: from game_state import GameState [as 别名]
# 或者: from game_state.GameState import __init__ [as 别名]
def __init__(self, p, interactive=False, current_total=0):
''' (SubtractSquareState, int, str) -> NoneType
Initialize SubtractSquareState self with current_total the number
to decrease to 0.
Assume: 0 <= current_total is an int
p in {'p1', 'p2'}
'''
if interactive:
current_total = randint(1, int(input('Maximum starting value? ')))
GameState.__init__(self, p)
self.current_total = current_total
self.instructions = ('On your turn, you may remove any number so long '
'as it is (a) a perfect square, and '
'(b) no more than the current number.')
示例6: __init__
# 需要导入模块: from game_state import GameState [as 别名]
# 或者: from game_state.GameState import __init__ [as 别名]
def __init__(self, p, interactive=False, dimension=3):
"""(TippyGameState, str, bool, int -> NoneType
Initialize TippyGameState self.
Assume: p in {'p1', 'p2'} and dimension is an int that >= 3
"""
if interactive:
dimension = int(input("How many columns and rows do you"
" want the grid to have:"))
self.grid = [[0 for i in range(dimension)] for j in range(dimension)]
GameState.__init__(self, p)
self.instruction = ("In your turn, you may place a placeholder"
" (cross or circle) at a position that has"
" not been taken, until you form a tippy")
self.dimension = dimension
self.interactive = interactive
self.over = False
示例7: __init__
# 需要导入模块: from game_state import GameState [as 别名]
# 或者: from game_state.GameState import __init__ [as 别名]
def __init__(self, p, interactive=False, board=[], turn=0):
'''(TippyGameState, str, int, int) -> None Type
'''
GameState.__init__(self, p)
'''
Create a 2D board. ' ' means empty, 'x' means a x piece on the
board, 'o' means a o piece on the board
'''
self.board = deepcopy(board)
if interactive:
size = int(input('Enter the size of the board\n'))
self.board = [ [self.EMPTY] * size for i in range(size)]
if p == 'p1':
self.P1 = self.PIECES[turn]
self.P2 = self.PIECES[turn - 1]
else:
self.P2 = self.PIECES[turn]
self.P1 = self.PIECES[turn - 1]
self.turn = turn #change
self.instructions = 'play the goddamn game'
示例8: __init__
# 需要导入模块: from game_state import GameState [as 别名]
# 或者: from game_state.GameState import __init__ [as 别名]
def __init__(self, game_info, sound_manager):
GameState.__init__(self, GameState.STATE_GAME, GameState.STATE_LOAD)
self.game_info = game_info
self.sound_manager = sound_manager
self.game_info.set_timer_in_seconds(300)
self.mario_game_time = -1
self.world_shift = 0
self.player = Player(self.sound_manager, game_info)
self.active_sprite_list = pygame.sprite.Group()
self.active_sprite_list.add(self.player)
self.level = Level(game_info, self.player, self.sound_manager)
if constants.DEBUG:
self.debug_overlay = DebugOverlay(self.game_info, self.player)
self.sound_manager.play_music(constants.MUSIC_MAIN_THEME)
示例9: __init__
# 需要导入模块: from game_state import GameState [as 别名]
# 或者: from game_state.GameState import __init__ [as 别名]
def __init__(self, p, interactive=False,
board_length=0, moves_p1=[], moves_p2=[]):
''' (TippyGameState, str, bool, str) -> NoneType
Initialize TippyGameState self with board_length as the dimension of
the board
Assume: 3 <= board_length is an int
p in {'p1', 'p2'}
'''
if interactive:
board_length = int(input('What board size do you want? '))
GameState.__init__(self, p)
self.board_length = board_length
self.instructions = ('Tippy is a variation of tic-tac-toe. '+
'Win the game by forming a z shape in four grids.')
self.moves_p1 = moves_p1
self.moves_p2 = moves_p2
if (self.winner('p1')
or self.winner('p2')
or self.possible_next_moves() == []):
self.over = True