本文整理汇总了Python中actions.Actions.get_successor方法的典型用法代码示例。如果您正苦于以下问题:Python Actions.get_successor方法的具体用法?Python Actions.get_successor怎么用?Python Actions.get_successor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类actions.Actions
的用法示例。
在下文中一共展示了Actions.get_successor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apply_action
# 需要导入模块: from actions import Actions [as 别名]
# 或者: from actions.Actions import get_successor [as 别名]
def apply_action(state, action):
""" Edits the state to reflect the results of the action.
(State, str) -> None
"""
if action not in BlackBirdRules.get_legal_actions(state):
raise Exception("Illegal action " + str(action))
state.score_change = 0
next_pos = Actions.get_successor(state.black_bird_position, action)
state.black_bird_position = next_pos
# if next_pos == state.red_bird_position :
# print( "Black moving into Red's position" )
if next_pos in state.yellow_birds:
state.score_change -= state.current_yellow_bird_score
state.yellow_birds = tuple([yb for yb in state.yellow_birds if yb != next_pos])
state._yellow_bird_eaten = next_pos
if not state.yellow_birds:
print("All Birds Eaten")
state.terminal = True
if state.red_bird_position == state.black_bird_position :
state.red_bird_dead = True # Black eats Red
print("Black EATS Red!")
state.score_change -= 250
if state.black_bird_position is not None:
state.current_yellow_bird_score *= 0.99
if state.current_yellow_bird_score < 0.5 :
print("Game Over - All the Yellow Birds Have Flown Away!")
示例2: apply_action
# 需要导入模块: from actions import Actions [as 别名]
# 或者: from actions.Actions import get_successor [as 别名]
def apply_action(state, action):
""" Edits the state to reflect the results of the action.
(State, str) -> None
"""
if action not in BlackBirdRules.get_legal_actions(state):
raise Exception("Illegal action " + str(action))
state.score_change = 0
next_pos = Actions.get_successor(state.black_bird_position, action)
state.black_bird_position = next_pos
if next_pos in state.yellow_birds:
state.score_change -= state.current_yellow_bird_score
state.yellow_birds = tuple([yb for yb in state.yellow_birds if yb != next_pos])
state._yellow_bird_eaten = next_pos
if state.black_bird_position is not None:
state.current_yellow_bird_score = max(1, state.current_yellow_bird_score - 1)
if not state.yellow_birds:
state.terminal = True