Design, implement, and test the game engine for a Java application to play the board game Igel Ärgern (commonly translated as "Hedgehogs in a Hurry").
Rules are very easy to find on the web (begin by reading this document as well as others at boardgamegeek.com); and we will demonstrate the game in class. Therefore, we provide only a very brief overview here:
The standard game is played on a grid with 6 rows and 9 columns. Each player has four tokens (representing hedgehogs) that he or she must move from the left column to the right column. Hedgehogs sharing a square stack on top of each other. Only the hedgehog on the top of a stack may move.
On his turn a player:
The game is interesting because:
This document contains a long list of variants. You will be required to implement some of them.
This jar file contains an example completed project. Use it to learn how to play
the game. To run the demo, download the jar file,
java -jar igelArgern.jar from the command line.
IIgelGameinterface. In addition, your model must implement this constructor
IgelGameParameters.obstacleTypespecifies the the type for all obstacles for this game. Please make sure your model recognizes the strings "ConcreteBlock" and "DeepPit". You may also have it recognize other strings if you prefer.
igelArgern.jarand import it into your project.
modelpackage that implements both
modelpackage that implements
MyIgelArgern, you should see a configuration dialog box appear. If you press the start button, the program will crash. This is because many methods in your model are returning
null. When you implement enough of your model to have removed all the default
return null;statements, you should be able to see the GUI.
If you look at the
you will see it contains a
GameEventListener. This interface allows the model to report events back to the presenter.
Your model must support a
GameEventListener. The presenter (which we provide) is
responsible for implementing a
GameEventListener object and passing it to the model using the method
addGameEventListener. Your model is responsible for calling methods on the
GameEventListener object at the apporpriate times. For example,
your model must call the
roll method whenever the die value changes.
Because the model uses a listener, the presenter does not have to "poll" the model for events. For example,
if there was no
GameEventListener, then the presenter would have to call
after every method call.
IgelViewKurmas uses objects called Artists to draw each cell. The provided GUI comes
Artists to draw Deep Pits and Concrete Blocks. In some cases,
you may be able to re-use or subclass these artists for your own obstacles. Read these instructions if you decide
you want your new obstacles to have a different
Artist is simply an object that
draw method. The
ICellState tells the view which artist to use. The
takes an optional
Map<String, Artist> parameter maps the strings returned
ICellState.type() to the
Artist object used to render the cell. Notice that all cells
of a given type share the same
Artist object. This means that the
Artist shouldn't store
any state. The view of any given cell should be determined solely by it's state (i.e.,
To add another obstacle type, do the following:
Artist. This step is optional because one of the existing Artists may work for the new obstacle type. For example, if the new obstacle doesn't allow hedgehogs inside, then you can simply use the existing
IgelViewKurmas.defaultArtistMap()to obtain the default map.
Map<String, Artist> artistMap = IgelViewKurmas.defaultArtistMap(); artistMap.put("FinishCell", new SmileyArtist()); // Create a view configured for the specified game. final IIgelView view = new IgelViewKurmas(model.getState(), artistMap);
IgelViewKurmas comes with the following artists: "Cell Type" is the string that is mapped to that
||"Cell"||Draws a "regular" cell: A cell containing a stack of hedgehogs.|
||"FinishCell"||Draws the cells in the rightmost column (i.e., the "finish" column). Works just like a
||"DeepPit"||Draws "deep pit" obstacles. These cells can contain a stack of hedgehogs. The artist draws a "regular" cell with a black background and a red border.|
||"ConcreteBlock"||Simply draws a solid black rectangle.|
ICellStateobject correctly implements the
type()method. Unless you have added your own
Artists or artist map, the
typemethod should return only those values listed in the "Cell Type" column of this table.
You must demonstrate your program. It is your responsibility to find a time for the demonstration. Programs that are not personally demonstrated may not be graded.
igelArgern.jar: All necessary demo and support code.
Artists or do other, optional fancy stuff.