9.7 WorldModel

WorldModel contains all the information regarding the current state of the “world” ie the current state of :

  • The Current Game Mode: This is what is the current game mode which can be accessed by using worldModel->getPlayMode(); which returns an integer representing the playmode.
  • cycle
  • scoreLeft : the score of the team loaded in on the left
  • scoreRight : the score of the team loaded in on the right
  • time : the current game time

Each of the parameters can be accessed in a similar fashion as described for the game mode. For information on how these are implemented can be found in worldmodel.cc and worldmodel.h

It is important to note that an instance of this class is made in naobehavior.h which is then inherited by strategy.cc.

In addition to the above WorldModel contains a list of all the WorldObjects WorldObject worldObjects[NUM_WORLD_OBJS]; within the simulation, however, this is information that is relative to the current agent. Since all agents use their own cameras to estimate the state of the other game objects. This means that if the agent has not seen an object for a while its’ actual position might have changed and therefore be inaccurate. This is why the agent is always swiveling its head to try to see as much of the world as possible. This can be demonstrated through visualising where the agent thinks the other objects are through RoboViz.

The list of the gameobjects that WorldModel keeps track of include:

  • Teammates
  • Opponents
  • Corner Flags
  • Goal Posts
  • Ball

Different World Objects are stored at very particular locations Within this array of WorldObjects which can be seen in WorldObject.h For example the first player in my team is stored at index 1. This is seen by enum WorldObjType and the fact that if you over WO_TEAMMATE1 in vscode you are prompted with enum WorldObjType::WO_TEAMMATE1 = 1. The same process can be used to see that the ball object is stored at index 0 or WO_BALL. This enum WorldObjType simply is defining indexes for specific game objects. It is important to note that the first of the opponent gameobjects will be stored at index WO_OPPONENT1 which is equal to 12. Now this is irrelevant of if your team has only 2 or 5 or even 7 players only. It will also start at that point, now if your team only has 2 members then it should be obvious that worldObjects[WO_TEAMMATE3] wouldn’t contain any appropriate.