Package kuimaze :: Module baseagent
[hide private]
[frames] | no frames]

Source Code for Module kuimaze.baseagent

 1  #!/usr/bin/env python 
 2  # -*- coding: utf-8 -*- 
 3   
 4  ''' 
 5  Contains class BaseAgent from which all of players must inherit. 
 6  @author: Zdeněk Rozsypálek, and the KUI-2018 team 
 7  @contact: svobodat@fel.cvut.cz 
 8  @copyright: (c) 2017, 2018 
 9  ''' 
10   
11  import collections 
12  import random 
13   
14  import kuimaze.maze 
15   
16   
17 -class BaseAgent:
18 ''' 19 Base class for players. All student solutions must inherit from this class. 20 ''' 21
22 - def __init__(self, problem):
23 ''' 24 All inherited players must call this method. Expects problem to be instance of L{kuimaze.Maze}. 25 If problem has L{show_level<kuimaze.SHOW>} other than L{kuimaze.SHOW.NONE}, it will start a GUI automatically. 26 27 @param problem: Maze to associate your player with: 28 @type problem: L{Maze} 29 @raise AssertionError: if problem is not an instance of L{Maze} 30 ''' 31 assert(isinstance(problem, kuimaze.maze.Maze)) 32 self.problem = problem 33 self.problem.set_player(self) # mainly for visualisazion
34 35
36 - def find_path(self):
37 ''' 38 Method that must be implemented. Otherwise raise NotImplementedError. Expects to return a path_section as a list of positions [[x1, y1], [x2, y2], ... ]. 39 40 @return: path_section as a list of positions [(x1, y1), (x2, y2), ... ]. Must 41 42 ''' 43 raise NotImplementedError('Not implemented yet')
44