User Tools

Site Tools


joust

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
joust [2020/04/10 16:32] frchrisjoust [2020/04/10 17:22] (current) frchris
Line 1: Line 1:
-Joust +====== Joust ====== 
  
 {{::joust1.png?400|}} {{::joust1.png?400|}}
  
-A game I learned about from Berkeley's [[http://gamescrafters.berkeley.edu/games.php?game=joust| Professor Dan Garcia's GamesCrafters Site]] Two knights on a chess board that move like chess, but as they leave a square, it is "burned" (uninhabitable for either player).  Players alternate moving their knight trying to avoid being the loser who is left with no place to go. Download and run  {{ ::joust_sfhs_2020.jar |}} to see a working version of the game.+A game I learned about from Berkeley's [[http://gamescrafters.berkeley.edu/games.php?game=joust| Professor Dan Garcia's GamesCrafters Site]] Two knights on a chess board that move like chess, but as they leave a square, it is "burned" (uninhabitable for either player).  Players alternate moving their knight trying to avoid being the loser who is left with no place to go. This is a real game that has [[http://indigo.ie/~gerryq/Joust/Joustra.htm| strategy]] 
 + 
 +Download and run  {{ ::joust_sfhs_2020.jar |}} to see a working version of the game (On macs you have to go to Security and press "Open anyway" since it is not from an Apple identified developer).
  
-This lab  is set up so you can discover how to program conditional statements (more commonly called "if" statements).  I have some starter code with graphics and fancy things like arrays and loops (something that we will be learning about formally very soon--think of this as an introduction to see how terribly wonderful and useful they can be).  Your job will be to finish writing some vital boolean methods that will make the code work.  +This lab  is set up so you can discover how to program conditional statements(if..then) and iterations (loops).  The starter code has graphics and fancy things like handling input from the mouse.  Your job will be to finish writing some vital boolean methods that will make the code work. Here is zip file {{ ::joust.zip |Joust.zip}} containing the starter source code for four classes.
-!Under the hood +
-# @@Square@@ objects start out either black or white (like chess board) and become red when they are "burned" It draws itself, so it needs to know if it is highlightedWrite the @@isBurned@@ method by checking what the color is+
  
-#Each player has @@Knight@@ (the player's piece) which needs to keep track of its location, what color it is.+====== Under the hood ====== 
 +  - The ''Joust'' class is a control class that handles the user's activity.  If the user is hovering over a valid move, then that particular ''Square'' is told it is highlighted.  If the user clicks on a valid move, then the current ''Knight'' burns the current square, and is moved to the new location. If it is not a game winning move, the current player switches to the other knight. If it is a victory for some one, a reset button is shown to start a new game.  
 +  - ''Square'' objects start out either black or white (like a chess board) and become red when they are "burned" It draws itself, so it needs to know if it is highlighted. Write the ''isBurned'' method by checking what the color is. If you like, you can change the actual Colors used for black, white and burned squares. 
 +  - Each player is ''Knight'' (the player's piece) which needs to keep track of its location, what color it is. If you want to have other pieces, you can see how the knight icon is a unicode character.  You can modify that if you wish with a different one [[https://www.chessvariants.com/d.font/unicode.html]] 
 +  - The game's ''Board'' has a collection of ''Square'' objects and two ''Knight'' objects (one for each player.  It also keeps track of whose turn it is, what are legal moves, and whether the game is over (and who the winner is).  Here you have to write two methods, both involving the possible moves.   
 +      - complete the ''Board'' method ''isLegalMove'' {{::screen_shot_2020-04-10_at_12.39.46_pm.png?400|}} 
 +      - complete the ''Board'' method ''hasMovesLeft''{{::hasMovesLeft.png?400|}} 
 +  - Hints 
 +      - You'll need to use the ''isBurned'' method from the ''Square''class.   
 +      - You also need to look at certain squares.  The knight can either move one over and two across, or two over and one across.   
 +      - You might get ''indexOutOfBounds'' runtime errors if you forget to see if you are looking for a square that is off the board.  Thank goodness Java uses 'short circut' conditional statements.   Good thing, since it would cause a runtime error.  Once the first part of the && is false, that is enough to know the whole expression is false.
  
-#The game's @@Board@@ has a collection of @@Square@@ objects and two @@Knight@@ objects (one for each player.  It also keeps track of whose turn it is, what are legal moves, and whether the game is over (and who the winner is).  Here you have to write two methods, both involving the possible moves.  You'll need to use the @@isAvailable@@ method.  You also need to look at certain squares.  The knight can either move one over and two across, or two over and one across.  You might get @@indexOutOfBounds@@ runtime errors if you forget to see if you are looking for a square that is off the board.  Thank goodness Java uses 'short circut' conditional statements. Consider @@if (c<0 && isAvailable(grid[r][c]) @@ If c is less than 0, it won't go to the isAvailable method.  Good thing, since it would cause a runtime error.  Once the first part of the && is false, that is enough to know the whole expression is false.+====== Now What? ======
  
-#The @@Joust@@ Applet handles the user's activity.  If the user is hovering over a valid move, then that particular @@Square@@ is told it is highlighted.  If the user clicks on a valid move, then the current @@Knight@@ burns the current square, and moved to the new location,If it is not game winning moveand the current player switches +Once you have it going, you can customize it: 
 +  - Change the colors or the appearance of the Knights 
 +  - Make the "Misere" version (where the one who can'move is the winner) 
 +  - Change the size of the board to 5 by 5 board or a rectangular board 
 +  - Make a new project with some of these classes to write a [[https://en.wikipedia.org/wiki/Knight%27s_tour|Knight's tour]] puzzle or [[https://en.wikipedia.org/wiki/Eight_queens_puzzle|8 Queens]] puzzleor for any size board.
  
  
-{{::screen_shot_2020-04-10_at_12.39.46_pm.png?400|}} 
  
-{{ ::joust.zip |Joust.zip}} 
joust.1586550720.txt.gz · Last modified: 2020/04/10 16:32 by frchris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki