java.lang.Object
za.co.wethinkcode.robots.client.memory.Memory

public class Memory extends Object
This class stores the memory of the currently running client The currently selected robot as well as all the robots launched

The memory is best thought of as it's own runtime that abstracts state out of the currently connected client

The Memory Class also contains the WorldKnowledge record, which stores all the currently known info about the world the client has

  • Constructor Details

    • Memory

      public Memory(String ipAddress, int port, Client client)
      Standard constructor for a Memory instance
      Parameters:
      ipAddress - ipAddress that is associated with this client
      port - that this Client is connected on
      client - the client that is associated with this memory
  • Method Details

    • getClient

      public Client getClient()
    • getWorldKnowledge

      public WorldKnowledge getWorldKnowledge()
    • getLastRequestResponse

      public Optional<RequestResponse> getLastRequestResponse()
    • getRobotNames

      public HashMap<String,ClientRobot> getRobotNames()
      Returns:
      Simple getter for all the client bots the client is aware of
    • hasCurrentRobot

      public boolean hasCurrentRobot()
      Returns:
      if a currentRobot has been set
    • addAndSetCurrentRobot

      public void addAndSetCurrentRobot(ClientRobot currentRobot)
      Add and automatically set a new ClientRobot that commands will be sent from
      Parameters:
      currentRobot - the new ClientRobot
    • setCurrentRobot

      public void setCurrentRobot(ClientRobot currentRobot)
      Set the current robot that commands will be sent from to a robot that is displayed here
      Parameters:
      currentRobot - the robot being switched to
    • addWorldKnowledge

      public void addWorldKnowledge(com.google.gson.JsonObject worldCommandResponseFull)
      Accept the input of a World Command.
      Parameters:
      worldCommandResponseFull - response
    • getCurrentRobot

      public Optional<ClientRobot> getCurrentRobot()
    • getLastResponse

      public Optional<com.google.gson.JsonObject> getLastResponse()
      Return the last response from the server
    • updateMemory

      public void updateMemory(InputParser parsedInput, com.google.gson.JsonObject request, com.google.gson.JsonObject response, AtomicBoolean running)
      Take in the parsed input from the user, the response from the server, and update the Memory accordingly
      Parameters:
      parsedInput - syntactically valid input from a client
      response - the parsed and syntactically valid response from the server