Wireframe - #35 - 2020

(Joyce) #1
wfmag.cc \ 33

Substitute Soccer

Toolbox


to make players feel like they were on the pitch
rather than [being] an uninvolved member of a
TV audience.”


SUBSTITUTE SOCCER
To make our tribute to Sensible Soccer, we need
to bear a few important things in mind first. We’ll
start by looking at the classes which contain the
bulk of the game’s code. Game, Ball, Player, and
Goal are all pretty self-explanatory – although we
should note that the Player class is used by each
of the 14 football players on the pitch, only one
or two (depending on the game mode) of which
are controlled by a human player at any one time.
Whereas in some other games an instance of the
Player class is the manifestation of the human
player in the game, in Substitute Soccer it makes
more sense to think in terms of a particular team
corresponding to a human player, rather than a
specific player on the pitch. Difficulty is used to
store and refer to a number of parameters which
are chosen based on the difficulty level. Controls
deals with control inputs (arrow keys and SPACE
for player 1, WSAD and left SHIFT for player 2).
Team stores an instance of the Controls class,
which determines the controls for the relevant
player – computer-controlled teams use the value
None here.
The Team class also keeps track of the active_
control_player – the player on the pitch currently
being controlled by a human, indicated by an
arrow over their head. When they don’t have the
ball, a human player can switch the


VISUALISATION QUEST
With so many computer-controlled players running around at once, it can be hard to verify that
the AI code is doing what it’s supposed to be doing – especially given that players can change
roles multiple times within the space of a few seconds. One moment a player might be acting
as a goalie, then he might be one of the ‘lead’ players trying to tackle the ball owner, then he
might be marking a player on the opposite team. One way to help confirm that everything is
working as it should is to use debug visualisations. Near the top of the code, you’ll see a number
of constants such as DEBUG_SHOW_TARGETS. When set to True, Game.draw displays a line from each
player, showing the position they’re currently running towards. Debug visualisations can also be
useful for learning how a game works. Try turning on each one – preferably one at a time.

 The menu screen enables
the selection of number
of players and one-player
difficulty level.
Free download pdf