Author: Richard Higgins
This project was from my highschool computer science class in the year 2008.
This project implements Gridworld to create a medieval era environment. The landscape includes classes such as Fighter, Archer, FootSoldier, Horseman, and Fortress. Each class is represented by a unique image and possesses distinct movement and combat behaviors. In this architecture, FootSoldier and Horseman extend Bug, whereas Archer and Fortress extend Critter.
- First
git clone https://github.com/parkr/GridWorld(thanks parkr) - Then
java -cp .:GridWorld/gridworld.jar GridGenerator.java
Here is a starting grid, you can see some castles have been randomly placed in the gridworld:
Here is after a few steps of operations, where castles have spawned some units.
Here is as the empires spawn peasants and those peasants build more castles of their own type.
Here is in the middle of combat, you can see some empires have been destroyed.
Here is after many rounds, where only a few empires remain.
- Overarching class with a basic implementation, originally defined as an object originating from a Fortress.
- NOTE: Now Defunct.
- Basic soldier.
- Extends:
Bug - Spawning: Most common spawn of a Fortress.
- Movement: One movement per turn.
- Attack: Fires in a straight line.
- Behavior: Mimics a Spiral Bug by attacking outwards from the fortress in a spiral
(or, similarly, a Rockhound). - Customization: Modified implementations for
act(),canMove(), andmove()compared to a standardBug.
- More complicated soldier.
- Extends:
Critter - Spawning: Third most common spawn of a Fortress.
- Movement: One movement per turn.
- Strategy: Analyzes nearby locations before executing a random movement and attack.
- Attack Chance: 1/8 chance of attacking (resulting in approximately one attack per turn given 8 potential targets).
- Attack Method: Attacks neighboring locations.
- Customization: Modified implementations for
processActors()andact()compared to a standardCritter.
- An enhanced version of the FootSoldier.
- Extends:
Bug - Spawning: Second most common spawn of a Fortress.
- Movement: Two spaces per turn.
- Attack: Fires in a straight line.
- Behavior: Mimics a Spiral Bug by attacking outwards from the fortress in a spiral
(or, similarly, a Rockhound). - Customization: Modified implementations for
act(),canMove(), andmove()compared to a standardBug.
- Acts as a spawning point and serves as the general locus of a color empire.
- Extends:
Critter- Primarily extends
Critterto utilize its spawning capabilities. - Movement is similar to a rock (i.e., essentially stationary).
- Primarily extends
- Spawning Behavior: Randomly places soldiers around itself using the
getMoveLocations()array. - Note: Does not move or attack.
- Customization: Modified
act()method to serve its role as a spawn point.
- Basic builder unit.
- Extends:
Bug - Spawning: Fourth most common spawn from a Fortress.
- Movement: One movement per turn.
- Attack: Does not attack.
- Special Ability: Has a chance (currently 1/30) of creating a new Fortress at its current location.
- Behavior: Mimics a Spiral Bug by moving outwards from the fortress in a spiral
(or, similarly, a Rockhound). - Customization: Modified implementations for
act()andmove()compared to a standardBug.
- Horseman:
Moves similarly to a Spiral Bug but covers two locations per act. - FootSoldier:
Moves similarly to a Spiral Bug but only covers one location per act. - Archer:
Behaves like aCritterbut only has a 1 in 8 chance of killing a neighboring creature. - Fortress:
Functions as a spawn point. By leveraging itsCrittermethods, it randomly produces either an Archer, FootSoldier, or Horseman in an adjacent location.
All objects maintain the same color as the Fortress; as a result, entities sharing the same color do not attack one another.
- GridGenerator Class:
- Generates a grid based on user-defined proportions.
- Can randomly populate the grid with objects (for example, a 1 in 10 chance of placing a
Bugin each square).
- Gridworld Provided Classes
Friday, May 9, 2008
- Acquired images for the following classes:
Fighter,FootSoldier,Horseman,Archer, andFortress. - Began coding on the above classes.
- Completed a large section of coding; faced challenges with determining friend vs. foe based on color.
Tuesday, May 13, 2008
- The
Fighterclass became defunct and was merged withFootSoldier. - Added the
Peasentclass, which has a 1/30 chance of spawning a new Fortress and does not attack. - Acquired an image for the
Peasentclass. - Tweaked the spawning ratios for the
Fortressclass. - Resolved an
ArrayIndexOutOfBoundsexception that occurred when aFortresshad no empty adjacent locations for spawning.





