Changeset 72:aa4bd93575d9


Ignore:
Timestamp:
Aug 31, 2009, 10:44:21 PM (11 years ago)
Author:
Neil Muller <drnlmuller@…>
Branch:
default
Convert:
svn:b4e93282-eac8-4b8b-b765-0f5d36de2b68@73
Message:

Fix some bound checking and tweak movement costs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gamelib/animal.py

    r71 r72  
    6464            'grassland' : 2,
    6565            'woodland' : 1, # Try to keep to the woods if possible
    66             'broken fence' : 1,
     66            'broken fence' : 2,
    6767            'fence' : 10,
    68             'guardtower' : 1, # We can pass under towers
    69             'henhouse' : 1,
     68            'guardtower' : 2, # We can pass under towers
     69            'henhouse' : 2,
    7070            }
    7171
     
    182182            dist = 10
    183183            for poss in moves:
    184                 this_tile = gameboard.tv.get(poss.to_tuple())
     184                if gameboard.in_bounds(poss):
     185                    this_tile = gameboard.tv.get(poss.to_tuple())
     186                else:
     187                    this_tile = tiles.REVERSE_TILE_MAP['woodland']
    185188                new_dist = poss.dist(new_pos)
    186189                if new_dist < dist:
    187190                    dist = new_dist
    188191                    final_pos = poss
    189         this_tile = gameboard.tv.get(final_pos.to_tuple())
     192        if gameboard.in_bounds(final_pos):
     193            this_tile = gameboard.tv.get(final_pos.to_tuple())
     194        else:
     195            this_tile = tiles.REVERSE_TILE_MAP['woodland']
    190196        if tiles.TILE_MAP[this_tile] == 'broken fence' and self.hunting:
    191197            # We'll head back towards the holes we make/find
Note: See TracChangeset for help on using the changeset viewer.