coach

package
v2.0.0-alpha.10 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package coach is a generated GoMock package.

Index

Constants

View Source
const (
	// ErrMinCols defines an error for invalid number of cols
	ErrMinCols = Error("number of cols lower the minimum")
	// ErrMaxCols defines an error for invalid number of cols
	ErrMaxCols = Error("number of cols higher the maximum")
	// ErrMinRows defines an error for invalid number of rows
	ErrMinRows = Error("number of rows lower the minimum")
	// ErrMaxRows defines an error for invalid number of rows
	ErrMaxRows = Error("number of rows higher the maximum")
)
View Source
const (
	ErrPlayerNotFound = Error("player not found in the game Snapshot")
	ErrNoBall         = Error("no ball found in the snapshot")
)
View Source
const (
	// Define the min number of cols allowed on the field division by the positioner
	MinCols uint8 = 4
	// Define the min number of rows allowed on the field division by the positioner
	MinRows uint8 = 2
	// Define the max number of cols allowed on the field division by the positioner
	MaxCols uint8 = 20
	// Define the max number of rows allowed on the field division by the positioner
	MaxRows uint8 = 10
)

Variables

This section is empty.

Functions

func DefaultTurnHandler

func DefaultTurnHandler(decider Decider, config lugo4go.Config, logger lugo4go.Logger) lugo4go.DecisionMaker

DefaultTurnHandler is a handler that allow you to create an interface to follow an basic strategy to define bot states. This function does not have to be used. You may define your own DecisionMaker function, and handle all messages as you prefer. Please take a look into Decider interface, and see how it may simplify your work.

Types

type Decider

type Decider interface {
	OnDisputing(ctx context.Context, data TurnData) error
	OnDefending(ctx context.Context, data TurnData) error
	OnHolding(ctx context.Context, data TurnData) error
	OnSupporting(ctx context.Context, data TurnData) error
	AsGoalkeeper(ctx context.Context, data TurnData) error
}

type Error

type Error string

Error helps to define internal errors

func (Error) Error

func (e Error) Error() string

type MockDecider

type MockDecider struct {
	// contains filtered or unexported fields
}

MockDecider is a mock of Decider interface

func NewMockDecider

func NewMockDecider(ctrl *gomock.Controller) *MockDecider

NewMockDecider creates a new mock instance

func (*MockDecider) AsGoalkeeper

func (m *MockDecider) AsGoalkeeper(arg0 context.Context, arg1 TurnData) error

AsGoalkeeper mocks base method

func (*MockDecider) EXPECT

func (m *MockDecider) EXPECT() *MockDeciderMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockDecider) OnDefending

func (m *MockDecider) OnDefending(arg0 context.Context, arg1 TurnData) error

OnDefending mocks base method

func (*MockDecider) OnDisputing

func (m *MockDecider) OnDisputing(arg0 context.Context, arg1 TurnData) error

OnDisputing mocks base method

func (*MockDecider) OnHolding

func (m *MockDecider) OnHolding(arg0 context.Context, arg1 TurnData) error

OnHolding mocks base method

func (*MockDecider) OnSupporting

func (m *MockDecider) OnSupporting(arg0 context.Context, arg1 TurnData) error

OnSupporting mocks base method

type MockDeciderMockRecorder

type MockDeciderMockRecorder struct {
	// contains filtered or unexported fields
}

MockDeciderMockRecorder is the mock recorder for MockDecider

func (*MockDeciderMockRecorder) AsGoalkeeper

func (mr *MockDeciderMockRecorder) AsGoalkeeper(arg0, arg1 interface{}) *gomock.Call

AsGoalkeeper indicates an expected call of AsGoalkeeper

func (*MockDeciderMockRecorder) OnDefending

func (mr *MockDeciderMockRecorder) OnDefending(arg0, arg1 interface{}) *gomock.Call

OnDefending indicates an expected call of OnDefending

func (*MockDeciderMockRecorder) OnDisputing

func (mr *MockDeciderMockRecorder) OnDisputing(arg0, arg1 interface{}) *gomock.Call

OnDisputing indicates an expected call of OnDisputing

func (*MockDeciderMockRecorder) OnHolding

func (mr *MockDeciderMockRecorder) OnHolding(arg0, arg1 interface{}) *gomock.Call

OnHolding indicates an expected call of OnHolding

func (*MockDeciderMockRecorder) OnSupporting

func (mr *MockDeciderMockRecorder) OnSupporting(arg0, arg1 interface{}) *gomock.Call

OnSupporting indicates an expected call of OnSupporting

type PlayerState

type PlayerState string

PlayerState defines states specific for players

const (
	// Supporting identifies the player supporting the team mate
	Supporting PlayerState = "supporting"
	// HoldingTheBall identifies the player holding	the ball
	HoldingTheBall PlayerState = "holding"
	// Defending identifies the player defending against the opponent team
	Defending PlayerState = "defending"
	// DisputingTheBall identifies the player disputing the ball
	DisputingTheBall PlayerState = "disputing"
)

func DefineMyState

func DefineMyState(config lugo4go.Config, snapshot *proto.GameSnapshot) (PlayerState, error)

type Positioner

type Positioner interface {
	// GetRegion Returns a region based on the coordinates and on the current field division
	GetRegion(col, row uint8) (Region, error)
	// GetPointRegion returns the region where that point is in
	GetPointRegion(point proto.Point) (Region, error)
}

Positioner Helps the bots to see the fields from their team perspective instead of using the cartesian plan provided by the game server. Instead of base your logic on the axes X and Y, the positioner create a region map based on the team side. The region coordinates uses the defensive field's right corner as its origin. This mechanism if specially useful to define players regions based on their roles, since you do not have to mirror the coordinate, neither do extra logic to define regions on the field where the player should be.

func NewPositioner

func NewPositioner(cols, rows uint8, sideRef proto.Team_Side) (Positioner, error)

NewPositioner creates a new Positioner that will map the field to provide Regions

type Region

type Region interface {
	fmt.Stringer
	// The col coordinate based on the field division
	Col() uint8
	// The row coordinate based on the field division
	Row() uint8
	// Return the point at the center of the quadrant represented by this Region. It is not always precise.
	Center() proto.Point

	// The region immediatelly in front of this one from the player perspective
	// Important: The same region is returned if the requested region is not valid
	Front() Region
	// The region immediatelly behind this one from the player perspective
	// Important: The same region is returned if the requested region is not valid
	Back() Region
	// The region immediatelly on left of this one from the player perspective
	// Important: The same region is returned if the requested region is not valid
	Left() Region
	// The region immediatelly on right of this one from the player perspective
	// Important: The same region is returned if the requested region is not valid
	Right() Region
}

Region represent a quadrant on the field. It is not always squared form because you may define how many cols/rows the field will be divided in. So, based on that division (e.g. 4 rows, 6 cols) there will be a fixed number of regions and their coordinates will be zero-index (e.g. from 0 to 3 rows when divided in 4 rows).

type TurnData

type TurnData struct {
	Me       *proto.Player
	Snapshot *proto.GameSnapshot
	Sender   lugo4go.OrderSender
}

Jump to

Keyboard shortcuts

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