Skip to content

joseairosa/Battleship

Repository files navigation

Battleship Game

Bakckend: PHP
Frontend: HTML, CSS and JavaScript
Pre-made Code: For this project HTML5 Boilerplate was used as well as some base classes (Debug and ObjectAbstract) that are abstracted from the main concept of this solution and therefore used as support.

The base concept is simple, deploy the Battleship game recurring to recent technologies with some basic rules.

======

RULES

* Each player gets their own board which is a grid of 10×10 spaces.
* 5 ships get placed on the board and take up a number of spaces on the grid in a straight line in any orientation (only one ship can occupy any given square): Aircraft-Carrier (5 spaces) Battleship (4 spaces) Destroyer (3 spaces) Submarine (3 spaces) * Patrol Boat (2 space)
* A player’s board is not visible to their opponent.
* Gameplay happens in rounds, each player taking turns attacking the other.
* A player’s turn consists of announcing a space on their opponent’s board to attack.
* If their opponent has a ship occupying that space, then that ship takes a point of damage in that space.
* When all the spaces occupied by a ship has been hit, it is considered sunk.
* The first player to have all their ships sunk loses the game.

======

FEATURES

* This game is played between human and computer.
* The computer player must place their own ships on the board.
* You may decide whether you’ll allow the human player to place their own ships or use the same algorithm as above to place them automatically.
* The computer’s attack pattern can be, and should probably start as, a random one, with the potential for making it more advanced later.
* Human players can view two boards, the first one with their ships and status, the second with the the result of their attacks on their computer opponent.

======

IMPROVEMENTS

* The initial AI attack algorithm will only attempt to do 1 inteligent attack after it notices that it hit a ship. It should, with more code, attack until it hits again.
* Report which ship you have just sunk

======

KNOWN BUGS

* Sometimes opening the page and the random placing algorythm will enter a deadlock, if this happens refresh the page

======

HOW TO PLAY

* Place your own ships or click place randomly to start your board
* Click "Start Game" or "Start 3 Turn Game Mode" to start the game
* Click on the squares on the right board to attack your opponent. If it's blue you've hit water, if it's red you've hit a part of a ship.
* If you're playing 3 Turn Game Mode you must place 3 attacks before you actually attack your opponent.

======

Examples

Soon...

About

Battleship Game developed in PHP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published