Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Latest commit

 

History

History
21 lines (12 loc) · 1.4 KB

useful-algorithms.md

File metadata and controls

21 lines (12 loc) · 1.4 KB
description
A collection of useful algorithms for building a competitive Battlesnake.

Useful Algorithms

This page was inspired by BoldBigflank, 101donutman, and Xtagon in the Battlesnake Discord. Each algorithm listed should include a widely accessible definition (think ELI5 style), how it could be applied to Battlesnake, and links to further resources. Contributions and updates are always welcome!__

Flood Fill

Flood fill is an algorithm to determine the boundaries and size of an enclosed space. A common example is the 'fill' or 'bucket' tool in paint and graphics programs, which finds all pixels within a set boundary.

Using Flood Fill in Battlesnake

In Battlesnake flood fill is a simple way to detect and avoid enclosed spaces that Battlesnakes may not be able to escape from. For example, if a Battlesnake were to move into a specific square, flood fill could be used to statically determine how many adjacent squares a Battlesnake could subsequently move into before running out of space.

Often times Battlesnakes will want to consider the available space of each move prior to choosing which move to make.

Additional Flood Fill Resources