scl

package
v0.0.0-...-9c133fc Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const FPS = 22.4
View Source
const HitHistoryLoops = 56 // 2.5 sec
View Source
const KD8Radius = 1.75
View Source
const ResourceSpreadDistance = 9

Variables

View Source
var Blue = api.Color{R: 12, G: 51, B: 232}
View Source
var DestructibleSize = map[api.UnitTypeID]BuildingSize{
	neutral.UnbuildableBricksDestructible:          UnbuildableRocks,
	neutral.UnbuildableBricksSmallUnit:             UnbuildableRocks,
	neutral.UnbuildableBricksUnit:                  UnbuildableRocks,
	neutral.UnbuildablePlatesDestructible:          UnbuildableRocks,
	neutral.UnbuildablePlatesSmallUnit:             UnbuildableRocks,
	neutral.UnbuildablePlatesUnit:                  UnbuildableRocks,
	neutral.UnbuildableRocksDestructible:           UnbuildableRocks,
	neutral.UnbuildableRocksSmallUnit:              UnbuildableRocks,
	neutral.UnbuildableRocksUnit:                   UnbuildableRocks,
	neutral.Rocks2x2NonConjoined:                   BreakableRocks2x2,
	neutral.DestructibleCityDebris4x4:              BreakableRocks4x4,
	neutral.DestructibleDebris4x4:                  BreakableRocks4x4,
	neutral.DestructibleIce4x4:                     BreakableRocks4x4,
	neutral.DestructibleRock4x4:                    BreakableRocks4x4,
	neutral.DestructibleRockEx14x4:                 BreakableRocks4x4,
	neutral.DestructibleCityDebris2x4Horizontal:    BreakableRocks4x2,
	neutral.DestructibleIce2x4Horizontal:           BreakableRocks4x2,
	neutral.DestructibleRock2x4Horizontal:          BreakableRocks4x2,
	neutral.DestructibleRockEx12x4Horizontal:       BreakableRocks4x2,
	neutral.DestructibleCityDebris2x4Vertical:      BreakableRocks2x4,
	neutral.DestructibleIce2x4Vertical:             BreakableRocks2x4,
	neutral.DestructibleRock2x4Vertical:            BreakableRocks2x4,
	neutral.DestructibleRockEx12x4Vertical:         BreakableRocks2x4,
	neutral.DestructibleCityDebris2x6Horizontal:    BreakableRocks6x2,
	neutral.DestructibleIce2x6Horizontal:           BreakableRocks6x2,
	neutral.DestructibleRock2x6Horizontal:          BreakableRocks6x2,
	neutral.DestructibleRockEx12x6Horizontal:       BreakableRocks6x2,
	neutral.DestructibleCityDebris2x6Vertical:      BreakableRocks2x6,
	neutral.DestructibleIce2x6Vertical:             BreakableRocks2x6,
	neutral.DestructibleRock2x6Vertical:            BreakableRocks2x6,
	neutral.DestructibleRockEx12x6Vertical:         BreakableRocks2x6,
	neutral.DestructibleCityDebris6x6:              BreakableRocks6x6,
	neutral.DestructibleDebris6x6:                  BreakableRocks6x6,
	neutral.DestructibleExpeditionGate6x6:          BreakableRocks6x6,
	neutral.DestructibleIce6x6:                     BreakableRocks6x6,
	neutral.DestructibleRock6x6:                    BreakableRocks6x6,
	neutral.DestructibleRock6x6Weak:                BreakableRocks6x6,
	neutral.DestructibleRockEx16x6:                 BreakableRocks6x6,
	neutral.DestructibleCityDebrisHugeDiagonalBLUR: BreakableRocksDiagBLUR,
	neutral.DestructibleDebrisRampDiagonalHugeBLUR: BreakableRocksDiagBLUR,
	neutral.DestructibleIceDiagonalHugeBLUR:        BreakableRocksDiagBLUR,
	neutral.DestructibleRampDiagonalHugeBLUR:       BreakableRocksDiagBLUR,
	neutral.DestructibleRockEx1DiagonalHugeBLUR:    BreakableRocksDiagBLUR,
	neutral.DestructibleCityDebrisHugeDiagonalULBR: BreakableRocksDiagULBR,
	neutral.DestructibleDebrisRampDiagonalHugeULBR: BreakableRocksDiagULBR,
	neutral.DestructibleIceDiagonalHugeULBR:        BreakableRocksDiagULBR,
	neutral.DestructibleRampDiagonalHugeULBR:       BreakableRocksDiagULBR,
	neutral.DestructibleRockEx1DiagonalHugeULBR:    BreakableRocksDiagULBR,
	neutral.DestructibleIceHorizontalHuge:          BreakableHorizontalHuge,
	neutral.DestructibleRampHorizontalHuge:         BreakableHorizontalHuge,
	neutral.DestructibleRockEx1HorizontalHuge:      BreakableHorizontalHuge,
	neutral.DestructibleIceVerticalHuge:            BreakableVerticalHuge,
	neutral.DestructibleRampVerticalHuge:           BreakableVerticalHuge,
	neutral.DestructibleRockEx1VerticalHuge:        BreakableVerticalHuge,
}
View Source
var Green = api.Color{R: 1, G: 255, B: 48}
View Source
var Red = api.Color{R: 255, G: 1, B: 44}
View Source
var White = api.Color{R: 255, G: 255, B: 255}
View Source
var Yellow = api.Color{R: 232, G: 177, B: 12}

Functions

func BresenhamsLineDrawable

func BresenhamsLineDrawable(p0, p1 point.Point, grid *grid.Grid) bool

func CmpAirDPS

func CmpAirDPS(unit *Unit) float64

func CmpAirRange

func CmpAirRange(unit *Unit) float64

func CmpAirScore

func CmpAirScore(unit *Unit) float64

func CmpFood

func CmpFood(unit *Unit) float64

func CmpGroundDPS

func CmpGroundDPS(unit *Unit) float64

func CmpGroundDamage

func CmpGroundDamage(unit *Unit) float64

func CmpGroundRange

func CmpGroundRange(unit *Unit) float64

func CmpGroundScore

func CmpGroundScore(unit *Unit) float64

func CmpHits

func CmpHits(unit *Unit) float64

func CmpTags

func CmpTags(unit *Unit) float64

Comparers

func CmpTotalScore

func CmpTotalScore(unit *Unit) float64

func DefaultAttackFunc

func DefaultAttackFunc(u *Unit, priority int, targets Units) bool

func DefaultMoveFunc

func DefaultMoveFunc(u *Unit, target *Unit)

func DpsGt5

func DpsGt5(u *Unit) bool

func Flying

func Flying(u *Unit) bool

func Gathering

func Gathering(u *Unit) bool

func Ground

func Ground(u *Unit) bool

func HasReactor

func HasReactor(u *Unit) bool

func HasTechlab

func HasTechlab(u *Unit) bool

func Hidden

func Hidden(u *Unit) bool

func Idle

func Idle(u *Unit) bool

Filters

func MaxInt

func MaxInt(a, b int) int

func Mechanical

func Mechanical(u *Unit) bool

func MinInt

func MinInt(a, b int) int

func Mineral

func Mineral(u *Unit) bool
func NavPath(grid *grid.Grid, wpm WaypointsMap, fromPtr, toPtr point.Pointer) (point.Points, float64)

func NoAddon

func NoAddon(u *Unit) bool

func NotReady

func NotReady(u *Unit) bool

func NotStructure

func NotStructure(u *Unit) bool

func NotWorker

func NotWorker(u *Unit) bool

func PosVisible

func PosVisible(u *Unit) bool

func Ready

func Ready(u *Unit) bool

func SortByOther

func SortByOther(mainSlice []point.Point, otherSlice []float64) []point.Point

func Structure

func Structure(u *Unit) bool

func TimeToLoop

func TimeToLoop(minutes, seconds int) int

func Unused

func Unused(u *Unit) bool

func Visible

func Visible(u *Unit) bool

Types

type Aliases

type Aliases map[api.UnitTypeID]UnitTypes

func (Aliases) Add

func (as Aliases) Add(td *api.UnitTypeData)

func (Aliases) For

func (as Aliases) For(ut api.UnitTypeID) UnitTypes

func (Aliases) Min

func (as Aliases) Min(ut api.UnitTypeID) api.UnitTypeID

type AttackDelays

type AttackDelays map[api.UnitTypeID]int

func (AttackDelays) IsCool

func (ad AttackDelays) IsCool(ut api.UnitTypeID, cooldown float32, frames int) bool

func (AttackDelays) Max

func (ad AttackDelays) Max(ut api.UnitTypeID, frames int) int

func (AttackDelays) UnitIsCool

func (ad AttackDelays) UnitIsCool(u *Unit) bool

type AttackFunc

type AttackFunc func(u *Unit, priority int, targets Units) bool

type Bot

type Bot struct {
	Client        *client.Client
	Obs           *api.Observation
	Data          *api.ResponseData
	Info          *api.ResponseGameInfo
	Chat          []*api.ChatReceived
	Result        []*api.PlayerResult
	Errors        []*api.ActionError
	Actions       actions.Actions
	Cmds          *CommandsStack
	DebugCommands []*api.DebugCommand
	RecentEffects [][]*api.Effect // This needed because corrosive biles disappear from effects to early

	Locs struct {
		MapCenter       point.Point
		MyStart         point.Point
		MyStartMinVec   point.Point
		EnemyStart      point.Point
		EnemyStarts     point.Points
		EnemyMainCenter point.Point
		MyExps          point.Points
		EnemyExps       point.Points
	}
	Ramps struct {
		All   []Ramp
		My    Ramp
		Enemy Ramp
	}
	Units struct {
		My       UnitsByTypes
		MyAll    Units
		Enemy    UnitsByTypes
		AllEnemy UnitsByTypes
		Minerals UnitsByTypes
		Geysers  UnitsByTypes
		Neutral  UnitsByTypes
		ByTag    map[api.UnitTag]*Unit
	}
	Enemies struct {
		All      Units
		AllReady Units
		Visible  Units
		Clusters []*Cluster // Not used yet
	}
	U struct {
		Types              []*api.UnitTypeData
		GroundAttackCircle map[api.UnitTypeID]point.Points
		Upgrades           []*api.UpgradeData
		Effects            []*api.EffectData
		UnitCost           map[api.UnitTypeID]Cost
		AbilityCost        map[api.AbilityID]Cost
		AbilityUnit        map[api.AbilityID]api.UnitTypeID
		UnitAbility        map[api.UnitTypeID]api.AbilityID
		UnitAliases        Aliases
		UnitsOrders        map[api.UnitTag]UnitOrder

		Attributes  map[api.UnitTypeID]map[api.Attribute]bool
		Weapons     map[api.UnitTypeID]Weapon
		HitsHistory map[api.UnitTag][]int
		PrevUnits   map[api.UnitTag]*Unit
		AfterAttack AttackDelays
		LastAttack  map[api.UnitTag]int
	}
	Miners struct {
		CCForMiner       map[api.UnitTag]api.UnitTag
		GasForMiner      map[api.UnitTag]api.UnitTag
		MineralForMiner  map[api.UnitTag]api.UnitTag
		TargetForMineral map[api.UnitTag]point.Point
		LastSeen         map[api.UnitTag]int
	}

	Grid           *grid.Grid
	SafeGrid       *grid.Grid
	ReaperGrid     *grid.Grid
	ReaperSafeGrid *grid.Grid
	// HomePaths        Steps
	// HomeReaperPaths  Steps
	// ExpPaths         []Steps
	WayMap           WaypointsMap
	SafeWayMap       WaypointsMap
	ReaperExists     bool
	ReaperWayMap     WaypointsMap
	ReaperSafeWayMap WaypointsMap

	EnemyRace       api.Race
	EnemyProduction TagsByTypes
	Orders          map[api.AbilityID]int
	FramesPerOrder  int
	Groups          *Groups
	MaxGroup        GroupID
	Upgrades        map[api.AbilityID]bool

	Loop             int
	LastLoop         int
	Minerals         int
	MineralsPerFrame float64
	Vespene          int
	VespenePerFrame  float64
	FoodCap          int
	FoodUsed         int
	FoodLeft         int

	UnitCreatedCallback func(unit *Unit)
}
var B *Bot // Pointer to the last created bot. It should be the only global here

func New

func New(client *client.Client, ucc func(unit *Unit)) *Bot

func (*Bot) AddToCluster

func (b *Bot) AddToCluster(enemy *Unit, c *Cluster)

func (*Bot) CalculateExpansionLocations

func (b *Bot) CalculateExpansionLocations() []UnitCluster

CalculateExpansionLocations groups resources into clusters and determines the best town hall location for each cluster. The Center() point of each cluster is the optimal town hall location. If debug is true then the results will also be visualized in-game (until new debug info is drawn).

func (*Bot) CanBuild

func (b *Bot) CanBuild(aid api.AbilityID, limit, active int) bool

func (*Bot) CanBuy

func (b *Bot) CanBuy(ability api.AbilityID) bool

func (*Bot) CheckPoints

func (b *Bot) CheckPoints(ps point.Points, check CheckMap) bool

func (*Bot) Debug2x2Buildings

func (b *Bot) Debug2x2Buildings(ps ...point.Point)

func (*Bot) Debug3x3Buildings

func (b *Bot) Debug3x3Buildings(ps ...point.Point)

func (*Bot) Debug5x3Buildings

func (b *Bot) Debug5x3Buildings(ps ...point.Point)

func (*Bot) DebugAdd

func (b *Bot) DebugAdd(cmd *api.DebugCommand)

func (*Bot) DebugAddBoxes

func (b *Bot) DebugAddBoxes(boxes []*api.DebugBox)

func (*Bot) DebugAddLines

func (b *Bot) DebugAddLines(lines []*api.DebugLine)

func (*Bot) DebugAddSpheres

func (b *Bot) DebugAddSpheres(spheres []*api.DebugSphere)

func (*Bot) DebugAddUnits

func (b *Bot) DebugAddUnits(unitType api.UnitTypeID, owner api.PlayerID, pos point.Point, qty uint32)

func (*Bot) DebugCircles

func (b *Bot) DebugCircles(cs ...point.Circle)

func (*Bot) DebugClusters

func (b *Bot) DebugClusters()

func (*Bot) DebugEnemyUnits

func (b *Bot) DebugEnemyUnits()

func (*Bot) DebugKillUnits

func (b *Bot) DebugKillUnits(tags ...api.UnitTag)

func (*Bot) DebugLines

func (b *Bot) DebugLines(lines point.Lines, color api.Color)

func (*Bot) DebugMap

func (b *Bot) DebugMap()

func (*Bot) DebugOrders

func (b *Bot) DebugOrders()

func (*Bot) DebugPath

func (b *Bot) DebugPath(path point.Points, color api.Color)

func (*Bot) DebugPoints

func (b *Bot) DebugPoints(ps ...point.Point)

func (*Bot) DebugRamps

func (b *Bot) DebugRamps()

func (*Bot) DebugSafeGrid

func (b *Bot) DebugSafeGrid(normal, safe *grid.Grid)

func (*Bot) DebugSend

func (b *Bot) DebugSend()

func (*Bot) DebugUnitValue

func (b *Bot) DebugUnitValue(tag api.UnitTag, value api.DebugSetUnitValue_UnitValue, qty float32)

func (*Bot) DebugWayMap

func (b *Bot) DebugWayMap(wpm WaypointsMap, showLines bool)

func (*Bot) DeductResources

func (b *Bot) DeductResources(aid api.AbilityID)

func (*Bot) DetectEnemyRace

func (b *Bot) DetectEnemyRace()

func (*Bot) EffectPoints

func (b *Bot) EffectPoints(effect api.EffectID) point.Points

func (*Bot) FillGases

func (b *Bot) FillGases(miners *Units, ccs, gases Units)

func (*Bot) FillMineralsUpTo2

func (b *Bot) FillMineralsUpTo2(miners *Units, ccs, allMfs Units)

func (*Bot) FillMineralsUpTo3

func (b *Bot) FillMineralsUpTo3(miners *Units, ccs, allMfs Units)

func (*Bot) FindBaseCenter

func (b *Bot) FindBaseCenter(basePos point.Point) point.Point

func (*Bot) FindBaseCluster

func (b *Bot) FindBaseCluster(p point.Point, cluster *point.Points, basePoints map[point.Point]bool)

func (*Bot) FindClosestPathable

func (b *Bot) FindClosestPathable(grid *grid.Grid, ptr point.Pointer) point.Point

func (*Bot) FindClosestPos

func (b *Bot) FindClosestPos(ptr point.Pointer, size BuildingSize, aid api.AbilityID,
	cells PathableCells, maxOffset, step int, flags ...CheckMap) point.Point

Return 0 if not found

func (*Bot) FindClusterTopPoints

func (b *Bot) FindClusterTopPoints(cluster *point.Points) (point.Points, float64)

func (*Bot) FindClusters

func (b *Bot) FindClusters()

func (*Bot) FindExpansions

func (b *Bot) FindExpansions()

func (*Bot) FindHomeMineralsVector

func (b *Bot) FindHomeMineralsVector()

func (*Bot) FindPaths

func (b *Bot) FindPaths(grid *grid.Grid, ptr point.Pointer, reaper bool) Steps

func (*Bot) FindRamp2x2Positions

func (b *Bot) FindRamp2x2Positions(ramp Ramp) point.Points

func (*Bot) FindRampBarracksPositions

func (b *Bot) FindRampBarracksPositions(ramp Ramp) point.Points

First position is for initial building, second is for addon

func (*Bot) FindRampCluster

func (b *Bot) FindRampCluster(p point.Point, cluster *point.Points, rampPoints map[point.Point]bool)

func (*Bot) FindRamps

func (b *Bot) FindRamps()

func (*Bot) FindWaypoints

func (b *Bot) FindWaypoints(wpm WaypointsMap, grid *grid.Grid) Waypoints

func (*Bot) FindWaypointsMap

func (b *Bot) FindWaypointsMap(grid *grid.Grid) WaypointsMap

func (*Bot) GetBuildingPoints

func (b *Bot) GetBuildingPoints(ptr point.Pointer, size BuildingSize) point.Points

func (*Bot) GetGasSaturation

func (b *Bot) GetGasSaturation(gases Units) map[api.UnitTag]int

func (*Bot) GetMineralsSaturation

func (b *Bot) GetMineralsSaturation(mfs Units) map[api.UnitTag]int

func (*Bot) GetPathablePoints

func (b *Bot) GetPathablePoints(ptr point.Pointer, size BuildingSize, cells PathableCells) point.Points

func (*Bot) HandleMiners

func (b *Bot) HandleMiners(miners, ccs, enemies Units, balance float64, safePos point.Pointer, turrets point.Points)

balance - minerals to gas gather ratio, ex: 2 => gather more vespene if it is less than minerals * 2

func (*Bot) HandleOversaturation

func (b *Bot) HandleOversaturation(ccs, allMfs Units)

func (*Bot) Init

func (b *Bot) Init(stop <-chan struct{})

func (*Bot) InitCCMinerals

func (b *Bot) InitCCMinerals(cc *Unit, turrets point.Points)

func (*Bot) InitEffects

func (b *Bot) InitEffects(effectData []*api.EffectData)

func (*Bot) InitLocations

func (b *Bot) InitLocations()

func (*Bot) InitMining

func (b *Bot) InitMining(turrets point.Points)

func (*Bot) InitRamps

func (b *Bot) InitRamps()

func (*Bot) InitUnits

func (b *Bot) InitUnits(typeData []*api.UnitTypeData)

func (*Bot) InitUpgrades

func (b *Bot) InitUpgrades(upgradeData []*api.UpgradeData)

func (*Bot) IsPosOk

func (b *Bot) IsPosOk(ptr point.Pointer, size BuildingSize, cells PathableCells, flags ...CheckMap) bool

func (*Bot) MicroGas

func (b *Bot) MicroGas(miners, gases, ccs, enemies Units, safePos point.Pointer)

func (*Bot) MicroMinerals

func (b *Bot) MicroMinerals(miners, ccs, enemies Units, safePos point.Pointer, turrets point.Points)

func (*Bot) MyRace

func (b *Bot) MyRace() api.Race

func (*Bot) NewUnit

func (b *Bot) NewUnit(unit *api.Unit) (*Unit, bool)

func (*Bot) ParseObservation

func (b *Bot) ParseObservation()

func (*Bot) ParseOrders

func (b *Bot) ParseOrders()

func (*Bot) ParseUnits

func (b *Bot) ParseUnits()

func (*Bot) Path

func (b *Bot) Path(toPtr, fromPtr point.Pointer) (point.Points, float64)

Params in reverse order because astar.Path returns reversed list

func (*Bot) Pending

func (b *Bot) Pending(aid api.AbilityID) int

func (*Bot) PendingAliases

func (b *Bot) PendingAliases(aid api.AbilityID) int

func (*Bot) RedistributeWorkersToRefineryIfNeeded

func (b *Bot) RedistributeWorkersToRefineryIfNeeded(ref *Unit, miners Units, limit int)

func (*Bot) RenewPaths

func (b *Bot) RenewPaths(stop <-chan struct{})

func (*Bot) RequestAvailableAbilities

func (b *Bot) RequestAvailableAbilities(irr bool, us ...*Unit)

func (*Bot) RequestPathing

func (b *Bot) RequestPathing(p1, p2 point.Pointer) float64

func (*Bot) RequestPlacement

func (b *Bot) RequestPlacement(ability api.AbilityID, pos point.Point, builder *Unit) bool

func (*Bot) SaveState

func (b *Bot) SaveState()

func (*Bot) UnitTargetPos

func (b *Bot) UnitTargetPos(u *Unit) point.Point

func (*Bot) UpdateData

func (b *Bot) UpdateData()

func (*Bot) UpdateInfo

func (b *Bot) UpdateInfo()

func (*Bot) UpdateObservation

func (b *Bot) UpdateObservation()

type BuildingSize

type BuildingSize int
const (
	S2x1 BuildingSize = iota + 1
	S2x2
	S3x3
	S5x3
	S5x5
	UnbuildableRocks
	BreakableRocks2x2
	BreakableRocks4x4
	BreakableRocks4x2
	BreakableRocks2x4
	BreakableRocks6x2
	BreakableRocks2x6
	BreakableRocks6x6
	BreakableRocksDiagBLUR
	BreakableRocksDiagULBR
	BreakableHorizontalHuge
	BreakableVerticalHuge
)

type Cell

type Cell struct {
	point.Point
	Distance float64
}

type CellsPair

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

type CheckMap

type CheckMap int
const (
	IsBuildable CheckMap = iota + 1
	IsPathable
	IsVisible
	IsExplored
	IsCreep
	IsNoCreep
)

type Cluster

type Cluster struct {
	Units UnitsMap
	Food  float64
}

type CommandsStack

type CommandsStack struct {
	Simple      map[api.AbilityID]Units
	SimpleQueue map[api.AbilityID]Units
	Pos         map[api.AbilityID]map[point.Point]Units
	PosQueue    map[api.AbilityID]map[point.Point]Units
	Tag         map[api.AbilityID]map[api.UnitTag]Units
	TagQueue    map[api.AbilityID]map[api.UnitTag]Units
}

func (*CommandsStack) AddPos

func (cs *CommandsStack) AddPos(a api.AbilityID, p point.Point, queue bool, u ...*Unit)

func (*CommandsStack) AddSimple

func (cs *CommandsStack) AddSimple(a api.AbilityID, queue bool, u ...*Unit)

func (*CommandsStack) AddTag

func (cs *CommandsStack) AddTag(a api.AbilityID, t api.UnitTag, queue bool, u ...*Unit)

func (*CommandsStack) Process

func (cs *CommandsStack) Process(actions *actions.Actions)

func (*CommandsStack) ProcessPos

func (cs *CommandsStack) ProcessPos(actions *actions.Actions, posList map[api.AbilityID]map[point.Point]Units, queue bool)

func (*CommandsStack) ProcessSimple

func (cs *CommandsStack) ProcessSimple(actions *actions.Actions, simple map[api.AbilityID]Units, queue bool)

func (*CommandsStack) ProcessTag

func (cs *CommandsStack) ProcessTag(actions *actions.Actions, tagList map[api.AbilityID]map[api.UnitTag]Units, queue bool)

type Compare

type Compare func(unit *Unit) float64

type Cost

type Cost struct {
	Minerals int
	Vespene  int
	Food     int
	Time     int
}

type Filter

type Filter func(unit *Unit) bool

type Group

type Group struct {
	Tags  Tags
	Units Units
}

type GroupID

type GroupID int

type Groups

type Groups struct {
	MaxGroup GroupID
	// contains filtered or unexported fields
}

func NewGroups

func NewGroups(maxGroup GroupID) *Groups

func (*Groups) Add

func (gs *Groups) Add(group GroupID, units ...*Unit)

func (*Groups) AddN

func (gs *Groups) AddN(groupName string, units ...*Unit)

func (*Groups) ClearUnits

func (gs *Groups) ClearUnits()

func (*Groups) Fill

func (gs *Groups) Fill(unit *Unit)

Add unit info to the corresponding group

func (*Groups) Get

func (gs *Groups) Get(group GroupID) Group

func (*Groups) GetN

func (gs *Groups) GetN(groupName string) Group

func (*Groups) New

func (gs *Groups) New(units ...*Unit) GroupID

type MapAccessor

type MapAccessor interface {
	IsPathable(p point.Pointer) bool
	IsBuildable(p point.Pointer) bool
	HeightAt(p point.Pointer) float64
}

type MoveFunc

type MoveFunc func(u *Unit, target *Unit)

type PathableCells

type PathableCells int
const (
	Zero PathableCells = iota
	One
	Two
)

type Paths

type Paths struct {
	Steps Steps
	Queue Queue
	B     MapAccessor
}

func (*Paths) AddCell

func (paths *Paths) AddCell(src, dst *Cell, reaper bool)

func (*Paths) FindPathableCell

func (paths *Paths) FindPathableCell(src, dst *Cell) point.Point

func (*Paths) Present

func (paths *Paths) Present(p point.Point) bool

type Queue

type Queue map[float64][]CellsPair

func (Queue) MinDist

func (q Queue) MinDist() ([]CellsPair, float64)

type Ramp

type Ramp struct {
	Top    point.Point
	Vec    point.Point
	Size   int
	Height float64
}

type Steps

type Steps map[point.Point]*Cell // from -> next step

func (Steps) Follow

func (steps Steps) Follow(ptr point.Pointer, limit int) point.Point

func (Steps) From

func (steps Steps) From(ptr point.Pointer) point.Points

type Tags

type Tags []api.UnitTag

func (*Tags) Add

func (ts *Tags) Add(tags ...api.UnitTag)

func (Tags) Empty

func (ts Tags) Empty() bool

func (Tags) Exists

func (ts Tags) Exists() bool

func (Tags) Len

func (ts Tags) Len() int

func (*Tags) Remove

func (ts *Tags) Remove(tag api.UnitTag)

type TagsByTypes

type TagsByTypes map[api.UnitTypeID]TagsMap

func (*TagsByTypes) Add

func (tt *TagsByTypes) Add(ut api.UnitTypeID, tag api.UnitTag)

func (TagsByTypes) Len

func (tt TagsByTypes) Len(ut api.UnitTypeID) int

func (TagsByTypes) Score

func (tt TagsByTypes) Score(uts ...api.UnitTypeID) int

type TagsMap

type TagsMap map[api.UnitTag]bool

type Tile

type Tile struct {
	// X and Y are the coordinates of the tile.
	X, Y float64
	// B is a reference to the Bot
	B MapAccessor
	// Tiles storage
	M map[float64]map[float64]*Tile
}

A Tile is a tile in a grid which implements Pather.

func (*Tile) Map

func (t *Tile) Map(x, y float64) *Tile

func (*Tile) PathEstimatedCost

func (t *Tile) PathEstimatedCost(to astar.Pather) float64

func (*Tile) PathNeighborCost

func (t *Tile) PathNeighborCost(to astar.Pather) float64

PathNeighborCost returns the movement cost of the directly neighboring tile.

func (*Tile) PathNeighbors

func (t *Tile) PathNeighbors() []astar.Pather

PathNeighbors returns the neighbors of the tile, excluding blockers and tiles off the edge of the board.

type Unit

type Unit struct {
	api.Unit
	SpamCmds     bool
	CmdSet       bool
	HPS          float64
	Hits         float64
	HitsMax      float64
	HitsLost     float64
	Abilities    []api.AbilityID
	IrrAbilities []api.AbilityID
	PosDelta     point.Point
	Neighbours   Units
	Cluster      *Cluster
}

func (*Unit) AirDPS

func (u *Unit) AirDPS() float64

func (*Unit) AirDamage

func (u *Unit) AirDamage() float64

func (*Unit) AirEvade

func (u *Unit) AirEvade(enemies Units, gap float64, ptr point.Pointer) (point.Point, bool)

these two functions are bad because they consider only one unit to evade. Todo: rewrite

func (*Unit) AirRange

func (u *Unit) AirRange() float64

func (*Unit) AssessStrength

func (u *Unit) AssessStrength(attackers Units) (outranged, stronger bool)

func (*Unit) Attack

func (u *Unit) Attack(targetsGroups ...Units)

func (*Unit) AttackCustom

func (u *Unit) AttackCustom(attackFunc AttackFunc, moveFunc MoveFunc, targetsGroups ...Units)

func (*Unit) AttackMove

func (u *Unit) AttackMove(target *Unit)

func (*Unit) CanAttack

func (u *Unit) CanAttack(us Units, gap float64) Units

func (*Unit) Command

func (u *Unit) Command(ability api.AbilityID)

func (*Unit) CommandPos

func (u *Unit) CommandPos(ability api.AbilityID, target point.Pointer)

func (*Unit) CommandPosQueue

func (u *Unit) CommandPosQueue(ability api.AbilityID, target point.Pointer)

func (*Unit) CommandQueue

func (u *Unit) CommandQueue(ability api.AbilityID)

func (*Unit) CommandTag

func (u *Unit) CommandTag(ability api.AbilityID, target api.UnitTag)

func (*Unit) CommandTagQueue

func (u *Unit) CommandTagQueue(ability api.AbilityID, target api.UnitTag)

func (*Unit) Dist

func (u *Unit) Dist(ptr point.Pointer) float64

func (*Unit) Dist2

func (u *Unit) Dist2(ptr point.Pointer) float64

func (*Unit) EstimatePositionAfter

func (u *Unit) EstimatePositionAfter(frames int) point.Point

func (*Unit) EvadeEffects

func (u *Unit) EvadeEffects() bool

func (*Unit) EvadeEffectsPos

func (u *Unit) EvadeEffectsPos(ptr point.Pointer, checkKD8 bool, eids ...api.EffectID) (point.Point, bool)

func (*Unit) FindAssignedBuilder

func (u *Unit) FindAssignedBuilder(builders Units) *Unit

func (*Unit) FindAssignedRepairers

func (u *Unit) FindAssignedRepairers(reps Units) Units

func (*Unit) FramesToDistantPos

func (u *Unit) FramesToDistantPos(ptr point.Pointer) float64

func (*Unit) FramesToPos

func (u *Unit) FramesToPos(ptr point.Pointer) float64

func (*Unit) GetEffectsList

func (u *Unit) GetEffectsList() []api.EffectID

func (*Unit) GetWayMap

func (u *Unit) GetWayMap(safe bool) (*grid.Grid, WaypointsMap)

func (*Unit) GroundDPS

func (u *Unit) GroundDPS() float64

func (*Unit) GroundDamage

func (u *Unit) GroundDamage() float64

func (*Unit) GroundEvade

func (u *Unit) GroundEvade(enemies Units, gap float64, ptr point.Pointer) (point.Point, bool)

func (*Unit) GroundFallback

func (u *Unit) GroundFallback(safePos point.Pointer, ignoreAttackAbility bool)

func (*Unit) GroundRange

func (u *Unit) GroundRange() float64

func (*Unit) GroundTowards

func (u *Unit) GroundTowards(ptr point.Pointer, offset float64, safe bool) point.Point

func (*Unit) HasAbility

func (u *Unit) HasAbility(a api.AbilityID) bool

func (*Unit) HasBuff

func (u *Unit) HasBuff(b api.BuffID) bool

func (*Unit) HasIrrAbility

func (u *Unit) HasIrrAbility(a api.AbilityID) bool

func (*Unit) HasReactor

func (u *Unit) HasReactor() bool

func (*Unit) HasTechlab

func (u *Unit) HasTechlab() bool

func (*Unit) InRange

func (u *Unit) InRange(target *Unit, gap float64) bool

func (*Unit) InRangeOf

func (u *Unit) InRangeOf(us Units, gap float64) Units

func (*Unit) Is

func (u *Unit) Is(ids ...api.UnitTypeID) bool

func (*Unit) IsAlreadyAttackingTargetInRange

func (u *Unit) IsAlreadyAttackingTargetInRange() bool

Used to prevent switches between targets with same priority without actually attacking anything

func (*Unit) IsArmed

func (u *Unit) IsArmed() bool

func (*Unit) IsArmored

func (u *Unit) IsArmored() bool

func (*Unit) IsCloserThan

func (u *Unit) IsCloserThan(dist float64, ptr point.Pointer) bool

func (*Unit) IsCoolToAttack

func (u *Unit) IsCoolToAttack() bool

Тут нужно определять способен ли юнит нанести удар развернувшись без дополнительной задержки Но так же надо следить, успеют ли укусить рипера или другой отступающий юнит Пока что надёжнее дожидаться u.WeaponCooldown == 0, тогда Рипер убегая от лингов или зилота атакует реже и тем самым может сохранять дистанцию Used to check if unit is ready to attack right away

func (*Unit) IsCoolToMove

func (u *Unit) IsCoolToMove() bool

Used to check if it is ok to issue next _move_ order without interrupting current attack action

func (*Unit) IsDefensive

func (u *Unit) IsDefensive() bool

func (*Unit) IsFarFrom

func (u *Unit) IsFarFrom(ptr point.Pointer) bool

func (*Unit) IsFurtherThan

func (u *Unit) IsFurtherThan(dist float64, ptr point.Pointer) bool

func (*Unit) IsGathering

func (u *Unit) IsGathering() bool

func (*Unit) IsGeyser

func (u *Unit) IsGeyser() bool

func (*Unit) IsHidden

func (u *Unit) IsHidden() bool

func (*Unit) IsIdle

func (u *Unit) IsIdle() bool

func (*Unit) IsLight

func (u *Unit) IsLight() bool

func (*Unit) IsMechanical

func (u *Unit) IsMechanical() bool

func (*Unit) IsMineral

func (u *Unit) IsMineral() bool

func (*Unit) IsMoving

func (u *Unit) IsMoving() bool

func (*Unit) IsNot

func (u *Unit) IsNot(ids ...api.UnitTypeID) bool

func (*Unit) IsPosVisible

func (u *Unit) IsPosVisible() bool

func (*Unit) IsReady

func (u *Unit) IsReady() bool

func (*Unit) IsReturning

func (u *Unit) IsReturning() bool

func (*Unit) IsSafeToApproach

func (u *Unit) IsSafeToApproach(p point.Pointer) bool

func (*Unit) IsStructure

func (u *Unit) IsStructure() bool

func (*Unit) IsUnused

func (u *Unit) IsUnused() bool

func (*Unit) IsVisible

func (u *Unit) IsVisible() bool

func (*Unit) IsWorker

func (u *Unit) IsWorker() bool

func (*Unit) Point

func (u *Unit) Point() point.Point

func (*Unit) RangeDelta

func (u *Unit) RangeDelta(target *Unit, gap float64) float64

func (*Unit) SightRange

func (u *Unit) SightRange() float64

func (*Unit) Speed

func (u *Unit) Speed() float64

func (*Unit) SpreadFromSplash

func (u *Unit) SpreadFromSplash(enemies Units, ptr point.Pointer) (point.Point, bool)

func (*Unit) TargetAbility

func (u *Unit) TargetAbility() api.AbilityID

func (*Unit) TargetPos

func (u *Unit) TargetPos() point.Point

func (*Unit) TargetTag

func (u *Unit) TargetTag() api.UnitTag

func (*Unit) Towards

func (u *Unit) Towards(ptr point.Pointer, offset float64) point.Point

type UnitCluster

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

UnitCluster is a cluster of units and the associated center of mass.

func MakeCluster

func MakeCluster(units Units, distance float64) []UnitCluster

Taken from Chippydip's lib Cluster breaks a list of units into clusters based on the given clustering distance.

func (*UnitCluster) Add

func (c *UnitCluster) Add(u *Unit)

Add adds a new unit to the cluster and updates the center of mass.

func (*UnitCluster) Center

func (c *UnitCluster) Center() point.Point

Center is the center of mass of the cluster.

func (*UnitCluster) Count

func (c *UnitCluster) Count() int

Count returns the number of units in the cluster.

func (*UnitCluster) Units

func (c *UnitCluster) Units() *Units

Units is the list of units in the cluster.

type UnitOrder

type UnitOrder struct {
	Loop    int
	Ability api.AbilityID
	Pos     point.Point
	Tag     api.UnitTag
}

type UnitTypes

type UnitTypes []api.UnitTypeID

func (*UnitTypes) Add

func (ut *UnitTypes) Add(ids ...api.UnitTypeID)

func (UnitTypes) Contain

func (ut UnitTypes) Contain(id api.UnitTypeID) bool

type Units

type Units []*Unit

func FilterCmdSetAndSetItForTheRest

func FilterCmdSetAndSetItForTheRest(us Units) Units

func (*Units) Add

func (us *Units) Add(units ...*Unit)

func (Units) Attack

func (us Units) Attack(targetsGroups ...Units)

func (Units) ByTag

func (us Units) ByTag(tag api.UnitTag) *Unit

func (Units) ByTags

func (us Units) ByTags(tags Tags) Units

func (Units) CanAttack

func (us Units) CanAttack(u *Unit, gap float64) Units

List of units that can attack u

func (Units) Center

func (us Units) Center() point.Point

func (Units) CloserThan

func (us Units) CloserThan(dist float64, ptr point.Pointer) Units

func (Units) ClosestTo

func (us Units) ClosestTo(ptr point.Pointer) *Unit

func (Units) Command

func (us Units) Command(ability api.AbilityID)

func (Units) CommandPos

func (us Units) CommandPos(ability api.AbilityID, target point.Pointer)

func (Units) CommandPosQueue

func (us Units) CommandPosQueue(ability api.AbilityID, target point.Pointer)

func (Units) CommandQueue

func (us Units) CommandQueue(ability api.AbilityID)

func (Units) CommandTag

func (us Units) CommandTag(ability api.AbilityID, target api.UnitTag)

func (Units) CommandTagQueue

func (us Units) CommandTagQueue(ability api.AbilityID, target api.UnitTag)

func (Units) Empty

func (us Units) Empty() bool

func (Units) Exists

func (us Units) Exists() bool

func (Units) Filter

func (us Units) Filter(filters ...Filter) Units

func (Units) First

func (us Units) First(filters ...Filter) *Unit

While using each method you should check that it returns not nil

func (Units) FurtherThan

func (us Units) FurtherThan(dist float64, ptr point.Pointer) Units

func (Units) FurthestTo

func (us Units) FurthestTo(ptr point.Pointer) *Unit

func (Units) InRangeOf

func (us Units) InRangeOf(u *Unit, gap float64) Units

List of units that are in range of u

func (Units) Len

func (us Units) Len() int

func (Units) Max

func (us Units) Max(comp Compare) *Unit

func (Units) Min

func (us Units) Min(comp Compare) *Unit

func (Units) OfType

func (us Units) OfType(ids ...api.UnitTypeID) Units

func (Units) OrderBy

func (us Units) OrderBy(comp Compare, desc bool)

func (Units) OrderByDistanceTo

func (us Units) OrderByDistanceTo(ptr point.Pointer, desc bool)

func (*Units) Pop

func (us *Units) Pop() *Unit

func (Units) Rect

func (us Units) Rect() point.Points

Coordinates of rectangle that fits all units

func (*Units) Remove

func (us *Units) Remove(unit *Unit)

func (*Units) RemoveTag

func (us *Units) RemoveTag(tag api.UnitTag)

func (Units) Sum

func (us Units) Sum(comp Compare) float64

func (Units) Tags

func (us Units) Tags() []api.UnitTag

func (Units) TagsMap

func (us Units) TagsMap() map[api.UnitTag]bool

type UnitsByTypes

type UnitsByTypes map[api.UnitTypeID]Units

func (UnitsByTypes) Add

func (ut UnitsByTypes) Add(utype api.UnitTypeID, unit *Unit)

func (UnitsByTypes) All

func (ut UnitsByTypes) All() Units

func (UnitsByTypes) Empty

func (ut UnitsByTypes) Empty() bool

func (UnitsByTypes) Exists

func (ut UnitsByTypes) Exists() bool

func (UnitsByTypes) OfType

func (ut UnitsByTypes) OfType(ids ...api.UnitTypeID) Units

type UnitsMap

type UnitsMap map[*Unit]struct{}

type Waypoint

type Waypoint struct {
	point.Point
	M WaypointsMap
}

func (*Waypoint) PathEstimatedCost

func (t *Waypoint) PathEstimatedCost(to astar.Pather) float64

func (*Waypoint) PathNeighborCost

func (t *Waypoint) PathNeighborCost(to astar.Pather) float64

PathNeighborCost returns the movement cost of the directly neighboring tile.

func (*Waypoint) PathNeighbors

func (t *Waypoint) PathNeighbors() []astar.Pather

PathNeighbors returns the neighbors of the tile, excluding blockers and tiles off the edge of the board.

type Waypoints

type Waypoints []*Waypoint

func FindNeighbours

func FindNeighbours(wpm WaypointsMap, from *Waypoint, waypoints Waypoints, skip int, grid *grid.Grid) Waypoints

type WaypointsMap

type WaypointsMap map[*Waypoint]Waypoints

func (WaypointsMap) NewWaypoint

func (wpm WaypointsMap) NewWaypoint(p point.Point) *Waypoint

type Weapon

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

Jump to

Keyboard shortcuts

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