{"id":13692696,"url":"https://github.com/wrenger/snork","last_synced_at":"2025-04-14T05:43:07.706Z","repository":{"id":52706407,"uuid":"334488700","full_name":"wrenger/snork","owner":"wrenger","description":"Fast battlesnake agents written in rust.","archived":false,"fork":false,"pushed_at":"2024-08-06T18:42:13.000Z","size":294,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T21:04:50.786Z","etag":null,"topics":["ai","battlesnake","battlesnakeio","competition","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/wrenger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2021-01-30T18:56:43.000Z","updated_at":"2025-02-13T17:47:49.000Z","dependencies_parsed_at":"2024-02-08T19:25:29.220Z","dependency_job_id":"fa17dbca-a84a-43c1-b0c7-81d655cb68cd","html_url":"https://github.com/wrenger/snork","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wrenger%2Fsnork","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wrenger%2Fsnork/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wrenger%2Fsnork/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wrenger%2Fsnork/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wrenger","download_url":"https://codeload.github.com/wrenger/snork/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248830420,"owners_count":21168272,"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":["ai","battlesnake","battlesnakeio","competition","rust"],"created_at":"2024-08-02T17:01:00.996Z","updated_at":"2025-04-14T05:43:07.685Z","avatar_url":"https://github.com/wrenger.png","language":"Rust","funding_links":[],"categories":["Battlesnakes"],"sub_categories":[],"readme":"# Rusty Snakes\n\nFast [Battlesnake](https://play.battlesnake.com) agents written in rust.\nThis project has been developed as part of an AI games course at the Leibniz University Hannover.\n\nOur `Tree` agent (\"ich heisse marvin\") reached second and first place in the global, dual, and royale arenas.\nIn the Spring League 2021, we surpassed last year's best snake ([Kreuzotter](https://github.com/m-schier/battlesnake-2019)) from our university.\n\nAt the end of 2021, the new `Flood` agent reached second place in the Elite Division of the Winter Classic Invitational 2021.\n\n\n## Structure of this Repository\n\nThis repository contains a web server compatible with the Battlesnake API version 1 and abstractions for the data types ([src/env.rs](src/env.rs)).\n\nWe developed multiple different agents ([src/agents](src/agents)), from a simple random agent, a very fast area control agent, to a minimax tree search agent combining multiple heuristics to find the best possible moves.\nThese heuristics are configurable, and the impact of specific variables and their influence over time can be specified on startup.\nThis allows us to perform parameter optimization (Bayesian optimization) to improve the heuristic further.\n\nWe also developed a fast simulator to execute moves and analyze their outcomes.\nIt is used to evaluate the heuristics and tune their parameters.\n\nThe [hpo](hpo) directory contains the code for automatically optimizing the agent's hyperparameters.\nIt utilizes the simulator to simulate the generated configs and find the best-performing parameters.\nThe current default configurations of the `Flood`, `Tree`, and `Mobility` agents are the results of several optimization campaigns.\n\n\n## Usage\n\n### Running the Server\n\nFirst, the rust toolchain has to be installed (https://www.rust-lang.org/learn/get-started).\n\nStarting the server:\n\n```bash\ncargo run --release -- [-h] [--host \u003cip:port\u003e] [--config \u003cjson\u003e]\n```\n\n\u003e There are additional options for `--runtime` and visual representation of the snake (`--head`, `--tail`, `--color`).\n\u003e Run `cargo run --release -- -h` to see all the commandline options.\n\n`config` defines the agent to be used (`Flood`, `Tree`, `Mobility`, `Random`) and configures the agent's heuristic.\nThe default config for the `Flood` agent is, for example:\n\n```json\n{\n  \"Flood\": {\n    \"health\": 0.00044,\n    \"food_distance\": 0.173,\n    \"space\": 0.0026,\n    \"space_adv\": 0.108,\n    \"size_adv\": 7.049,\n    \"size_adv_decay\": 0.041,\n  }\n}\n```\n\n\u003e If a config parameter (like `health`) is excluded the default value is used.\n\n### Simulating Configs\n\nThis tool can be used to simulate different configurations.\nThese configurations specify the agent and its hyperparameters.\nIf no parameters are provided, the default values for the agent are used.\nThe number of simulated games can be specified with `--game-count`.\nUse `-h` for more information about other arguments to define the board size and game rules.\n\nThe example below simulates the `Flood` and `Tree` agents for 10 games:\n\n```bash\ncargo run --release --bin simulate -- '{\"Flood\":{\"space\":8.0}}' '{\"Tree\":{\"centrality\":0}}' --game-count 10\n```\n\nThe last line of the standard output contains the number of wins of the first snake and the total number of games played:\n\n```\nResult: 3/10\n```\n\n### Testing moves\n\nThe `move` program outputs the chosen move for a given game state and agent configuration.\nThis can be useful for debugging situational bugs.\nThe game input can be downloaded from the [battlesnake](https://play.battlesnake.com) with this [Firefox extension](https://addons.mozilla.org/firefox/addon/battlesnake-downloader/).\n\n```bash\ncargo run --release --bin move -- [--config \u003cjson\u003e] [--runtime] \u003cjson\u003e\n```\n\n### Running tests \u0026 benchmarks\n\nThere are multiple tests for the different modules that can be run, as shown below.\nFor more information on unit testing in Rust, see https://doc.rust-lang.org/book/ch11-01-writing-tests.html.\n\n```bash\ncargo test -- [--nocapture] [testname]\n```\n\nBesides the functional tests, there are several performance benchmarks.\nThey are executed with the release config with compiler and linker optimizations.\nThe criterion benchmark runner tracks the execution times from previous runs and reports any improvements or degradations.\n\n```bash\ncargo bench -- [testname]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwrenger%2Fsnork","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwrenger%2Fsnork","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwrenger%2Fsnork/lists"}