{"id":26708496,"url":"https://github.com/triformine/battleship","last_synced_at":"2025-10-09T10:34:26.796Z","repository":{"id":64373183,"uuid":"574531150","full_name":"TriForMine/battleship","owner":"TriForMine","description":"This is a variation of the classic battleship game where you can move your ships and when you miss a ship, a mine is placed on the board.","archived":false,"fork":false,"pushed_at":"2025-04-08T02:12:56.000Z","size":280,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T16:45:32.669Z","etag":null,"topics":["ai","ansi-c","battleship-game","board-game","c","game","multiplayer","multithreading","rust-lang"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TriForMine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"triformine","patreon":"isekaimaid","ko_fi":"isekaimaid"}},"created_at":"2022-12-05T14:13:32.000Z","updated_at":"2025-02-27T17:43:06.000Z","dependencies_parsed_at":"2025-02-27T18:48:36.233Z","dependency_job_id":"48b369e2-3437-4ade-a414-c26170c8e5b5","html_url":"https://github.com/TriForMine/battleship","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/TriForMine/battleship","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TriForMine%2Fbattleship","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TriForMine%2Fbattleship/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TriForMine%2Fbattleship/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TriForMine%2Fbattleship/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TriForMine","download_url":"https://codeload.github.com/TriForMine/battleship/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TriForMine%2Fbattleship/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001267,"owners_count":26083040,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","ansi-c","battleship-game","board-game","c","game","multiplayer","multithreading","rust-lang"],"created_at":"2025-03-27T07:18:44.244Z","updated_at":"2025-10-09T10:34:26.769Z","avatar_url":"https://github.com/TriForMine.png","language":"C","funding_links":["https://github.com/sponsors/triformine","https://patreon.com/isekaimaid","https://ko-fi.com/isekaimaid"],"categories":[],"sub_categories":[],"readme":"# Battleship Game in C\n\n\u003cimg align=\"right\" src=\"https://i.imgur.com/5ENqoMn.png\" height=\"150px\"\u003e\n\nWelcome to the Battleship Game in C! In this version of the classic battleship game, players take turns guessing the\nlocation of each other's ships on a grid. When a player misses a ship, a mine is placed on the board. The game ends when\nall of one player's ships have been sunk. Players can move their ships and attack their opponent's ships on each turn.\nThe game also includes three types of AI that players can compete against.\n\nIn addition, the game now features online multiplayer, using a game server written in Rust. The server only handles turn-by-turn broadcast of actions to the other player, and does not check for cheats or incorrect commands.\n\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/TriForMine/battleship)\n![GitHub](https://img.shields.io/github/license/TriForMine/battleship)\n![GitHub last commit](https://img.shields.io/github/last-commit/TriForMine/battleship) \u003cbr/\u003e\n[![test](https://github.com/TriForMine/battleship/actions/workflows/test.yml/badge.svg)](https://github.com/TriForMine/battleship/actions/workflows/test.yml)\n[![pre-release](https://github.com/TriForMine/battleship/actions/workflows/pre-release.yml/badge.svg)](https://github.com/TriForMine/battleship/actions/workflows/pre-release.yml)\n[![DeepSource](https://deepsource.io/gh/TriForMine/battleship.svg/?label=active+issues\u0026show_trend=true\u0026token=46Xb9KY7rG195b7ilvE_jl6i)](https://deepsource.io/gh/TriForMine/battleship/?ref=repository-badge)\n\n## Gameplay\n\nIn Battleship, players take turns guessing the location of each other's ships on a grid. The size of the grid can be\ncustomized at the start of the game.\n\nEach player places their ships on the board and then takes turns guessing the location of the opponent's ships. If a\nplayer hits a ship, the turn ends and the opponent gets to go. If a player misses a ship, a mine is placed on the board.\nIf a player hits a mine, the turn ends and the opponent gets to go.\n\nThe game ends when all of one player's ships have been sunk. On each turn, a player can either move one of their ships\nor attack an opponent's ship. If two ships collide on the same space, both ships will be damaged and their movements\nwill be cancelled. If a ship moves onto a mine, it will be damaged. The game ends when one player has no ships left.\n\n## Rules\n\n- Players take turns playing the game.\n- If a player misses a shot, they will place a mine on the board.\n- If a ship moves onto a mine, it will be damaged.\n- If two ships collide on the same space, both ships will be damaged and their movements will be cancelled.\n- On each turn, a player can either move one of their ships or attack an opponent's ship.\n- The game ends when one player has no ships left.\n\n## AI\n\nThe game includes 3 types of AI:\n\n### Random AI\n\nThis AI fires at random coordinates each turn.\n\n### Hunt and Target\n\nThis AI fires in a grid form, and when there is a hit, fires on the adjacent cell until the ship is sunk.\n\n### Probability Targeting\n\nThis AI calculates at every turn where the highest probability for a ship to be is, and fires at that point. When in\nhunting mode, it will calculate all the possibilities for the hit ship to be placed and eliminate it quickly. This AI is\nthe most difficult to beat.\n\n## Installation\n\nTo install and run the game, you have two options:\n\n1. Clone the repository to your local machine and compile the source code using the Makefile.\n2. Download a release from the [releases page](https://github.com/TriForMine/battleship/releases) and run the game.\n\n### Option 1: Install using the Makefile\n\n1. Clone the repository to your local machine:\n\n```sh\ngit clone https://github.com/TriForMine/battleship.git\n```\n\n2. Navigate to the directory where you cloned the repository:\n\n```sh\ncd battleship\n```\n\n3. Compile the source code using the Makefile:\n\n```sh\nmake release\n```\n\nTo build the game with the debug mode, use `make debug` instead. This will show a map of the probabilities for the\nprobability targeting mode.\n\n4. Run the game:\n\n- Interactive Mode\n```sh\n./build/battleship -i\n```\n\n- STDIN Format\n```sh\ncat test/format0.txt | ./build/battleship\n```\n\n- File Argument\n```sh\n./build/battleship -f test/format0.txt\n```\n\n### Option 2: Install using CMake and Ninja\n\n1. Clone the repository to your local machine:\n\n```sh\ngit clone https://github.com/TriForMine/battleship.git\n```\n\n2. Navigate to the directory where you cloned the repository:\n\n```sh\ncd battleship\n```\n\n3. Compile the source code using CMake and Ninja:\n\n```sh\ncmake -G Ninja -DCMAKE_BUILD_TYPE=Release -S . -B build\ncmake --build build\n```\n\nTo build the game with the debug mode, use `cmake -DDEBUG=1 -G Ninja -DCMAKE_BUILD_TYPE=Release -S . -B build` instead.\nThis will show a map of the probabilities for the probability targeting AI.\n\n4. Run the game:\n\n- Interactive Mode\n```sh\n./build/battleship -i\n```\n\n- STDIN Format\n```sh\ncat test/format0.txt | ./build/battleship\n```\n\n- File Argument\n```sh\n./build/battleship -f test/format0.txt\n```\n\n## Server\nTo build and run the server for the Battleship game, you have several options:\n\n1. **Using Makefile:** You can use the command `make server` in the root directory of the project to build the server.\nOnce the build is complete, you can run the server using `./build/server`\n\n2. **Downloading from GitHub Releases:** You can download a pre-built binary of the server from the [GitHub releases page](https://github.com/TriForMine/battleship/releases) and run it on your machine.\n\n3. **Building from source with Cargo:** To build the server from source, navigate to the `server` directory and run `cargo build --release`. This will build the server in release mode and you can find the binary in the `target/release` folder. You can run the server by executing `./target/release/server`.\n\n**NOTE:** Make sure you have rust and cargo installed before trying to build the server with cargo or the Makefile, otherwise the command will not work.\n\n## Contributions\n\nWe welcome contributions to the project! If you would like to contribute, please follow these steps:\n\n1. Read the [CONTRIBUTING.md](CONTRIBUTING.md) file for guidelines on contributing to the project.\n2. Fork the repository.\n3. Create a new branch for your changes.\n4. Make your changes.\n5. Commit your changes and push them to your fork.\n6. Create a pull request to merge your changes into the main branch.\n\nWe will review your pull request and provide feedback as needed. Thank you for considering contributing to the project!\n\n## License\n\nThis project is licensed under the Apache-2.0 license. See the [LICENSE](LICENSE) file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftriformine%2Fbattleship","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftriformine%2Fbattleship","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftriformine%2Fbattleship/lists"}