CS 242 Spring 2012 : Assignment 1.3 | charlie on software

CS 242 Spring 2012 : Assignment 1.3

This page last changed on Feb 20, 2012 by cemeyer2.

Feudal … the game of siege and conquest


  • Code Complete Chapter 31: Layout and Style
The readings are due before lecture as usual, on Monday, February 20th.



The code is due at the start of your discussion section, on either 23rd or 24th in Subversion in a folder named Assignment1.3. Please follow these naming conventions exactly.

Rules of the Game

During the Middle Ages, there were two feudal kingdoms which bordered one upon the other. One kingdom was ruled by Ethelred the Great; the other by Aelfric the Barbaric. Raids between the two kingdoms were frequent and often savage. The bloodiest part of each kingdom was the border area which was claimed by both kings. Both had tried unsuccessfully to gain possession of this disputed territory as had their ancestors before them. Many schemes had been tried and had failed.

One day Aelfric decided that the only way to end the dispute was to seize the castle of Ethelred the Great and thus win not only the disputed territory, but also Ethelred’s entire kingdom. He and his son, Prince Alfred, gathered their forces and called upon Duke Athelstan to join them. Athelstan held a castle fief which meant that in order to hold his fief he was obligated to defend the king’s castle and also to help him wage war. With his forces and Duke Athelstan’s help, Aelfric hoped to conquer Ethelred’s kingdom and also to protect his own castle while he was waging war.

About this same time, King Ethelred also came to the conclusion that the only way to gain control of the disputed territory was to conquer the neighboring kingdom. Gathering his forces, he called upon his son, Prince Edgar, and his brother, Duke Ethelbert, to help command them. Leaving some of his men to guard his castle from possible attack, Ethelred set out to wage war against Aelfric the Barbaric. This is the point at which the FEUDAL war begins, with both Kings preparing to invade the neighboring kingdom.

The object of Feudal is to invade and capture the opponent’s Castle or slay his royalty – King, Prince and Duke – while strategically protecting your own Castle and royalty.

For this assignment, you will be implementing the two player version of Feudal, building on your chess solving application. To start, you need to make a board to play on. Here is what the original Feudal board looked like:

Impassable mountains are in dark green and the striped squares indicate rough terrain (which the faster-moving mounted pieces may not cross). Each player receives 2 adjacent quadrants of the board.

A coin is tossed to determine who will position the playing board and who will move first. Player winning the toss will be first to move; player losing the toss positions the board, choosing any two adjacent quarters as his kingdom. After board is positioned, players secretly deploys (positions) their playing pieces in their kingdoms.

Two players use only two of the six sets of playing pieces – one selects a blue set, the other a brown set. After sorting his pieces, each player will have the following:

MOUNTAINS AND ROUGH TERRAIN (solid green and patterned spaces respectively) are restricted areas of play. Before deploying their forces, players should check rules for Mounted Men and Footmen for restrictions regarding positioning
and movement of pieces in these areas.

CASTLE piece may be placed on any terrain, including rough and mountainous areas. Once positioned, the Castle may not be moved. The Castle Green is the only entrance to or exit from the Castle (which you can determine which direction that faces as the castle is 1×2, so long as it is consistent).

MOUNTED MEN (on horses) may not be positioned on, move onto or across mountains or rough terrain; but, they may cross valleys between mountains and/or rough terrain.

FOOTMEN may not be positioned on, move onto or across mountains. They may, however, cross rough terrain and valleys between mountains. Archers and Squires are the only pieces that may not be positioned in (or enter) their own Castles; however, they may be placed or moved onto the Castle Green of either side.

The play begins with the player who won the toss moving first. During his turn, each player may move any or all of his men; at least one man must be moved in each turn. Each piece is allowed only one move per turn and may be moved only as diagrammed below. All men (except Squire) may be moved only over unoccupied spaces; Squire’s move, same as knight in chess, may be over vacant or occupied spaces (but not over Castle piece). When moving to slay an enemy, the attacker (except Archer) must move onto an enemy-occupied space; slain enemy is removed from board and victor occupies the space.

Archers do not “move” to slay; instead, they may shoot (remove) the first man in line of fire up to three spaces away in any direction. They may not shoot over mountains or Castles; however, they may shoot from or across the Castle Green. To cross the Green, or to leave or enter the Castle, a man must stop on the Castle Green and wait till his next turn to leave it. Note that the Squire’s move makes it impossible for him to enter the enemy’s Castle from the Green. The game ends when the opponent’s Castle is captured, or when all of his royalty has been slain. To capture a Castle, the invader must gain entrance through, and stop on the Castle Green. From the Green he may enter the Castle on his next move – and WIN THE GAME!

All moves (except Squire’s) are made over unoccupied spaces. To slay, attacker (except Archer) must end a move on an enemy-occupied space. No man may move onto or across a mountain.

Your Task

For this week, your job is to implement the basic Feudal board game and write a basic solver for it. You need to do the following:

  • Make a board following the rules above. As the most basic, you must implement the original feudal board. If you wish to spice it up, you can create your own custom boards. The board(s) should not be hard-coded in source code, but rather read from some other file format, such as a text file, json file, xml file, yaml file, etc
  • Allow for the user to deploy pieces. Since we are implementing a basic two player version, try to see if you can ensure each player can deploy in secrecy to the best of your ability.
  • Allow for basic game play
    • Start out by implementing the two player version, where two humans are playing against each other. You will need to implement all the pieces with where they can move, etc. Then implement the basic rules for the game as described above.
    • Once that works, move on to a one player version where the human player plays against the computer. Do your best to come up with a solver that will give a reasonably good turn for the computer player each turn. Before game play begins, the computer should position its pieces on its half of the board independent of where the human has placed its pieces if the human player deploys its pieces first. If you can finish it this week, great, otherwise you will need to finish it next week.
  • For this week, you only need to update your GUI interface to play the game, not your console interface


Category Weight Notes
Basic Preparation 3 Ready to go at the start of section
Code Submission 6 Submitted on time and to the correct location in the repository
Decomposition 6  
Documentation 6 Comments for each class and each function listing a brief summary, its parameters, and its return value
Effort 3  
Naming 3  
Overall Design 9 Correct Decomposition of pieces
Participation 6  
Presentation 3  
Requirements Satisfaction 6 Board Implementation
Requirements Satisfaction 9 Start on Single Player Version
Requirements Satisfaction 9 Two Player Version
Testing 9 Unit tests written for all controller code, manual test plan for views

material on this page borrowed from various sources across the interwebs, found using wifis and ethernets, traversing through tubes:

feudalpieces.png (image/png)

feudalboard.gif (image/gif)

valleys.png (image/png)

feudalmoves.png (image/png)
Document generated by Confluence on Mar 29, 2012 02:55

  1. No comments yet.

  1. No trackbacks yet.