- Rust 100%
| src | Idk | |
| .gitignore | Cars now wait for each other (somewhat) | |
| Cargo.lock | Cars now wait for each other (somewhat) | |
| Cargo.toml | Cars now wait for each other (somewhat) | |
| ferrari.png | Initial commit | |
| giveway.png | Give way signs | |
| README.md | Initial commit | |
| sans-bold.ttf | Initial commit | |
| sans.ttf | Initial commit | |
battleship
A networked implementation of the classic boardgame sænke slagskib, I mean battleships. The used protocol over TCP is meant to be completely fair and portable. When preparing a game with your opponent, you will send over a checksum of the ships you placed so that your opponent can confirm they remained in place when the game is over. This checksum also includes a random byte so as to avoid equal layouts to have the same checksum. Additionally, who starts is randomly determined by exchanged random bytes and then biasing them with a random offset based on random bytes sent between the peers.
If you can find a way to cheat without being detected by your opponent, I'd be very interested.
Picture of a late game state where the current player is about to win
How to play
The bot can be run with cargo run --bin bot and either be given a an address and port
to a host (hostname/ip:port) to connect to or if no argument is supplied, it will
host a match and print out the port it is listening on.
The GUI client can be run with cargo run and will show a crude screen
where you can type in an address and port to connect to in the same format and press enter.
If you want to host instead, press Ctrl+H and a host screen will be shown, telling
you what port is being listened on.
When another client has joined the host, the players will have to set up their boats. The bot will do this almost instantaneously and mark itself as ready. To mark yourself as ready in the client, press Ctrl+R (hopefully this ready status will be shown on screen soon). If the boats aren't placed in a legal manner (non-overlapping and in-bounds), you won't be marked as ready.
You drag the ships with left-click to move them and use right-click to rotate them.
When both players are ready, the peers exchange checksums for cheat detection and random bytes to determine who starts. The GUI currently prints out "I start!" if it is the starting player. The bot automatically finds a suitable random place (although trying to finish ships it's recently hit) to shoot, and in the GUI, you press a place you want to shoot on the right-hand grid.
A white circle will appear if you missed and some flames/an explosion appears if you hit. If you hit, you get another go. When a whole ship has been destroyed, it will show on the screen as destroyed. This information is very useful to know not to continue in that direction (although be careful, adjacent ships are currently allowed).
The game goes on until one player has lost all their ships. The GUI prints out to STDOUT whether you've won or lost and likewise the bot announces if it won or not.
If any peer misbehaves in the protocol or is determined a cheater (which can also just mean incorrect implementation), the bot and GUI client will crash nicely with an error. This won't (shouldn't) happen using the bot and GUI client from this repo.
Extra notes
The bot is currently a bit buggy and will sometimes stop finishing a ship it's hit several times when it shouldn't.
The graphics are all also mostly placeholders and old assets I had lying around from when I tried to make this game some ten years ago. Feel free to shine them up :3 I also have the destroyed sprites of a pirate theme for the ships but I have sadly lost the non-destroyed ships.
Thanks for playing
Thank you for your interest and I hope you have a little fun :)