Introduction
MRB's Documentation
Walkthrough
    The General Idea
    MasterControl
    The Modules
    The World
Design Suggestions Modified MRB Source

Code Walkthrough: MasterControl

MasterControl is the only subclass of the class Player.  Between MasterControl and Player there are functions to inspect player attributes such as amIGoalie(), getMyNumber(), etc.; functions to interact with the world, getSnapShot(), worldFeedbackAudio(), say(), etc.; and functions to compute actions such as play and act.  The class also has member variables of a communication object (comm), an object to convert actions into server commands  (skills), and the world model (world).

MasterControl's constructor instantiates two evaluation objects (goaleval and passeval) and nine modules.  Several of these modules take in information about whether the player is a goalie, a pointer to passeval, and a pointer to goaleval.

MasterControl's worldFeedbackAudio and worldGetSayMsg functions call FeedbackAudio and GetSayMsg on MasterControl's world member variable.  Throughout the code information transceived with the soccer server is called audio. Functions call FeedbackAudio take messages received from the soccer server and pass them to an object for processing.  Functions called SayMsg create messages to send to the soccer server.

MasterControl's getSnapshot function returns a snapshot generated by the world.  The snapshots are later passed to the modules.

The function play in Player connects the player to the soccer server with the comm object and adjusts the world to the present state of the field.  Play then calls act to decide and then take action on the field.

The function act is where all the fun is.  In this function, the information that is received from the soccer server (audiomsg) is passed into each module.  Then, a snapshot from the worldmodel is taken.  This snapshot is fed to the tactical module.  The tactical module returns a tactical snapshot and the snapshot and the tactical snapshot are fed back to each of the modules (except tactical module).  Evaluate is called on each module except tacticalmodule (which has no evaluate function).  The evaluation returns a grade from 0 to 100 that describes the "best" action to take.  A sequence of if statements then decides which action to take based on the "best" grade. A switch statement on the decision then calls the act function on a specific module.

 

Previous: The General Idea Next: The Modules