{"id":13692706,"url":"https://github.com/m-schier/battlesnake-2019","last_synced_at":"2025-05-02T19:32:32.072Z","repository":{"id":38011174,"uuid":"174587053","full_name":"m-schier/battlesnake-2019","owner":"m-schier","description":"🥈 2nd Intermediate Division @ Battlesnake 2019, Victoria by Team \"Niedersächsische Kreuzotter\"","archived":false,"fork":false,"pushed_at":"2022-12-08T04:19:41.000Z","size":59,"stargazers_count":10,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-12T18:42:01.450Z","etag":null,"topics":["battlesnake","battlesnake-2019","battlesnakeio","competition"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m-schier.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-08T18:18:02.000Z","updated_at":"2023-04-01T11:34:38.000Z","dependencies_parsed_at":"2023-01-25T08:16:48.922Z","dependency_job_id":null,"html_url":"https://github.com/m-schier/battlesnake-2019","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/m-schier%2Fbattlesnake-2019","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m-schier%2Fbattlesnake-2019/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m-schier%2Fbattlesnake-2019/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m-schier%2Fbattlesnake-2019/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m-schier","download_url":"https://codeload.github.com/m-schier/battlesnake-2019/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252095417,"owners_count":21693912,"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":["battlesnake","battlesnake-2019","battlesnakeio","competition"],"created_at":"2024-08-02T17:01:01.109Z","updated_at":"2025-05-02T19:32:31.620Z","avatar_url":"https://github.com/m-schier.png","language":"C#","funding_links":[],"categories":["Battlesnakes"],"sub_categories":[],"readme":"﻿# BattleSnake 2019 Submission by Team \"Niedersächsische Kreuzotter\"\n\n## About\nBattleSnake 2019 was an artificial intelligence competition carried out by Dyspatch, Github and other sponsors in March 2019 in Victoria, BC, Canada.\nThe objective of the competition was creating an AI to control a snake in a multi agent game of competetive snake dubbed BattleSnake.\n\nThis repository contains the submission of our team consisting of Maximilian Schier, Frederick Schubert and Niclas Wüstenbecker (in alphabetical order).\nThe team efforts were supported by the Institute for Information Processing (TNT) of the University of Hannover, especially Florian Kluger, M.Sc.\n\nOur team placed 2nd in the Intermediate division.\n\n## Paper\nThe algorithms and heuristics used in this software are described in more detail in our publication \n[Adversarial N-player Search using Locality for the Game of Battlesnake](https://dl.gi.de/handle/20.500.12116/29001) \n\n## Content\nThe code in this repository is a heavily cut and edited version of our tournament code. Many agents, heuristics, metrics and functions that are not required\nto run were stripped. This controller does however perform exactly the same moves as it did during competition.\n\n## Installation and running\nThis project requires [.NET Core SDK](https://dotnet.microsoft.com/download) for compiling. To build and run this solution, run `dotnet run -c Release` from this\nfolder. A web server is started on the default port of 5050, though this port may be changed through the `PORT` environment variable. You may then interface with the\ncontroller on `http://localhost:5050/primary` with the [official BattleSnake engine](https://github.com/battlesnakeio/engine).\n\n## Strategy\nOur AI performs a game tree search to determine the optimal move. Therefore we had to implement a full simulation of the game in C# to simualted future steps.\nWe implemented a different world representation than the official engine uses that has very fast constant time update, cloning and collision checking by using\na matrix/pointer based representation of the world instead of the list based approach of the main engine. This potential was however not fully used as our heuristics\nproved to be the main bottleneck in the end.\n\nGame tree search is iteratively deepened until the specified cutoff time is reached. The subset of opponents to simulate is determined by minimum distance of an opponents\nbody part to our own head. If we cannot reach any body part within the search depth, we are performing a reflex based evaluation for this opponent. This means that the opponent\nwill try to perform a non-suicidal move at each leaf of the search tree, but we are not playing out all moves for this opponent. If the number of fully simulated snakes (including\nour own) is 2, we are performing Alpha Beta search for its increased speed (though this search could still be improved by sorting of nodes and other means usually employed).\nIf we are however simulating more than 2 snakes, we are employing the MaxN algorithm for multi agent games. This algorithm uses no pruning and can therefore only evaluate a\nsignificantly more shallow part of the tree.\n\nDue to the nature of both Alpha Beta and MaxN search our agent is generally pessimistic about its options. Since we are performing the first virtual ply followed by the opponents\nply during search, the opponent may counter our move perfectly for all cases. This is however not possible in reality as our ply is not visible until all agents have specified\ntheir desired moves.\n\nFor heuristic we primarily used a variety of flood fill and distance metrics. \n\n## Remarks\nThe deepening search using MaxN simulating all potentially dangerous opponents allowed us to play very well in the early stages of the game, rarely getting eliminated.\nThis also resulted in us performing best of all submitting teams in the Dyspatch arena where the agent faced an increasing number of hostile snakes ganging up on the\nuser snake, winning this bounty.\n\nIt became apperant however that our heuristics were sub par. Our agent tries to maximize its territorial advantage without utilizing either length or territory advantage\nfully. This generally resulted in us \"idling\" too much, which is also the reason we had a significant length disadvantage in the final duell against the winner team.\n\nShould we compete again, we should mainly focus on improving our heuristics for this reason.\n\n## Known issues\n- Receiving an `/end` request with our snake killed results in a non fatal exception causing a resource leak\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm-schier%2Fbattlesnake-2019","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm-schier%2Fbattlesnake-2019","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm-schier%2Fbattlesnake-2019/lists"}