{"id":14957370,"url":"https://github.com/mano-08/battleship","last_synced_at":"2026-02-15T22:06:29.805Z","repository":{"id":243987682,"uuid":"811302902","full_name":"Mano-08/battleship","owner":"Mano-08","description":"Play battleship online with friends! ","archived":false,"fork":false,"pushed_at":"2024-08-03T09:55:57.000Z","size":5951,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T03:12:26.446Z","etag":null,"topics":["game","game-development","next-js","nextjs","nextjs14","real-time","realtime","socket-io","socket-programming","tailwindcss","typescript"],"latest_commit_sha":null,"homepage":"https://playbattleship.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mano-08.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-06T10:37:24.000Z","updated_at":"2024-10-10T18:24:46.000Z","dependencies_parsed_at":"2024-08-03T07:49:26.256Z","dependency_job_id":null,"html_url":"https://github.com/Mano-08/battleship","commit_stats":null,"previous_names":["mano-08/battleship"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mano-08%2Fbattleship","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mano-08%2Fbattleship/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mano-08%2Fbattleship/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mano-08%2Fbattleship/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mano-08","download_url":"https://codeload.github.com/Mano-08/battleship/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245579677,"owners_count":20638679,"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","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":["game","game-development","next-js","nextjs","nextjs14","real-time","realtime","socket-io","socket-programming","tailwindcss","typescript"],"created_at":"2024-09-24T13:14:48.417Z","updated_at":"2026-02-15T22:06:29.799Z","avatar_url":"https://github.com/Mano-08.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **BATTLESHIP**\n\n\u003cbr/\u003e\n\n\u003e Dominate the seas, one battle at a time \u003cbr /\u003e Sink your enemies before they sink you!\n\n\u003cbr/\u003e\n\n- [x] 2 Player online game: Create your own game rooms and invite your friends\n- [x] Choose your strategy: randomize your ship placement or carefully position your fleet manually!\n- [x] Compete for glory: track your performance and rise through the ranks on the leaderboard!\n\n\u003cbr/\u003e\n\n![Main Page of BattleShip](https://github.com/user-attachments/assets/148cd638-0392-45d3-aa22-1e47aef3fd96)\n\n![Gameplay screenshot](https://github.com/user-attachments/assets/a6ca17ad-3f78-4fce-ac68-478c815a65da)\n\n### Tech stack\n\n---\n\n- Next.js\n- Socket.io\n- Java Spring Boot\n- Java netty-socket-io\n- Firebase\n\n### Battleship Backend\n\n---\n\nFind the backend system code serving Battleship at \u003ca href=\"https://github.com/Mano-08/server.battleship\"\u003eserver.battleship\u003c/a\u003e.\n\n### Local Setup\n\n---\n\n1. Clone Battleship backend\n\n```typescript\ngit clone https://github.com/Mano-08/server.battleship.git\n```\n\n2. Clone Battleship frontend (branch socket-v2)\n\n```typescript\ngit clone -b https://github.com/Mano-08/battleship.git\n```\n\n3. Install packages for Battleship frontend using\n\n```typescript\npnpm install\n```\n\n4. Run backend using\n\n```typescript\n./gradlew bootRun\n```\n\n5. Run frontend using\n\n```typescript\npnpm run dev\n```\n\n### Bot\u0026apos;s Coordinate Guesser Logic\n\n---\n\nAn intelligent coordinate guesser algorithm has been designed for the robot to predict coordinates that leverages on the previous HIT\ncoordinates along with predicted direction of ship alignment (vertical or horizontal) where the ship was HIT but not WRECKED.\n\u003cbr/\u003e\n\u003cbr/\u003e\nData Structure of the HIT Stack:\n\u003cbr/\u003e\n\n```\n{\n row: number;\n col: number;\n shipId: string;\n direction: \"vertical\" | \"horizontal\" | null;\n}[]\n```\n\n\u003cbr/\u003e\nThe Algorithm is designed based on the following ideology:\n\u003cbr/\u003e\n\u003cbr/\u003e\n            \u003cul className=\"list-disc px-5\"\u003e\n              \u003cli\u003eFirst guess is random, if it is a HIT, then push it into HIT Stack with direction set to null.\u003c/li\u003e\n              \u003cli\u003e\n                If there is data on HIT Stack, the next guess is around the most recent hit, i.e. the top element of stack.\n              \u003c/li\u003e\n              \u003cli\u003e\n                While dropping torpedo around valid coordinates of most recent HIT, if \n                we miss the guess then we would swap predicted direction from vertical to horizontal or vice versa.\n              \u003c/li\u003e\n              \u003cli\u003e\n                In case if there are no valid coordinates around the most recent HIT, there again are 2 cases:\n                \u003col className=\"list-item\"\u003e\n                  \u003cli\u003e\n                    \u003cstrong\u003eCase 1:\u003c/strong\u003e If there are successive hits on my\n                    HIT Stack, then the next guess is along the direction of\n                    Successive hits, this way we reach the other end of the\n                    ship.\n                  \u003c/li\u003e\n                  \u003cli\u003e\n                    \u003cstrong\u003eCase 2:\u003c/strong\u003e Else we just swap our predicted\n                    direction from horizontal to vertical or vertical to\n                    horizontal.\n                  \u003c/li\u003e\n                \u003c/ol\u003e\n              \u003c/li\u003e\n              \u003cli\u003e\n                When a ship is wrecked completely, remove it\u0026apos;s coordinates\n                from the HIT Stack.\n              \u003c/li\u003e\n              \u003cli\u003e\n                If a ship is wrecked and no more coordinates are present inside\n                HIT Stack, just go with random guess.\n              \u003c/li\u003e\n            \u003c/ul\u003e\n            \u003cbr /\u003e\n            You can find the code of the Coordinate guesser\u0026nbsp;\n            \u003ca\n              className=\"underline\"\n              href=\"https://github.com/Mano-08/battleship/blob/main/src/helper/guesser.ts\"\n            \u003e\n              here\n            \u003c/a\u003e\n            .\n            \u003cbr /\u003e\n            Learn more about this project on\u0026nbsp;\u003ca\n              className=\"underline\"\n              href=\"https://github.com/Mano-08/battleship\"\n            \u003e\n              github\n            \u003c/a\u003e\u0026nbsp;and find me on\u0026nbsp;\u003ca className=\"underline\" href=\"https://x.com/mano__08\"\u003e\n              twitter\n            \u003c/a\u003e\n            .\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmano-08%2Fbattleship","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmano-08%2Fbattleship","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmano-08%2Fbattleship/lists"}