The playing area is encapsulated by the class SoccerPitch. A single
instance of this class is instantiated in main.cpp. The
owns instances of
SoccerTeam, SoccerBall, and Goal objects.
Here’s the class declaration:
These first few members are self explanatory and I’ll be describing the rel
evant classes in detail in a few pages.
//container for the boundary walls
The pitch boundaries in the Simple Soccer environment are represented by
Wall2Ds. Walls are described by a line segment with two endpoints and a
normal to the line segment representing the facing direction. You may
remember them from the wall avoidance steering behavior description.
//defines the dimensions of the playing area
A Region object is used to describe the dimensions of the soccer pitch. A
Region stores the top left, right bottom, and center positions of the declared
area, and also an identifying number (ID).
Soccer players have to know where they are on the soccer pitch and
although their x, y coordinates give a very specific position, it’s also useful
to split the pitch up into regions players can make use of to implement
strategies. To facilitate this, the pitch is divided into eighteen areas as
shown in Figure 4.3.
At the beginning of a game, each player is assigned a region to be its
home region. This will be the region it returns to after a goal is scored or
when it has finished making a play with the ball. A player’s home region
may vary during a game depending on the team strategy. For example,
when attacking, it’s advantageous for a team to occupy positions farther
forward on the field (upfield) than when defending.
136 | Chapter 4
The Simple Soccer Environment and Rules