Documentation
¶
Index ¶
- Constants
- type BoardState
- type ConstrictorRuleset
- type Point
- type RoyaleRuleset
- type Ruleset
- type RulesetError
- type Snake
- type SnakeMove
- type SoloRuleset
- type SquadRuleset
- type StandardRuleset
- func (r *StandardRuleset) CreateInitialBoardState(width int32, height int32, snakeIDs []string) (*BoardState, error)
- func (r *StandardRuleset) CreateNextBoardState(prevState *BoardState, moves []SnakeMove) (*BoardState, error)
- func (r *StandardRuleset) IsGameOver(b *BoardState) (bool, error)
- func (r *StandardRuleset) Name() string
Constants ¶
View Source
const ( MoveUp = "up" MoveDown = "down" MoveRight = "right" MoveLeft = "left" BoardSizeSmall = 7 BoardSizeMedium = 11 BoardSizeLarge = 19 SnakeMaxHealth = 100 SnakeStartSize = 3 // bvanvugt - TODO: Just return formatted strings instead of codes? NotEliminated = "" EliminatedByCollision = "snake-collision" EliminatedBySelfCollision = "snake-self-collision" EliminatedByOutOfHealth = "out-of-health" EliminatedByHeadToHeadCollision = "head-collision" EliminatedByOutOfBounds = "wall-collision" // TODO - Error consts ErrorTooManySnakes = RulesetError("too many snakes for fixed start positions") ErrorNoRoomForSnake = RulesetError("not enough space to place snake") ErrorNoRoomForFood = RulesetError("not enough space to place food") ErrorNoMoveFound = RulesetError("move not provided for snake") ErrorZeroLengthSnake = RulesetError("snake is length zero") )
View Source
const EliminatedBySquad = "squad-eliminated"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BoardState ¶
type ConstrictorRuleset ¶ added in v1.0.17
type ConstrictorRuleset struct {
StandardRuleset
}
func (*ConstrictorRuleset) CreateInitialBoardState ¶ added in v1.0.17
func (r *ConstrictorRuleset) CreateInitialBoardState(width int32, height int32, snakeIDs []string) (*BoardState, error)
func (*ConstrictorRuleset) CreateNextBoardState ¶ added in v1.0.17
func (r *ConstrictorRuleset) CreateNextBoardState(prevState *BoardState, moves []SnakeMove) (*BoardState, error)
type RoyaleRuleset ¶ added in v1.0.9
type RoyaleRuleset struct {
StandardRuleset
Seed int64
// TODO: move Turn into BoardState?
Turn int32
ShrinkEveryNTurns int32
}
func (*RoyaleRuleset) CreateNextBoardState ¶ added in v1.0.9
func (r *RoyaleRuleset) CreateNextBoardState(prevState *BoardState, moves []SnakeMove) (*BoardState, error)
func (*RoyaleRuleset) Name ¶ added in v1.0.18
func (r *RoyaleRuleset) Name() string
type Ruleset ¶
type Ruleset interface {
Name() string
CreateInitialBoardState(width int32, height int32, snakeIDs []string) (*BoardState, error)
CreateNextBoardState(prevState *BoardState, moves []SnakeMove) (*BoardState, error)
IsGameOver(state *BoardState) (bool, error)
}
type RulesetError ¶ added in v1.0.17
type RulesetError string
func (RulesetError) Error ¶ added in v1.0.17
func (err RulesetError) Error() string
type SoloRuleset ¶ added in v1.0.4
type SoloRuleset struct {
StandardRuleset
}
func (*SoloRuleset) IsGameOver ¶ added in v1.0.4
func (r *SoloRuleset) IsGameOver(b *BoardState) (bool, error)
func (*SoloRuleset) Name ¶ added in v1.0.18
func (r *SoloRuleset) Name() string
type SquadRuleset ¶ added in v1.0.8
type SquadRuleset struct {
StandardRuleset
SquadMap map[string]string
// These are intentionally designed so that they default to a standard game.
AllowBodyCollisions bool
}
func (*SquadRuleset) CreateNextBoardState ¶ added in v1.0.8
func (r *SquadRuleset) CreateNextBoardState(prevState *BoardState, moves []SnakeMove) (*BoardState, error)
func (*SquadRuleset) IsGameOver ¶ added in v1.0.8
func (r *SquadRuleset) IsGameOver(b *BoardState) (bool, error)
func (*SquadRuleset) Name ¶ added in v1.0.18
func (r *SquadRuleset) Name() string
type StandardRuleset ¶
type StandardRuleset struct {
FoodSpawnChance int32 // [0, 100]
MinimumFood int32
HazardDamagePerTurn int32
}
func (*StandardRuleset) CreateInitialBoardState ¶
func (r *StandardRuleset) CreateInitialBoardState(width int32, height int32, snakeIDs []string) (*BoardState, error)
func (*StandardRuleset) CreateNextBoardState ¶ added in v1.0.4
func (r *StandardRuleset) CreateNextBoardState(prevState *BoardState, moves []SnakeMove) (*BoardState, error)
func (*StandardRuleset) IsGameOver ¶ added in v1.0.4
func (r *StandardRuleset) IsGameOver(b *BoardState) (bool, error)
func (*StandardRuleset) Name ¶ added in v1.0.18
func (r *StandardRuleset) Name() string
Click to show internal directories.
Click to hide internal directories.