Exemplo n.º 1
0
def run_KB_test(statements, question, expected):
  agent.pyagent_initialize()
  start_time = round(time.clock(), 2)
  for statement in statements:
      agent.KB.tell(statement)
  actual = agent.KB.ask(question)
  end_time = round(time.clock(), 2)
  output_test_results(expected, actual, end_time - start_time)
Exemplo n.º 2
0
def run_get_adjacent_cells_test(cell, expected):
  agent.pyagent_initialize()
  start_time = round(time.clock(), 2)
  agent.KB.tell("Wall(6_2, 5_2)")
  agent.KB.tell("Wall(5_2, 6_2)")
  actual = agent.get_adjacent_cells(cell)
  end_time = round(time.clock(), 2)
  output_test_results(expected, actual, end_time - start_time)
Exemplo n.º 3
0
 def process(self, percept):
     """ process: call the agent's process method, passing to it the percepts """
     if self.manual_agent:
         return ManualPyAgent.pyagent_process(percept.stench,
                                              percept.breeze,
                                              percept.glitter, percept.bump,
                                              percept.scream,
                                              percept.compass)
     else:
         return PyAgent.pyagent_process(percept.stench, percept.breeze,
                                        percept.glitter, percept.bump,
                                        percept.scream, percept.compass)
Exemplo n.º 4
0
 def initialize(self):
     """ initialize: call the agent's initialize method """
     if self.manual_agent:
         ManualPyAgent.pyagent_initialize()
     else:
         PyAgent.pyagent_initialize()
Exemplo n.º 5
0
def run_coordinate_to_string_test(coordinate, expected):
  start_time = round(time.clock(), 2)
  actual = agent.coordinate_to_string(coordinate)
  end_time = round(time.clock(), 2)
  output_test_results(expected, actual, end_time - start_time)
Exemplo n.º 6
0
def run_update_agent_direction_test(curr_dir, action, expected):
  agent.pyagent_initialize()
  start_time = round(time.clock(), 2)
  actual = agent.update_agent_direction(curr_dir, action)
  end_time = round(time.clock(), 2)
  output_test_results(expected, actual, end_time - start_time)
Exemplo n.º 7
0
def run_find_subsequence_test(subseq, seq, expected):
  agent.pyagent_initialize()
  start_time = round(time.clock(), 2)
  actual = agent.find_subsequence(subseq, seq)
  end_time = round(time.clock(), 2)
  output_test_results(expected, actual, end_time - start_time)
Exemplo n.º 8
0
 def destructor():
     """ deconstructor: call the agent's destructor """
     PyAgent.PyAgent_Destructor()
Exemplo n.º 9
0
 def game_over(score):
     """ game_over: call the agent's game over method, passing to it the final score """
     PyAgent.PyAgent_GameOver(score)
Exemplo n.º 10
0
 def process(percept):
     """ process: call the agent's process method, passing to it the percepts """
     return PyAgent.PyAgent_Process(percept.stench, percept.breeze,
                                    percept.glitter, percept.bump,
                                    percept.scream)
Exemplo n.º 11
0
 def initialize():
     """ initialize: call the agent's initialize method """
     PyAgent.PyAgent_Initialize()
Exemplo n.º 12
0
 def construct():
     """ construct: call the agent's constructor method """
     PyAgent.PyAgent_Constructor()