{"id":19615017,"url":"https://github.com/ghurtchu/botbeaters","last_synced_at":"2025-07-12T08:39:29.823Z","repository":{"id":127741510,"uuid":"547489470","full_name":"Ghurtchu/botbeaters","owner":"Ghurtchu","description":":game_die::trophy: RNG Game Server. Tech used: Scala, Akka, akka-http \u0026 websockets, spray-json.","archived":false,"fork":false,"pushed_at":"2023-04-03T07:10:11.000Z","size":42506,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-28T02:36:32.265Z","etag":null,"topics":["actors","akka","akka-http","akka-testkit","concurrency","scala","spray-json","websockets"],"latest_commit_sha":null,"homepage":"","language":"Scala","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/Ghurtchu.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}},"created_at":"2022-10-07T19:18:40.000Z","updated_at":"2023-10-30T17:22:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"7d6e2558-fc78-4111-a226-e6257588c506","html_url":"https://github.com/Ghurtchu/botbeaters","commit_stats":null,"previous_names":["scalevolvable/botbeaters","ghurtchu/botbeaters"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Ghurtchu/botbeaters","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghurtchu%2Fbotbeaters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghurtchu%2Fbotbeaters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghurtchu%2Fbotbeaters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghurtchu%2Fbotbeaters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ghurtchu","download_url":"https://codeload.github.com/Ghurtchu/botbeaters/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ghurtchu%2Fbotbeaters/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261759501,"owners_count":23205560,"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":["actors","akka","akka-http","akka-testkit","concurrency","scala","spray-json","websockets"],"created_at":"2024-11-11T10:54:55.048Z","updated_at":"2025-06-24T21:33:53.395Z","avatar_url":"https://github.com/Ghurtchu.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"The game idea is based on RNG and is really simple:\n\nThe client sends the message to the server where it specifies the amount of players for each round. The server uses Akka actors for intercommunication. The game engine is simple:\n- The engine generates a random number for each player and the bot\n- it then applies some business logic and calculates the result for each player\n- then drops all players who were outperformed by bot\n- and finally sorts the results in descending order.\n\nLet's see the flow:\n\n- The client sends a simple JSON via WebSocket to initialize the game\n  \n  The JSON looks like this:\n  ```json\n    {\n      \"messageType\": \"request.play\",\n      \"players\": 10\n    }\n  ```\n  \n- The server uses Akka Actors for intercommunication which looks like this:\n  - Server receives the JSON, parses it, initializes the `GameActor` and sends `InitializeGame` to it.\n  - `GameActor` spawns N amount of `PlayerActor`-s and sends `Play` message to each.\n  - each `PlayerActor` sends `GenerateRandomNumber` to `RNGActor`.\n  - `RNGActor` generates the random number and replies back to `PlayerActor` with `PlayerUpdated` message.\n  - `PlayerActor` then replies `GameActor` with `PlayerReply` message.\n  - Once all messages received, `GameActor` creates `GameAggregatorActor` and sends `AggregateResults` message to it.\n  - `GameAggregatorActor` applies the business logic to the game and responds back with `GameAggregatorReply`.\n  - `GameActor` responds back with the `GameResult` message which holds the final outcome for the round.\n  - And finally the result gets parsed and delivered as a WebSocket response.\n\nThe typical response looks like:\n\n```json\n[\n  {\n    \"number\": 100400,\n    \"player\": \"player_82d7f47f-84b1-48c0-a026-635d87020abe\",\n    \"position\": 1,\n    \"result\": 1002\n  },\n  {\n    \"number\": 616186,\n    \"player\": \"player_b5811f05-9884-470c-b4d4-6b389fb513f8\",\n    \"position\": 2,\n    \"result\": 111\n  },\n  {\n    \"number\": 542540,\n    \"player\": \"player_b700dec7-751f-406a-86a3-5ef1c72c2eea\",\n    \"position\": 3,\n    \"result\": 22\n  },\n  {\n    \"number\": 325584,\n    \"player\": \"player_874b306a-584a-4f7e-b7f1-81ce1a67b322\",\n    \"position\": 4,\n    \"result\": 14\n  },\n  {\n    \"number\": 691235,\n    \"player\": \"bot\",\n    \"position\": 5,\n    \"result\": 6\n  }\n]\n```\n\nSetup instructions:\n  - clone the repo\n  - cd into ~/onair-game-simulation\n  - run `test` to make sure unit and actor tests pass\n  - run `run` to see the options, let's run the most interesting one (AkkaHttpApp) or you may also run AkkaConsoleApp or ScalaConsoleApp\n  - in case of running AkkaHttpApp you need to start second sbt server and `run` GameWebsocketClient for making randomized requests, please pay attention to periodical sorted json responses in terminal\n  - in case of running AkkaHttpApp you need to start third sbt server and run `run` PingPongWebsocketClient for making randomized requests, please pay attention to periodical json responses in terminal\n\nThe app can also be very simply set up with the help of IntelliJ IDEA.\n\nEnjoy!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghurtchu%2Fbotbeaters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghurtchu%2Fbotbeaters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghurtchu%2Fbotbeaters/lists"}