本文整理汇总了Python中Map.surround_with方法的典型用法代码示例。如果您正苦于以下问题:Python Map.surround_with方法的具体用法?Python Map.surround_with怎么用?Python Map.surround_with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map.surround_with方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Player
# 需要导入模块: import Map [as 别名]
# 或者: from Map import surround_with [as 别名]
#.........这里部分代码省略.........
def cleanup_ships_map(self):
"""
Cleanup the ships map of all the helpful water fields.
"""
mymap = self.ships
mymap.set_fields(mymap.get_fields('water'), None)
def save_foes_ships(self, shipdef):
# I have to copy this dictionary deeply, not copying the
# reference to it only.
self.foeships = copy.deepcopy(shipdef)
def is_all_sunk(self):
"""
Returns True when all own ships are sunk.
"""
if self.ship_count < 1: return True
return False
def turn(self):
"""
Play one turn and return a koordninate to bomb the foe's ships.
Returns None when when player resigns or has no possible turn left.
"""
if self.human:
# This is the human part of turn() -- I do not comment it
# and left it to the reader...
if self.last_result:
lkoor,lstat = self.last_result
if lstat == 'sunk':
self.hits.surround_with(lkoor, 'water')
elif lstat == 'hit':
self._mark_hit_ship(lkoor)
bomb_map = self.hits
ship_map = self.ships
koor = None # is a tuple()
while True:
line = input( "\nCaptain> " )
token = line.rstrip("\n").split()
token.append('') # empty lines fail to pop()
cmd = token.pop(0).lower()
if re.match('^(resign|aufgeben|quit|exit|ende|stop)', cmd):
exit(0)
elif re.match('^(hilfe|help)', cmd):
_print_help()
elif re.match('^(skip)', cmd):
break
elif cmd == '':
bomb_map.print()
elif cmd == 'ships':
ship_map.print()
elif cmd == 'strategie':
t_map = self._best_moves()
Map(t_map).print()
elif cmd == 'tmap':
t_map = self._rate_unknown_fields(int(token[0]))
Map(t_map).print()
elif cmd == 'tipp':
t_map = self._best_moves()
# Map(t_map).print()