Skip to content

Instantly share code, notes, and snippets.

@jesseract
Last active August 29, 2015 14:13
Show Gist options
  • Save jesseract/0d643211ed64274d3a35 to your computer and use it in GitHub Desktop.
Save jesseract/0d643211ed64274d3a35 to your computer and use it in GitHub Desktop.

#How to play Battleship ##Setup Instructions

  • Take game out of box
  • Open your game unit
  • each player receives five ships
    • destroyer has 2 hit points
    • submarine has 3 hit points
    • cruiser has 3 hit points
    • battleships has 4 hit points
    • carrier has 5 hit points
  • Place your five ships on the ocean grid
    • Fit anchoring pegs into holes of grid
      1. is ship_position horizontal = true
      2. is ship_position vertical = true
      3. is ship_position diagonal = false
      4. does ship_position overlap letters, numbers, edge or another ship = false
      5. ship_position does not change
  • Determine who will go first
    • player_1 = attacking_player
    • player_2 = defending_player
  • victorious_player = nil

##Gameplay

  • while victorious_player = nil
    1. attacking_player chooses location on defending_player’s grid
    2. location = [grid points]
    3. defending_player determines if one of his ships is at that point in the grid
    4. if ship is on point
      • identify type of ship
      • identify number of hit points for ship
      • then defending_player places red peg into point on ocean grid
      • defending_player tells attacking_player ship is hit
      • attacking_player places red peg into target grid
      • if hit_count == peg_number of hit ship then sunk_ship = true
        • puts "You sunk my ship!"
        • identify number of live ships
        • if live_ships = 0 then attacking_player wins because defending_player has no more ships victorious_player = attacking_player victorious_player.gloat end end
    • else 2. defending_player tells attacking_player they missed
      • attacking_player places white peg into target grid
    • end
    • attacking and defending player swap
  • end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment