Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

22 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

BattleShip

Battle-Ship Game applying some Software Patterns. Battle-Ship is a game composed by two boards with a set of positions and every position has specific coordinates in the board. Each player has a set of ships conformed by 1 Air Craft, 1 Submarine, 1 Destroyers, 1 Cruisers, 1 Boats. The ships are located randomly in the board of each player occupying specific positions depending on the size of each ships. Once the ships are located, one player specified a set of coordinates related with positions in the board of its opponent in order to attack its ships. The first player who destroy all the ships of its opponent is the winner. The patterns used in this simple approach were:

Template: Every turn requires a series of steps, most of those steps are equal even if are executed by human-player or pc-player. Some specific steps requires specific implementation for human-player or pc-player due to their behaviour. For example, 'make an attack' is a step that pc-player executed based on one strategy, but the human-player executed via pressing one slot in the GUI grid. The idea to implement this pattern is to set and control the steps related with 'take a turn', make the steps common in one specific place and each player implements specific steps depend on its behaviour.

Strategy: The pc-player has to make an attack in the human-player board. It is possible to executed that attack in different ways: Randomly or Systematically. The first option is Randomly, so the pc-player create a shoot randomly and this shoot take the state of Successful or Missed. In the next turn of the pc-player, if the previous turn has the state of Successful, the pc-player change the strategy to Systematically in order to create the following shoots near the position of the previous shoot. It is possible to create possible shoots in Horizontal, Vertical or Diagonal direction. This change of behaviour is carry on runtime depending on the previous shoots executed by the pc-player.

Observer: The Ship has state, the state is basically OK, Attacked and Destroyed. This State is updated with every shot that the ship received. When the State is updated in the Ship, the GUI have to update the information that display about the ship in order to inform to the player which kind of ship has been attacked and how many ships remain in the opponent board. The observer pattern is useful to update information in the GUI based on the different states of the Ships.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages