DrunkAgent

DrunkAgent goes randomly around and shouts random things.

import random
from basic_agents import BasicAgent, BasicAgentFactory
 
class DrunkAgent(BasicAgent):
    def choose_action(self, game_state):
        self.say(random.choice(['Burp', 'Blah', 'Mrmmmf']))
        actions = game_state.getLegalActions(self.index)
        return random.choice(actions)
 
class DrunkAgentFactory(BasicAgentFactory):
    def get_agents_list(self):
        return [DrunkAgent, DrunkAgent]

Mouse Agents

by Valentin Haenel

Download the code here

""" These are some really simple mice that do not know very much about the maze.
    They don't compute and shortest paths but instead use a set of simple
    heuristics to navigate. Also they only care about food and will not run
    away from or pursue the enemy.
 
    Random Mouse:
        This is a bit better than a brownian agent. Instead of always making
        random moves it only makes random moves at junctions. In corridors, it
        keeps going forward. If it hits a dead-end it will turn around.
 
    Danger Mouse:
        This is a bit better than the RagndomMouse. This mouse knows about the
        cheese. Instead of making random moves at junctions it trys to move
        towards its current food. The current food is selected at random in the
        beginning, and then then it selects the closest. It always uses
        manhatten distance. If it can't move towards its current food at the
        given junction, it will make right hand turns until it can. If it gets
        stuck in a cycle (keeps moving through the same number of positions)
        then it will try to make a few right had turns until it can move towards
        the food again.
 
    The agents serve to demonstrate some basic techniques such storing game
    state position and moves, and how to navigate without knowing anything about
    the maze other than what can be seen. In pacman however you know what the
    maze looks like, and you should probably use a shortest-path algorithm to
    navigate from A to B. This will most certainly be more effective than these
    poor mice :-)
"""