Question: use ATELIER B . . . GIVE THE WHOLE CODE WITHOUT MISTAKES PLZZZ code shud compulsorily have these code lines, report - - deployFleet (

use ATELIER B...GIVE THE WHOLE CODE WITHOUT MISTAKES PLZZZ
code shud compulsorily have these code lines,
report -- deployFleet(player, positions)
report -- playerShoots(target)
shipsquares -- shipLocations(player)
shipCounts -- shipsLeft
shotCount -- shotsTaken(player)
report -- gameStatus
**plz attach the whole workable code (no need explanations)
This coursework requires you to develop a B specification of a version of the Battleships board game. This system is to be developed using the B tools Atelier B and ProB. Battleships is a strategy type guessing game for two players. It is played using two 10 x 10 grids, one for each player. The game starts by each player placing the warships of their fleet on squares in their own grid. The locations of the fleets are concealed from the other player. Players take alternate turns "shooting" at the other player's ships in an attempt to sink them. The aim of the game is to win by destroying your opponent's fleet of ships before they destroy yours.
1.1 The Battleships Game Constraints and Requirements
For the purposes of this coursework, the Battleships game used is a simplified version of the normal game:
A grid size of 10 x 10 squares, with the grid square (6,8) representing the square at column 6 & row 8.
Each player has 3 warships in their fleet.
Each warship occupies a single grid square on the grid.
The warships must be on different grid squares, i.e. at most 1 warship per square.
1.2 Playing the Battleships Game
The Battleships game is played as follows:
1. The game starts by each player placing their 3 ships on their own grid, each player's ships in different grid squares.
2. Player 1 has the first turn.
3. Player 1 shoots at Player 2's ships, by selecting a target square on Player 2's grid. If there is a ship in the target square it is a hit and the ship is deleted from Player 2's fleet, otherwise it is a miss and there is no change to Player 2's fleet.
4. It is then Player 2's turn.
5. Player 2 shoots at Player 1's ships, by selecting a target square on Player 1's grid. Registering a hit or miss, as above.
6. The players continue to take turns until all of one player's ships have been sunk, at this point the other player is the winner.
2. The Battleships Game B Specification
2.1 Specification Components
Your B specification should include the following elements.
(a) Sets and Constants
Any sets and constants that are required to define the data and state of the Battleships game system, and their properties. Includes at least the set of players, dimensions of their grids, and number of battleships.
(b) System State
The state variables required to represent the data for the Battleships game system. Including the state invariant and initialisation. Includes at least both players grids, the current game state (for example, it could be ongoing, won by either player, or one or both players may still need to deploy their fleet), and whose turn it is. Check the operations to figure out what other information is needed.
(c) Operations
The Battleships game operations are:
report -- deployFleet(player, positions)
The specified player places their 3 ships at the given positions on their own grid. If the ships are all placed in valid grid positions, then the operation reports success, otherwise it reports an error message indicating what the error was.
report -- playerShoots(target)
The player whose turn it is shoots at the target square on the other player's grid. If it contains a ship, then this ship is deleted, and the operation reports a hit. If this was their last ship the game is over, and the current player wins the game; otherwise, it is the other players turn. If there is no ship in the target square the operation reports a miss. If the target square is not in the grid, it reports an error message.
For each operation make sure to use suitable preconditions (e.g. players should not start shooting before both fleets have been deployed).
(d) Enquiry Operations
You must also specify the following enquiry operations, that all output information about the state of the game:
shipsquares -- shipLocations(player)
Outputs the location of all the ships left in the player's fleet.
shipCounts -- shipsLeft
Outputs the numbers of ships left in both players fleets.
shotCount -- shotsTaken(player)
Outputs the number of shots taken by the player.
report -- gameStatus
Gives information about the games state (e.g. ongoing, player 1 win, both players still need to deploy, etc)
2.2 General Requirements
The B specification should use the appropriate features to define the data & operations in any machines that you define. The overall structure of the B specification should be
A single B machine that contains all the state information and operations, etc.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!