gasilwhole.blogg.se

Coordinate grid games battleship online
Coordinate grid games battleship online










This is because, in the final part of this series, we're going to run a bunch of games to see if this system gives any inherent bias to one of the Player objects. The Player class also has a ton of methods which we define in Part 3. I've taken to calling this space a Panel. The next object we need represents a single space on the game boards.

coordinate grid games battleship online

#Coordinate grid games battleship online how to

We'll see a lot of those characters when we show how to play a game in the next part of this series. The Description attribute records the display character used for each of these statuses. To represent all of these statuses, I created an enumeration called OccupationType: public enum OccupationType If there's nothing on that panel, the panel is said to be empty.If a shot was fired at that panel, then either a hit or a miss was recorded on that panel.If a ship is on the panel, then the panel is occupied.OccupationTypeįor any given panel, there a few possibilities as to what can be on that panel: Here, we'll be using integers, as it makes several calculations easier). (NOTE: In the game, rows are given letter designations, e.g. This is because whenever a shot is fired, the person firing the shot does so by calling out coordinates, and so this class will not only represent coordinates on the game and firing boards, but also coordinates that are under attack. the Panel model that we're about to define. You might be wondering why those properties Row and Column are not a part of a different model, e.g.

coordinate grid games battleship online

The first and most basic object we are going to model is the Coordinates object, which represents a location on a board that can be fired at. With those in place, we can begin modeling the game. In the first part of this series we discussed how to play a game of Battleship and what kinds of components and strategies we would need to use. Also, check out my other posts in the Modeling Practice series! You might want to use the sample project over on GitHub to follow along with this post. NOTE: This is Part 2 of a three-part series demonstrating how we might model the classic game Battleship as a C# program.










Coordinate grid games battleship online