BATTLESHIP WITH HTML?CSS?JAVASCRIPT - STILL NOT WORKING
This commit is contained in:
parent
fcd815004c
commit
ebab446f47
52
README.md
52
README.md
|
|
@ -22,7 +22,55 @@ You lose if:
|
||||||
* Your code raises an exception.
|
* Your code raises an exception.
|
||||||
* All your ships have been sunk.
|
* All your ships have been sunk.
|
||||||
|
|
||||||
|
TECHNOLOGIES
|
||||||
How To Play
|
|
||||||
--------------
|
--------------
|
||||||
|
* HTML
|
||||||
|
* Javascript
|
||||||
|
* CSS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
HOW TO PLAY
|
||||||
|
--------------
|
||||||
|
|
||||||
Will Add soon
|
Will Add soon
|
||||||
|
|
||||||
|
`state` is a representation of the known state of the opponent’s fleet, as
|
||||||
|
modified by the player’s shots. It is given as an array of arrays; the inner
|
||||||
|
arrays represent horizontal rows. Each cell may be in one of three states:
|
||||||
|
`:unknown`, `:hit`, or `:miss`. E.g.
|
||||||
|
|
||||||
|
[[:hit, :miss, :unknown, ...], [:unknown, :unknown, :unknown, ...], ...]
|
||||||
|
# 0,0 1,0 2,0 0,1 1,1 2,1
|
||||||
|
|
||||||
|
`ships_remaining` is an array of the ships remaining on the opponent's board,
|
||||||
|
given as an array of numbers representing their lengths, longest first.
|
||||||
|
For example, the first two calls will always be:
|
||||||
|
|
||||||
|
[5, 4, 3, 3, 2]
|
||||||
|
|
||||||
|
If the player is lucky enough to take out the length 2 ship on their first two
|
||||||
|
turns, the third turn will be called with:
|
||||||
|
|
||||||
|
[5, 4, 3, 3]
|
||||||
|
|
||||||
|
and so on.
|
||||||
|
|
||||||
|
`take_turn` must return an array of co-ordinates for the next shot. In the
|
||||||
|
example above, we can see that the player has already played `[0,0]`, yielding
|
||||||
|
a hit, and `[1,0]`, giving a miss. They can now return a reasonable guess of
|
||||||
|
`[0,1]` for their next shot.
|
||||||
|
|
||||||
|
The console runner
|
||||||
|
------------------
|
||||||
|
|
||||||
|
A console runner is provided. It can be started using:
|
||||||
|
|
||||||
|
bundle exec bin/play path/to/player_a.rb path/to/player_b.rb
|
||||||
|
|
||||||
|
Players are isolated using DRb.
|
||||||
|
|
||||||
|
A couple of very basic players are supplied: `NaivePlayer` and
|
||||||
|
`AnotherNaivePlayer` put all their ships in a corner and guess at random (often
|
||||||
|
wasting turns by repeating themselves). `HumanPlayer` asks for input via the
|
||||||
|
console.
|
||||||
|
|
|
||||||
20
index.html
20
index.html
|
|
@ -74,16 +74,16 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="headers">A</th>
|
<th class="headers">A</th>
|
||||||
<td class="player-cell" id="00"></td>
|
<td class="player-cell" id="100"></td>
|
||||||
<td class="player-cell" id="01"></td>
|
<td class="player-cell" id="101"></td>
|
||||||
<td class="player-cell" id="02"></td>
|
<td class="player-cell" id="102"></td>
|
||||||
<td class="player-cell" id="03"></td>
|
<td class="player-cell" id="103"></td>
|
||||||
<td class="player-cell" id="04"></td>
|
<td class="player-cell" id="104"></td>
|
||||||
<td class="player-cell" id="05"></td>
|
<td class="player-cell" id="105"></td>
|
||||||
<td class="player-cell" id="06"></td>
|
<td class="player-cell" id="106"></td>
|
||||||
<td class="player-cell" id="07"></td>
|
<td class="player-cell" id="107"></td>
|
||||||
<td class="player-cell" id="08"></td>
|
<td class="player-cell" id="108"></td>
|
||||||
<td class="player-cell" id="09"></td>
|
<td class="player-cell" id="109"></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user