Question: use ATELIER B . . . GIVE THE WHOLE CODE WITHOUT MISTAKES ( attached here is a code for ur reference use it when forming
use ATELIER BGIVE THE WHOLE CODE WITHOUT MISTAKES attached here is a code for ur reference use it when forming the GRID and where necessary the coding practice shud follow the given example the project shud run in atelier B and pro b and give the working code
ps plz check the SETS specially
code shud compulsorily have these code lines,
report deployFleetplayerpositions
report playerShootstarget
shipsquares shipLocationsplayer
shipCounts shipsLeft
shotCount shotsTakenplayer
report gameStatus
This system is to be developed using the B tools Atelier B and ProB.
A grid size of x squares, with the grid square representing the square at column & row
Each player has warships in their fleet.
Each warship occupies a single grid square on the grid.
The warships must be on different grid squares, ie at most warship per square.
The game starts by each player placing their ships on their own grid, each player's ships in different grid squares.
Player has the first turn.
Player shoots at Player s ships, by selecting a target square on Player s grid. If there is a ship in the target square it is a hit and the ship is deleted from Player s fleet, otherwise it is a miss and there is no change to Player s fleet.
It is then Player s turn.
Player shoots at Player s ships, by selecting a target square on Player s grid. Registering a hit or miss, as above.
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.
example code.....
MACHINE
NoughtsCrosses
SETS
Players Noughts Crosses;
Results Success Failure
CONSTANTS
Grid, winningSubsets
PROPERTIES
Grid &
winningSubsets : POWGrid &
winningSubsets
id
VARIABLES
noughts, crosses
INVARIANT
noughts : Grid & crosses : Grid & noughts crosses
INITIALISATION
noughts : crosses :
OPERATIONS
res placeNoughtpp
PRE
pp : Grid
THEN
IF
pp : noughts crosses
THEN
res : Failure
ELSE
noughts : noughts pp
res : Success
END
END;
res placeCrosspp
PRE
pp : Grid
THEN
IF
pp : noughts crosses
THEN
res : Failure
ELSE
crosses : crosses pp
res : Success
END
END
END
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
