Adds find_file method

This commit is contained in:
Thomas Forgione 2019-03-26 15:25:06 +01:00
parent 5d1c96407b
commit 3fd1010559
No known key found for this signature in database
GPG Key ID: 203DAEA747F48F41
1 changed files with 14 additions and 0 deletions

View File

@ -25,7 +25,21 @@ class Player(object):
def __init__(self):
pass
def find_file(self, name):
"""
Returns the correct path for finding an asset file (like neural network
weights file) in the directory where the Ai class is.
:name the name of the file to look for
"""
return self.__module__.replace('.', '/') + '/' + name
def next_position_and_direction(self, current_position, id, map):
"""
Computes the direction of the player, and computes its next position
depending on the current position.
"""
direction = self.action(map, id)
if direction == Direction.UP:
return ((current_position[0] - 1, current_position[1]), direction)