The file ant.py
is incomplete (to prevent from plagiarism). If you would like a completed version, please email me at me@timkchan.com
In this project, we will create a tower defense game called Ants Vs. SomeBees. As the ant queen, we populate our colony with the bravest ants we can muster. Our ants must protect our queen from the evil bees that invade your territory. Irritate the bees enough by throwing leaves at them, and they will be vanquished. Fail to pester the airborne intruders adequately, and our queen will succumb to the bees' wrath. This game is inspired by PopCap Games' Plants Vs. Zombies.
A game of Ants Vs. SomeBees consists of a series of turns. In each turn, new bees may enter the ant colony. Then, new ants are placed. Finally, all insects (ants, then bees) take individual actions: bees sting ants, and ants throw leaves at bees. The game ends either when a bee reaches the ant queen (we lose), or the entire bee flotilla has been vanquished (we win).
- The Colony: The colony consists of several places that are chained together. The
exit
of eachPlace
leads to anotherPlace
. - Placing Ants: There are two constraints that limit ant production. Placing an ant uses up some amount of the colony's food, a different amount for each type of ant. Also, only one ant can occupy each
Place
. - Bees: When it is time to act, a bee either moves to the
exit
of its currentPlace
if no ant blocks its path, or stings an ant that blocks its path. - Ants: Each type of ant takes a different action and requires a different amount of food to place. The two most basic ant types are the
HarvesterAnt
, which adds one food to the colony during each turn, and theThrowerAnt
, which throws a leaf at a bee each turn.
Files in this project:
ants.py
: The game logic of Ants Vs. SomeBeesants_gui.py
: An older GUI for Ants Vs. SomeBeesgui.py
: An new GUI for Ants Vs. SomeBeesgraphics.py
: Utilities for displaying simple two-dimensional animationsstate.py
: Abstraction for gamestate forgui.py
utils.py
: Some functions to facilitate the game interfaceucb.py
: Utility functions for CS 61Aassets
: A directory of images and files used bygui.py
img
: A directory of images used byants_gui.py
icon8080
: A directory of images used byREADME.md
There are 3 ways to run the game:
-
text-based
$ python3 ants.py
-
Python GUI
$ python3 ants_gui.py
-
Web-based GUI (recommended)
$ python3 gui.py
All the methods above follow the same arguments:
usage: gui.py [-h] [-d DIFFICULTY] [-w] [--food FOOD]
Play Ants vs. SomeBees
optional arguments:
-h, --help show this help message and exit
-d DIFFICULTY sets difficulty of game (easy/medium/hard/insane)
-w, --water loads a full layout with water
--food FOOD number of food to start with when testing
e.g.
$ python3 gui.py -d hard -w