Core Classes
The concepts described above each have a corresponding class that encapsulates the logic for that concept. Here is a summary of the main classes involved in this game:
GameState
:
Represents the colony and some state information about the game, including how much food is available, how much time has elapsed, where the AntHomeBase
is, and all the Place
s in the game.
Place
:
Represents a single place that holds insects.
At most one Ant
can be in a single place, but there can be many Bee
s in a single place.
Place
objects have an exit
to the left and an entrance
to the right, which are also places.
Bees travel through a tunnel by moving to a Place
's exit
.
Hive
:
Represents the place where Bee
s start out (on the right of the tunnel).
AntHomeBase
:
Represents the place Ant
s are defending (on the left of the tunnel).
If Bee
s get here, they win :(
Insect
:
A superclass for Ant
and Bee
.
All insects have health
attribute, representing their remaining health, and a place
attribute, representing the Place
where they are currently located.
Each turn, every active Insect
in the game performs its action
.
Ant
:
Represents ants.
Each Ant
subclass has special attributes or a special action that distinguish it from other Ant
types.
For example, a HarvesterAnt
gets food for the colony and a ThrowerAnt
attacks Bees.
Each ant type also has a food_cost
attribute that indicates how much it costs to deploy one unit of that type of ant.
Bee
:
Represents bees.
Each turn, a bee either moves to the exit
of its current Place
if the Place
is not blocked
by an ant, or stings the ant occupying its same Place
.
Tips about VSCode:
We can use OUTLINE in the explorer to view the source code structure conveniently.
Try many useful actions pointed to by the red arrow if we would like to maximize our coding power.