Skip to content

Commit

Permalink
Poprawki tłumaczenia basic strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
xinulsw committed Apr 28, 2015
1 parent d857f3f commit 748e713
Showing 1 changed file with 36 additions and 35 deletions.
71 changes: 36 additions & 35 deletions docs/rg/basic_strategy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -220,43 +220,44 @@ implemetację robota wyposażonego we wszystkie założone wyżej właściwości
import rg
class Robot:
all_locs = {(x, y) for x in xrange(19) for y in xrange(19)}
spawn = {loc for loc in all_locs if 'spawn' in rg.loc_types(loc)}
obstacle = {loc for loc in all_locs if 'obstacle' in rg.loc_types(loc)}
team = {loc for loc in game.robots if game.robots[loc].player_id == self.player_id}
enemy = set(game.robots)-team
adjacent = set(rg.locs_around(self.location)) - obstacle
adjacent_enemy = adjacent & enemy
adjacent_enemy2 = {loc for loc in adjacent if (set(rg.locs_around(loc)) & enemy)} - team
safe = adjacent - adjacent_enemy - adjacent_enemy2 - spawn - team
def mindist(bots, loc):
return min(bots, key=lambda x: rg.dist(x, loc))
if enemy:
closest_enemy = mindist(enemy,self.location)
else
closest_enemy = rg.CENTER_POINT
# akcja domyślna, którą nadpiszemy, jak znajdziemy coś lepszego
move = ['guard']
if self.location in spawn:
if safe:
move = ['move', mindist(safe, rg.CENTER_POINT)]
elif adjacent_enemy:
if 9*len(adjacent_enemy) >= self.hp:
def act(self, game):
all_locs = {(x, y) for x in xrange(19) for y in xrange(19)}
spawn = {loc for loc in all_locs if 'spawn' in rg.loc_types(loc)}
obstacle = {loc for loc in all_locs if 'obstacle' in rg.loc_types(loc)}
team = {loc for loc in game.robots if game.robots[loc].player_id == self.player_id}
enemy = set(game.robots)-team
adjacent = set(rg.locs_around(self.location)) - obstacle
adjacent_enemy = adjacent & enemy
adjacent_enemy2 = {loc for loc in adjacent if (set(rg.locs_around(loc)) & enemy)} - team
safe = adjacent - adjacent_enemy - adjacent_enemy2 - spawn - team
def mindist(bots, loc):
return min(bots, key=lambda x: rg.dist(x, loc))
if enemy:
closest_enemy = mindist(enemy,self.location)
else
closest_enemy = rg.CENTER_POINT
# akcja domyślna, którą nadpiszemy, jak znajdziemy coś lepszego
move = ['guard']
if self.location in spawn:
if safe:
move = ['move', mindist(safe, rg.CENTER_POINT)]
else:
move = ['attack', adjacent_enemy.pop()]
elif adjacent_enemy2:
move = ['attack', adjacent_enemy2.pop()]
elif safe:
move = ['move', mindist(safe, closest_enemy)]
return move
elif adjacent_enemy:
if 9*len(adjacent_enemy) >= self.hp:
if safe:
move = ['move', mindist(safe, rg.CENTER_POINT)]
else:
move = ['attack', adjacent_enemy.pop()]
elif adjacent_enemy2:
move = ['attack', adjacent_enemy2.pop()]
elif safe:
move = ['move', mindist(safe, closest_enemy)]
return move
.. raw:: html

Expand Down

0 comments on commit 748e713

Please sign in to comment.