utils

package
v0.0.0-...-a2d6bc3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2017 License: MIT Imports: 0 Imported by: 0

README

Utils for both bot and replayer

Direction class

Movement directions between two adjacent positions on the field.

Player class

Information about the player: current position (x, y), last move, id

Field class

Contains the field as two dimensional byte array. First dimension is vertical (y), second one is horizontal (x). Containes height and width of the game field too.

Documentation

Index

Constants

View Source
const (
	REPLAY_DIR       = "replays"
	REPLAY_SEPARATOR = '|'
)

Variables

View Source
var (
	DEBUG_VARS = []string{"round"} //example for debugging variables
)

Functions

This section is empty.

Types

type Direction

type Direction int
const (
	Up Direction = iota
	Right
	Down
	Left
	Wtf
)

func (Direction) Reverse

func (d Direction) Reverse() Direction

func (Direction) String

func (d Direction) String() string

type Field

type Field struct {
	Rows          [][]byte
	Width, Height int
}

type Player

type Player struct {
	X, Y, Id int
	IdStr    byte
	LastMove Direction
}

func (*Player) Move

func (p *Player) Move()

func (*Player) MoveField

func (p *Player) MoveField(field *Field)

func (*Player) SetAndMoveField

func (p *Player) SetAndMoveField(fieldStr string, field *Field)

func (*Player) SetMove

func (p *Player) SetMove(d Direction)

func (*Player) WhereIs

func (p *Player) WhereIs(in string, field *Field) Direction

type ReplayFormat

type ReplayFormat struct {
	FieldWidth  int `json:"W"`
	FieldHeight int `json:"H"`
	OwnX        int `json:"N"`
	OwnY        int `json:"M"`
	OppX        int `json:"P"`
	OppY        int `json:"Q"`
}

type ReplayMove

type ReplayMove struct {
	OwnMove Direction `json:"N"`
	OppMove Direction `json:"P"`
	//additional fields may come here for debug purposes
	Others []string `json:"O"` //debugging variables
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL