Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. # Battleship
  2.  
  3. **Game Overview**
  4.  
  5. Battleship is a game played on a board with n x m holes placed in a grid pattern. Players place model ships of different lengths in the holes in horizonal or vertical orientation. Players take turns guessing grid positions (e.g., 'B8'). If the position is occupied by a ship, that position on the grid is hit. Otherwise, the shot is a miss. Once all of the positions of the ship have been hit, the ship is sunk.
  6.  
  7. **Project Motivation**
  8.  
  9. I'm trying to improve my fundamentals in data structures and procedural decomposition. I thought that this problem represented some fun challenges in both areas.
  10.  
  11. **Code Overview**
  12.  
  13. The game currently has 3 classes - Ocean, Ship and ShipLocation. Currently, it can simulate the basic game action, i.e., striking a location in the Ocean and receiving feedback on whether that strike constitutes a miss, hit or sink(ing) of a Ship.
  14.  
  15. **Next Steps**
  16.  
  17. 1. *Validation and Error handling.* The constructors and methods currently assume good data inputs. E.g., the Ocean constructor assumes that the array of ShipLocations contains valid ShipLocations (non-clashing, fully contained on board), and both strike() methods assume a valid Ocean coordinate and Ship position argument (respectively).
  18.  
  19. 2. *Unit testing.* I'd like to use this project as a chance to practice writing unit tests.
  20.  
  21. 3. *Build game player.* Build a proper interactive 1-player game, where the player can input coordinates and receive feedback (miss, hit, sink, invalid coordinate?).
  22.  
  23. 4. *Randomize ShipLocations.* Currently, the ShipLocations are hard-coded. I would like to randomize these with each new Ocean instantiation. The difficulty here is in making sure the locations 1) keep the ships fully on the board and 2) do not clash with any other ships.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement