{"id":21421422,"url":"https://github.com/percival33/battleships","last_synced_at":"2025-10-27T03:14:23.350Z","repository":{"id":107184865,"uuid":"429519543","full_name":"Percival33/Battleships","owner":"Percival33","description":"Battleships game created as an university assignment essentials of Informatics and Programming","archived":false,"fork":false,"pushed_at":"2022-10-17T19:51:53.000Z","size":35858,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T20:14:02.328Z","etag":null,"topics":["battleship","c","game"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Percival33.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":"2021-11-18T17:26:20.000Z","updated_at":"2023-04-17T16:44:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"041ebb43-ba8f-437d-b468-7593b70c5c05","html_url":"https://github.com/Percival33/Battleships","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Percival33/Battleships","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Percival33%2FBattleships","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Percival33%2FBattleships/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Percival33%2FBattleships/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Percival33%2FBattleships/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Percival33","download_url":"https://codeload.github.com/Percival33/Battleships/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Percival33%2FBattleships/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264465845,"owners_count":23612580,"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":["battleship","c","game"],"created_at":"2024-11-22T20:34:13.590Z","updated_at":"2025-10-27T03:14:23.277Z","avatar_url":"https://github.com/Percival33.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Battleships game\nProject for collage assignment essentials of Informatics and Programming\n### Task\nWrite battleships game, then extend it by writing additional functionalities, so it will become interesting.\n\n## Goals:\n\nMain goals for the assignment\n\nBasics:\n\n- [x] Implement a board of fixed size 21x10 \n- [x] Each player has exactly 1 ship of size 5 [CAR]RIER , 2 ships of size 4 [BAT]TLESHIP, 3 ships of size 3 [CRU]ISER , 4 ships of size 2 [DES]TROYER\n- [x] There is a possibility of placing the ships by the players. A can put ships in rows 0...9; B can put ships in rows 11...20. \n- [x] The players can make moves, one after another, the only possible move is to either place the ships or shot one shot at a given position.\n- [x] The game can detect which players wins. The checking of victory condition (the opposing player has no healthy ship fragments left) should be done at the end of the turn.\n- [x] Program can print the state of the game.\n\nExtended logic: \n\n- [x] The board can be of arbitrary size. The player starting positions can be bounded into arbitrary rectangle. There can be specified reefs, i.e. forbidden fields on the map and no ship under any circumstances can be present on such a field. The number of reefs specified can be quite large, but bounded by the size of board. Also, some of the ships of the players can be preallocated. Make the size and allocation of the board truly dynamic.\n- [x] A player can make an order to move a ship. In each round each of the players can make any ship rotate, or move one field in its direction. Each ship except the carrier can move up to 3 times in a round. Carrier can move only up to 2 times. However, due to the fact that the ships are ships, they cannot rotate in place, and, for simplicity, are always going forward 1 field.  \nE.g. for a destroyer changing course to the right twice.\n```\n#       #+++      #   +\n#+# -\u003e  # #  -\u003e   # # +\n#+      #         #   +\n#+      #         #\n```\n- [x] Each of the ships contains additional section, radar at it's head. The radar provides an \ninformation about positions of other ships, i.e. if there is a opposing ship in the range of the \nradar. If the radar is damaged, then the range of the radar is 1; otherwise it is the length of the \nship. A field is in range if the distance (the same formula as for the cannon) between the field \nand the radar is at most the range of the radar. Of course, a ship knows it's position always. \nAlso, carriers can send spy planes (in number up to equal to the number of shoots - 5), the \nplanes revel presence of enemy ships in 3x3 square each. Sending a planes count as shooting.\nPrinting from player's perspective should be implemented.\n\n- [x]  Extended printing, in addition to the previous point the following things should be printed:\na) engine as %\nb) cannon as !\nc) radar as @\nIf the cannon and engine are taking the same field, then engine should be printed. Also, the \nnumbers of rows and columns should be printed, e.g. as:\n```\n 00000000001\n 01234567890\n00\n01\n00 # @!++%\n01\n02 #%\n03 @\n```\n- [x] Printing (Saving) the state of the game. The program should be able to print commands \nwhich allows to reconstruct the state of the game.\n\nAdvanced logic:\n\n- [x] implement A.I. which should be able to execute some reasonable strategy. For example, to always move carrier out of the range of other ships, if possible; or to scout the map initially.\n\n## Commands: \n\n**STATE COMMANDS**\n\nThe group of state commands starts with **[state]** and the commands from this group are provided until \nanother **[state]** is encountered. There are\n\nBasic: \n- ```PRINT x``` - **x = 0**  basic version,  **x = 1**   extended version\n- ```SET_FLEET P a1 a2 a3 a4``` - The number of ships of consecutive classes for the player P\n- ```NEXT_PLAYER P``` - Sets an information that P should make move next.\n\nExtended:\n\n\n- ```BOARD_SIZE y x``` - Set the board size to y x \n- ```INIT_POSITION P y1 x1 y2 x2``` The player P can place ships in rectangle given by (y1, x1) (left upper) and (y2, x2) (right lower).\n- ```REEF y x``` - Place a reef at position (y,x)\n- ```SHIP P y x D i C a1...al``` - There is a ship of player P at position (y,x) in the direction D(N/W/S/E) i-th of class C \n(CAR/BAT/CRU/DES). The state of the segments are a1 … al, where l is the length of the \nship and 1 means that the part is not destroyed, 0 that it was destroyed. This command is \nunaffected by starting positions requirements.\n- ```EXTENDED_SHIPS``` -Turn the extended logic of ships. I.e. the ships are composed of the 2 sections, etc. Turning \nthis on disables the default SHOOT operations by players. \n- ```SAVE``` - Save the commands that allows to recreate the state of the game.\n\n\n**PLAYER COMMANDS**\n\nThe group of player commands starts and ends with **[playerX]**, where X is either A or B. Commands \nare give until another corresponding **[playerX]** is given.\n\nBasic:\n\n- ```PLACE_SHIP y x D i C``` - Place the i-th ship of class C at (y,x) with direction equal to D.\n- ```SHOOT y x``` - Shoot at the field (y,x). Shooting can only start if all the ships were placed.\n\nExtended:\n\n- ```MOVE i C x``` - Move the i-th ship of class C x ([F]orward, [L]eft, [R]ight).\n- ```SHOOT i C y x``` -Let one of the shoots of i-th class ship be at (y,x).\n- ```SPY i y x``` - Send a spy plane from i-th carrier at the position (y,x).\n- ```PRINT x``` - Print the state of the game as seen by the player. That is, print the state as seen using radars \nand spy planes. The reefs are known every time. If a field is empty print ' '. If a field \ncontains a visible part of ship print it. If a field is unknown print '?'.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpercival33%2Fbattleships","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpercival33%2Fbattleships","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpercival33%2Fbattleships/lists"}