Package agents

Class RandomAgent

  • All Implemented Interfaces:
    Agent

    public class RandomAgent
    extends java.lang.Object
    implements Agent
    An interface for representing an agent in the game Love Letter All agent's must have a 0 parameter constructor
    • Constructor Summary

      Constructors 
      Constructor Description
      RandomAgent()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void newRound​(State start)
      Method called at the start of a round
      Action playCard​(Card c)
      Perform an action after drawing a card from the deck
      void see​(Action act, State results)
      Method called when any agent performs an action.
      java.lang.String toString()
      Reports the agents name
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • RandomAgent

        public RandomAgent()
    • Method Detail

      • toString

        public java.lang.String toString()
        Reports the agents name
        Specified by:
        toString in interface Agent
        Overrides:
        toString in class java.lang.Object
      • newRound

        public void newRound​(State start)
        Method called at the start of a round
        Specified by:
        newRound in interface Agent
        Parameters:
        start - the starting state of the round
      • see

        public void see​(Action act,
                        State results)
        Method called when any agent performs an action.
        Specified by:
        see in interface Agent
        Parameters:
        act - the action an agent performs
        results - the state of play the agent is able to observe.
      • playCard

        public Action playCard​(Card c)
        Perform an action after drawing a card from the deck
        Specified by:
        playCard in interface Agent
        Parameters:
        c - the card drawn from the deck
        Returns:
        the action the agent chooses to perform
        Throws:
        IllegalActionException - when the Action produced is not legal.