macro

package
v0.0.0-...-f38aecb Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

View Source
const SafeBuildRange = 9

Variables

View Source
var FactoryBuildOrder = BuildNodes{
	{
		Name:    "Factory Tech Lab",
		Ability: ability.Build_TechLab_Factory,
		Premise: func() bool {
			factory := B.Units.My[terran.Factory].First(scl.Ready, scl.NoAddon, scl.Idle)
			return (factory != nil) && B.Enemies.Visible.CloserThan(SafeBuildRange, factory).Empty()
		},
		Limit: func() int {
			allFactories := B.Units.My.OfType(B.U.UnitAliases.For(terran.Factory)...)
			if allFactories.Len() == 1 {
				return 1
			}
			return allFactories.Len()
		},
		Active: BuildOne,
		Method: func() {
			B.Units.My[terran.Factory].First(scl.Ready, scl.NoAddon, scl.Idle).Command(ability.Build_TechLab_Factory)
		},
	},
}
View Source
var RaxBuildOrder = BuildNodes{
	{
		Name:    "Bunkers",
		Ability: ability.Build_Bunker,
		Premise: func() bool {
			return B.PlayDefensive && B.Units.My[terran.Marine].Len() >= 2
		},
		Limit:  func() int { return B.BunkersPos.Len() },
		Active: func() int { return B.BunkersPos.Len() },
	},
	{
		Name:    "Armory",
		Ability: ability.Build_Armory,
		Premise: func() bool {
			cyclones := B.PendingAliases(ability.Train_Cyclone)
			tanks := B.PendingAliases(ability.Train_SiegeTank)
			return (cyclones > 0 || tanks > 0) && B.Units.My[terran.EngineeringBay].First(scl.Ready) != nil
		},

		Limit: func() int {
			if B.Units.My[terran.FusionCore].First(scl.Ready) != nil {
				return 2
			}
			return 1
		},
		Active: BuildOne,
	},
	{
		Name:    "Barracks",
		Ability: ability.Build_Barracks,
		Premise: func() bool {
			if B.CcAfterRax && B.Units.My[terran.Barracks].First(scl.Unused) != nil {
				return false
			}
			if B.Units.My.OfType(B.U.UnitAliases.For(terran.Barracks)...).Len() >= 2 && B.Minerals <= 450 {
				return false
			}
			if B.Minerals > 800 {
				return true
			}
			return !B.WorkerRush && B.Units.My[terran.BarracksFlying].Empty() &&
				B.Units.My[terran.Barracks].First(scl.Ready, scl.Unused) == nil
		},
		Limit: func() int {
			ccs := B.Units.My.OfType(B.U.UnitAliases.For(terran.CommandCenter)...)
			if B.BruteForce {
				return scl.MinInt(4, ccs.Len())
			}
			return scl.MinInt(4, ccs.Len()+1)
		},
		Active: func() int {
			return 2
		},
	},
	{
		Name:    "Engineering Bay",
		Ability: ability.Build_EngineeringBay,
		Premise: func() bool {
			if B.CcAfterRax || B.CcBeforeRax {
				return B.Units.My.OfType(B.U.UnitAliases.For(terran.Factory)...).First(scl.Ready) != nil
			}
			return B.Units.My.OfType(B.U.UnitAliases.For(terran.CommandCenter)...).Filter(scl.Ready).Len() >= 2
		},
		Limit:  BuildOne,
		Active: BuildOne,
	},
	{
		Name:    "Missile Turrets",
		Ability: ability.Build_MissileTurret,
		Premise: func() bool {
			return B.BuildTurrets
		},
		Limit:  func() int { return B.TurretsPos.Len() },
		Active: func() int { return B.TurretsPos.Len() },
	},
	{
		Name:    "Barracks techlabs",
		Ability: ability.Build_TechLab_Barracks,
		Premise: func() bool {
			ccs := B.Units.My.OfType(B.U.UnitAliases.For(terran.CommandCenter)...).Filter(scl.Ready)
			rax := B.Units.My[terran.Barracks].First(scl.Ready, scl.NoAddon, scl.Idle)
			return ccs.Len() >= 2 &&
				((B.Vespene >= 100 && rax != nil && B.Enemies.Visible.CloserThan(SafeBuildRange, rax).Empty()) ||
					B.Units.My[terran.BarracksFlying].First() != nil)
		},
		Limit: func() int {
			return B.Units.My.OfType(B.U.UnitAliases.For(terran.Barracks)...).Len() - 1
		},
		Active: BuildOne,
		Method: func() {
			if rax := B.Units.My[terran.BarracksFlying].First(); rax != nil {
				rax.CommandPos(ability.Build_TechLab_Barracks, B.FirstBarrack[1])
				return
			}

			raxes := B.Units.My[terran.Barracks]
			rax := raxes.First(scl.Ready, scl.NoAddon, scl.Idle)
			if B.BruteForce || raxes.Len() >= 3 {
				rax.Command(ability.Build_TechLab_Barracks)
				return
			}
			if rax.IsCloserThan(3, B.FirstBarrack[0]) {
				if B.FirstBarrack[0] != B.FirstBarrack[1] {
					if B.Enemies.Visible.CloserThan(SafeBuildRange, rax).Exists() {
						return
					}
					rax.Command(ability.Lift_Barracks)
				} else {
					rax.Command(ability.Build_TechLab_Barracks)
				}
			}
		},
	},
	{
		Name:    "Barracks reactors",
		Ability: ability.Build_Reactor_Barracks,
		Premise: func() bool {
			ccs := B.Units.My.OfType(B.U.UnitAliases.For(terran.CommandCenter)...).Filter(scl.Ready)
			rax := B.Units.My[terran.Barracks].First(scl.Ready, scl.NoAddon, scl.Idle)
			return ccs.Len() >= 2 && (rax != nil) && B.Enemies.Visible.CloserThan(SafeBuildRange, rax).Empty()
		},
		Limit:  BuildOne,
		Active: BuildOne,
		Method: func() {
			rax := B.Units.My[terran.Barracks].First(scl.Ready, scl.NoAddon, scl.Idle)
			if rax.IsCloserThan(3, B.FirstBarrack[0]) {
				return
			}
			rax.Command(ability.Build_Reactor_Barracks)
		},
	},
}
View Source
var RootBuildOrder = BuildNodes{

	{
		Name:    "Expansion CCs",
		Ability: ability.Build_CommandCenter,
		Premise: func() bool {
			return B.Enemies.All.Filter(scl.DpsGt5).CloserThan(B.DefensiveRange, B.Locs.MyStart).Empty()
		},
		Limit: func() int {
			if B.CcAfterRax || B.CcBeforeRax {
				return 2
			}
			if B.BruteForce && B.Loop < scl.TimeToLoop(2, 40) {
				return 0
			}
			if B.Loop < scl.TimeToLoop(2, 0) {
				return 1
			} else if B.Loop < scl.TimeToLoop(4, 0) {
				return 2
			}
			return B.BuildPos[scl.S5x5].Len()
		},
		Active: func() int { return 1 + B.Minerals/800 },
		WaitRes: func() bool {
			ccs := B.Units.My.OfType(B.U.UnitAliases.For(terran.CommandCenter)...)
			if ccs.Len() <= B.FoodUsed/40 {
				return true
			}
			return false
		},
	},
	{
		Name:    "Supplies",
		Ability: ability.Build_SupplyDepot,
		Premise: func() bool {
			if B.CcAfterRax || B.CcBeforeRax {
				if B.Pending(ability.Train_SCV) < 14 {
					return false
				}
				if B.Units.My.OfType(B.U.UnitAliases.For(terran.SupplyDepot)...).Len() == 1 &&
					(B.Units.My.OfType(B.U.UnitAliases.For(terran.Barracks)...).Empty() ||
						B.Units.My.OfType(B.U.UnitAliases.For(terran.CommandCenter)...).Len() < 2) {
					return false
				}
			}
			return B.FoodLeft < 6+B.FoodUsed/20 && B.FoodCap < 200
		},
		Limit:  func() int { return 30 },
		Active: func() int { return 1 + B.FoodUsed/50 },
	},
	{
		Name:    "First Barrack",
		Ability: ability.Build_Barracks,
		Premise: func() bool {
			ccs := B.Units.My.OfType(B.U.UnitAliases.For(terran.CommandCenter)...)
			if B.CcBeforeRax && ccs.Len() == 1 {
				return false
			}
			return !B.ProxyReapers && !B.ProxyMarines &&
				B.Units.My.OfType(B.U.UnitAliases.For(terran.SupplyDepot)...).First(scl.Ready) != nil &&
				B.Units.My.OfType(B.U.UnitAliases.For(terran.Barracks)...).Empty()
		},
		Limit:  BuildOne,
		Active: BuildOne,
		Method: BuildFirstBarrack,
	},
	{
		Name:    "Proxy Barracks",
		Ability: ability.Build_Barracks,
		Premise: func() bool {
			return (B.ProxyReapers || B.ProxyMarines) &&
				B.Units.My.OfType(B.U.UnitAliases.For(terran.SupplyDepot)...).First(scl.Ready) != nil
		},
		Limit:  func() int { return 2 },
		Active: func() int { return 2 },
		Method: BuildProxyBarrack,
	},
	{
		Name:    "Barracks reactor for brute force",
		Ability: ability.Build_Reactor_Barracks,
		Premise: func() bool {
			rax := B.Units.My[terran.Barracks].First(scl.Ready, scl.NoAddon, scl.Idle)
			return B.BruteForce &&
				((B.Vespene >= 50 && rax != nil && B.Enemies.Visible.CloserThan(SafeBuildRange, rax).Empty()) ||
					B.Units.My[terran.BarracksFlying].First() != nil)
		},
		Limit:  BuildOne,
		Active: BuildOne,
		Method: func() {
			if rax := B.Units.My[terran.BarracksFlying].First(); rax != nil {
				rax.CommandPos(ability.Build_Reactor_Barracks, B.FirstBarrack[1])
				return
			}

			rax := B.Units.My[terran.Barracks].First(scl.Ready, scl.NoAddon, scl.Idle)
			if rax.IsCloserThan(3, B.FirstBarrack[0]) {
				if B.FirstBarrack[0] != B.FirstBarrack[1] {
					if B.Enemies.Visible.CloserThan(SafeBuildRange, rax).Exists() {
						return
					}
					rax.Command(ability.Lift_Barracks)
				} else {
					rax.Command(ability.Build_Reactor_Barracks)
				}
			}
		},
	},
	{
		Name:    "Refinery",
		Ability: ability.Build_Refinery,
		Premise: func() bool {
			if B.WorkerRush {
				return false
			}
			ccs := B.Units.My.OfType(B.U.UnitAliases.For(terran.CommandCenter)...)
			if (B.CcBeforeRax || B.CcAfterRax) && ccs.Len() == 1 {
				return false
			}
			if B.Vespene < B.Minerals*2 {
				raxPending := B.Pending(ability.Build_Barracks)
				refPending := B.Pending(ability.Build_Refinery)
				ccs := B.Units.My.OfType(B.U.UnitAliases.For(terran.CommandCenter)...)
				if raxPending == 0 {
					return false
				}
				if B.Minerals > 350 {
					return true
				}
				if ccs.Len() < 3 {
					return refPending < ccs.Len()+1 || B.BruteForce
				}
				return true
			}
			return false
		},
		Limit: func() int {
			if B.CcBeforeRax {
				ccs := B.Units.My.OfType(B.U.UnitAliases.For(terran.CommandCenter)...).Filter(scl.Ready).Len()
				if ccs == 1 {
					return 1
				}
				if ccs == 2 {
					return 3
				}
			}
			return 20
		},
		Active: func() int {
			ccs := B.Units.My.OfType(B.U.UnitAliases.For(terran.CommandCenter)...).Filter(scl.Ready).Len()
			if (B.CcAfterRax || B.CcBeforeRax) && ccs < 3 {
				return 1
			}
			return 2
		},
		Method: func() {
			ccs := B.Units.My.OfType(terran.CommandCenter, terran.OrbitalCommand, terran.PlanetaryFortress)
			if cc := ccs.First(scl.Ready); cc != nil {
				BuildRefinery(cc)
			}
		},
		Unlocks: RaxBuildOrder,
	},
	{
		Name:    "Factory",
		Ability: ability.Build_Factory,
		Premise: func() bool {
			if B.Units.My.OfType(B.U.UnitAliases.For(terran.Factory)...).Len() >= 1 && B.Minerals <= 400 {
				return false
			}
			if B.Minerals > 800 {
				return true
			}
			return B.Units.My[terran.Factory].First(scl.Ready, scl.Unused) == nil
		},
		Limit: func() int {
			buildFacts := B.Units.My.OfType(B.U.UnitAliases.For(terran.CommandCenter)...).Filter(scl.Ready).Len()
			if B.EnemyRace == api.Race_Zerg && buildFacts > 1 {
				buildFacts--
			}
			starports := B.Units.My.OfType(B.U.UnitAliases.For(terran.Starport)...).Len()
			return scl.MinInt(4, scl.MinInt(buildFacts, starports+1))
		},
		Active:  BuildOne,
		Unlocks: FactoryBuildOrder,
	},
	{
		Name:    "Starport",
		Ability: ability.Build_Starport,
		Premise: func() bool {
			if B.Units.My.OfType(B.U.UnitAliases.For(terran.Starport)...).Len() >= 1 && B.Minerals <= 400 {
				return false
			}
			if B.Minerals > 800 {
				return true
			}
			return B.Units.My[terran.Starport].First(scl.Ready, scl.Unused) == nil
		},
		Limit: func() int {
			ccs := B.Units.My.OfType(B.U.UnitAliases.For(terran.CommandCenter)...).Filter(scl.Ready).Len()
			factories := B.Units.My.OfType(B.U.UnitAliases.For(terran.Factory)...).Len()
			return scl.MinInt(4, scl.MinInt(ccs, factories+1))
		},
		Active:  BuildOne,
		Unlocks: StarportBuildOrder,
	},
}
View Source
var StarportBuildOrder = BuildNodes{
	{
		Name:    "Starport Tech Lab",
		Ability: ability.Build_TechLab_Starport,
		Premise: func() bool {
			if B.BruteForce && B.Pending(ability.Train_Medivac) == 0 {
				return false
			}
			starport := B.Units.My[terran.Starport].First(scl.Ready, scl.NoAddon, scl.Idle)
			return (starport != nil) && B.Enemies.Visible.CloserThan(SafeBuildRange, starport).Empty()
		},
		Limit: func() int {
			allStarports := B.Units.My.OfType(B.U.UnitAliases.For(terran.Starport)...)
			if allStarports.Len() == 1 {
				return 1
			}
			return allStarports.Len()
		},
		Active: BuildOne,
		Method: func() {
			B.Units.My[terran.Starport].First(scl.Ready, scl.NoAddon, scl.Idle).Command(ability.Build_TechLab_Starport)
		},
	},

	{
		Name:    "Fusion Core",
		Ability: ability.Build_FusionCore,
		Premise: func() bool {
			return B.Units.My[terran.Raven].Exists() && B.Units.My[terran.Starport].Filter(scl.Ready).Len() >= 2
		},
		Limit:  BuildOne,
		Active: BuildOne,
	},
}

Functions

func Build

func Build(aid api.AbilityID) point.Point

func BuildFirstBarrack

func BuildFirstBarrack()

func BuildOne

func BuildOne() int

func BuildProxyBarrack

func BuildProxyBarrack()

func BuildRefinery

func BuildRefinery(cc *scl.Unit)

func Cast

func Cast()

func Cheeze

func Cheeze()

func GetFactory

func GetFactory(id api.UnitTypeID, needTechlab bool, usedFactories scl.TagsMap) *scl.Unit

func Macro

func Macro(b *bot.Bot)

func Morph

func Morph()

func NormalizeScore

func NormalizeScore(score map[api.AbilityID]int, a api.AbilityID, qty, defQty int)

func Order

func Order(unit api.AbilityID, factoryType api.UnitTypeID, needTechlab, gatherMoney bool, usedFactories scl.TagsMap)

func OrderBuild

func OrderBuild(scv *scl.Unit, pos point.Point, aid api.AbilityID)

func OrderTrain

func OrderTrain(factory *scl.Unit, aid api.AbilityID, usedFactories scl.TagsMap)

func OrderUnits

func OrderUnits()

func OrderUpgrades

func OrderUpgrades()

func ProcessBuildOrder

func ProcessBuildOrder(buildOrder BuildNodes)

func ReserveSCVs

func ReserveSCVs()

func TrainScv

func TrainScv()

func Yes

func Yes() bool

Types

type Booler

type Booler func() bool

type BuildNode

type BuildNode struct {
	Name    string
	Ability api.AbilityID
	Premise Booler
	WaitRes Booler
	Limit   Inter
	Active  Inter
	Method  Voider
	Unlocks BuildNodes
}

type BuildNodes

type BuildNodes []BuildNode

type Inter

type Inter func() int

type Voider

type Voider func()

Jump to

Keyboard shortcuts

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