agent.py 448 B

1234567891011121314
  1. #!/usr/bin/env python3
  2. from environment import State, goalTest, actions, result
  3. from collections import deque
  4. # Example of goal-oriented agent.
  5. frontier = deque() # Initialize the frontier as a queue
  6. state = State() # Generate the initial state
  7. while not goalTest(state): # Apply the global test
  8. for action in actions(state): # Expand the node
  9. frontier.append(result(state, action))
  10. state = frontier.popleft()
  11. state.printState()