Imperfect Information RFC -- Battlesnake Flashlight Tag #253
Replies: 3 comments 3 replies
-
Thanks for the awesome RFC Corey! I have two additional thoughts to be considered:
Best |
Beta Was this translation helpful? Give feedback.
-
This is great Corey! At first glance I would really like to find a way to roll out Maybe it's as simple as giving Maps the filter function you propose as an API call that can manipulate BoardStates before they get sent to specific snakes. To start, we could limit input and output to valid BoardStates, and then the Map could only use the BoardState Editor interface to manipulate state for each snake -- this comes with added protections of not having to worry about the filter func breaking the JSON format, since it doesn't actually operate on the raw data.
I also like the idea of Maps being able to draw on the board arbitrarily! Maybe rather than |
Beta Was this translation helpful? Give feedback.
-
Love this idea - particularly because I've always wanted there to be some kind of "game mode" that forces you to keep state. Otherwise, Battlesnake doesn't really push you into learning about databases - which is kind of a pity since they tend to be a major component of most software development work. I agree with Brad's thought that, at least at first, maybe this is best implemented as an optional maps hook. Even if it might make sense to eventually separate them out, there's a lot of plumbing required to get a new game setting end to end - e.g. in the play UI, play database, engine API, engine workers, rules, etc. Another unfortunate gotcha here is that the engine codebase has a mix of representations of the board state, depending on which step of playing a game it's in. The code that makes requests to snake servers uses one type, and the rules code uses another. The game logic converts to the rules BoardState after making the requests, then applies the rules, then converts back before storing the next frame in the database. I don't think this is insurmountable, but it is the reason why I never got around to implementing the |
Beta Was this translation helpful? Give feedback.
-
The purpose of this document is to propose a new feature to Battlesnake, and allow it to be played as an imperfect information game.
The proposed new game type involved allowing Snakes too ONLY see things within 5 game spaces from the head of their snake.
The working title for this game mode is “Flashlight Tag”
Background
Perfect vs Imperfect Information
Battlesnake has historically been a “perfect” information game. This means that each snake has the full information about the game state. Each player knows where each snake is, where the food is and where any hazard squares might be.
This makes Battlesnake easy to understand as you get started!
But for developers looking for an additional challenge, an “imperfect” information game mode opens up new ideas and possibilities.
If your snake is only able to see a few squares around its head, new strategies are expected to be explored!
Stateful Snakes
In particular, the Battlesnake Team believes an imperfect information game mode will encourage more “stateful” snakes, that remember information from one turn to the next.
In “traditional” perfect information Battlesnake, you can be very competitive without storing any state from turn to turn, since each turn you get the full information of the game board.
The introduction of an imperfect information game mode seems like it will increase the advantage of being able to store state between turns.
Battlesnake is all about teaching developers valuable skills while they build snakes, and high performance ‘local state’ is an awesome thing we can help developers gain exposure too.
Examples
Yannik and others from University of Hannover have been working on an imperfect information game mode for use in their AI classes!
You can see an example game played with one such imperfect information game mode
Technical Background
The Battlesnake rules repo is open source and available at
https://github.com/BattlesnakeOfficial/rules
The rules repo currently has two constructs to create different game types: ‘rulesets’ and ‘maps’
Examples of
rulesets
include:standard
,wrapped
andconstrictor
And Examples of
maps
include:arcade_maze
,solo_maze
, andsnail_mode
Rulesets
Rulesets change base behavior of the game. For example
standard
defines how snakes move and eliminations are done, this is the traditional Ruleset Battlesnake ruleset.wrapped
changes us the original rules by allowing snakes to leave the board on one side, and appear on the other! Instandard
this would lead to an elimination from hitting a wallAnd
constrictor
changes the base rules my making it so snakes grow each turn, and their tail never move from their original square.Maps
Maps on the other hand don’t affect the base rules of the game, but allow developers to create unique experiences on top of the rulesets.
For example the
arcade_maze
map typically is played with thewrapped
ruleset, and has an arcade game inspired ‘maze’ for the snakes to battle it out in.The
solo_maze
andsnail_mode
maps add some extra complexity.One thing the Map interface allows you to do is decide the position of all food and hazards on the game board.
solo_maze
uses this to a build a maze of hazards, with a food as the goal. When the snake reaches this food the map “increases in size”, a new map is generated by placing hazards on the board and a new goal food is placed.snail_mode
uses the hazards to create deadly “snail tails” behind snakes. When a snake leaves a space thesnail_mode
map replaces its tail with a hazard that stacks in damage. Over time this “slime” trail fades away, and this is also controlled by thesnail_mode
mapboard
ViewerThe
board
is responsible for showing games to developers in the UI: https://github.com/BattlesnakeOfficial/boardboard
currently has NO knowledge of any of the modeling we just talked about. It does NOT know about the different maps or rules specifically.Instead the server sends it a copy of the game board for each frame, with all the information on the board. This is similar to the information sent to each snake.
This approach keeps the board decoupled from the engine, and allows adding game modes without requiring changes to the
board
.Proposal
I propose that we introduce a new construct to allow the creation of new imperfect information game modes.
In addition to
rulesets
andmaps
, this RFC proposes addingfilters
.filters
would NOT be able to affect the game state as the rules repo sees it, but WOULD be able to alter the board state before they are sent to snakes.And the filter would be applied to each snake individually, so that the filter could craft custom responses for each snake.
In Psuedo-Code the existing process looks something like this for an individual turn
In the new version I propose a solution that looks like this
The difference is the body of the for loop
Now we call
filter.filter_for_snake
for each snake before making requests.This allows custom filters to be applied to each snake, which should enable the “flashlight tag” game mode
Adding a new construct for the filter allows the existing
ruleset
andmap
constructs to remain unchanged!Snake Request Changes
The shape of the JSON sent to snakes MAY change in this RFC.
We propose that filters are allowed to REMOVE information from the requests, but NOT add new fields or information. It is likely this requirement will not be able to be enforced in code, but will remain a social construct.
Some of the information we expect filters to remove are:
Its important to note that with the removal of snake body pieces, there is NO guarantee that snake body pieces are contiguous or that the number of snake body pieces equals the full length of the snake
Filters shall NOT remove “metadata” information about the game. This includes the ruleset, map and any filter modes that may be active.
board
changesWe want to be able to ‘see’ what each snake can see while replaying the games.
And we would like to do that without requiring the
board
repo to be aware of the specific rules of the filters.To do this I propose we make the
rules
repo in charge of deciding how to render any new ‘additions’.I propose we add a new ‘ui_additions’ object that a filter can create. These
ui_additions
should be for things that do not affect gameplay, but add extra information to the board.At a minimum
filters
should be able to createui_additions
, but I think it’s reasonable to allowmaps
andrulesets
to do the same!The
board
repo uses SVG to render the board, so I propose theui_addition
object closely match SVG elements. For the initial implementation of this game mode, I think only a single ‘type’ ofui_addition
is needed, but we should expect to expand this in the future.We need a
ui_addition
that maps to a cell of the board. The basic shape could look something like thisThis would allow us to draw cells for what each snake can see, similar to how the games look in the examples!
Alternatives Considered
Adding a Ruleset
In some sense it would be ideal to allow adding a “flashlight_tag” game mode, without adding any new concepts to the Battlesnake game.
One way to accomplish this would be to define ”flashlight_tag” as a
ruleset
!rulesets
are the lowest level concept here, and as such have the most ‘power’ to control the board state.However,
rulesets
are NOT positioned in a place to create different experiences for each snake.And with the current state of the
rules
code, aruleset
is NOT responsible for actually sending requests to snakes.For a
flashlight_tag
to be written as a ruleset we’d need to refactor the rules and create a tighter coupling between a Ruleset and how requests are sent to snakes.Another big downside to this approach is that it doesn’t allow easy ‘stacking. For example it’s reasonable to want to play “flashlight_tag” with either the standard ruleset or the wrapped ruleset. It would be unfortunate if we needed to create a “flashlight_tag_standard” and “flashlight_tag_wrapped” rulesets to accomplish this goal.
Adding a new Map
Trying to slot this into a Map has some of the same drawbacks a ‘ruleset’ does, and a map is more limited in its control of the board state.
Maps don’t provide a way to customize the requests sent to each snake, which is a core requirement of this proposal.
And again it would be ideal to be able to ‘stack’ different filters on top of different maps, without needing to duplicate large amount of logic
Having the
board
calculate the view tooWe could have the Rules repo know how to draw the UI on its own, without adding any new information to the wire protocol.
But this requires the
board
repo also knowing the rules of the filter, and reduces the decoupling betweenboard
andrules
that we have todayBeta Was this translation helpful? Give feedback.
All reactions