You are on page 1of 3

InitBrains:

Set the team to CKH (default)

RunBrains:
If this event is MINERLocationChanged or ResourceLocationChanged
Call UpdateLocation
Call UpdateTargets
Calculate the adjacent squares to the targets
End if

QueryTargetMINER:
If WhichMINER is 0
Return the primary target
Else
Return the secondary target
End if

QueryTargetDestination:
If WhichMINER is the primary MINER
Return the primary destination
Else
Return the secondary destination
End if

QueryAdjacentSquare:
If the primary MINER location is known
Return the primary MINER location
Else if the secondary MINER location is known
Return the secondary MINER location
Else
Query the current TRACTOR location
Return a square adjacent to the TRACTOR location
End if

QueryMinerLocation:
Return the location of the MINER of interest

QueryIsOptimal:
Return true if the current position of the MINERs is optimal

SetMyTeam:
If MyTeam is CKH
Set MyMINER and TheirMINER appropriately
Set MyExclusiveResource and TheirExclusiveResource
Else
Set MyMINER and TheirMINER appropriately
Set MyExclusiveResource and TheirExclusiveResource
End if

UpdateLocations:
Query the current TRACTOR location
Query the MINER locations from the SPUD
Query the resource locations from the SPUD
Update the registry of which MINER is in each resource square
Update team exclusive resource locations

UpdateTarget:
Set IsOptimal to false
Try to occupy our exclusive resource with one of our MINERs
(ImplementFirstGoal)
If ImplmentFirstGoal returned false
If our scoring MINER is the primary one
If secondary MINER is already scoring
Set IsOptimal to true
Else
Primary target is our secondary MINER
Primary destination is Neutral 1
End if
Else
If primary MINER is already scoring
Set IsOptimal to true
Else
Primary target is our primary MINER
Primary destination is Neutral 1
End if
End if
Secondary target is their primary MINER
Secondary destination is an unoccupied corner
End if
If the target MINER has changed and IsOptimal is false
Post TargetMinerChanged to MasterSM
End if
Set last target MINERs to current target MINERs
If the target destinations has changed and IsOptimal is false
Post TargetDestinationChanged to MasterSM
End if
Set last target destinations to current target destinations

ImplementFirstGoal:
If MyExclusiveResource is empty
Primary target MINER is my primary MINER
Secondary target MINER is my secondary MINER
Primary target destination is MyExclusiveResource
Secondary target destination is MyExclusiveResource
Return true
Else if there is one MINER on MyExclusiveResource
If that MINER is an enemy MINER
Primary target MINER is that enemy MINER
Secondary target MINER is my primary MINER
Primary target destination is an unoccupied corner
square
Secondary target destination is MyExclusiveResource
Return true
End if
Else (there are multiple MINERs on our square)
If the first MINER on the square is an enemy MINER
Primary target MINER is that enemy MINER
Secondary target MINER is my primary MINER
Primary target destination is an unoccupied corner
square
Secondary target destination is MyExclusiveResource
Else if the second MINER on the square is an enemy MINER
Primary target MINER is that enemy MINER
Secondary target MINER is my primary MINER
Primary target destination is an unoccupied corner
square
Secondary target destination is MyExclusiveResource
Else
Primary target MINER is my primary MINER
Secondary target MINER is my secondary MINER
Primary target destination is Neutral 1
Secondary target destination is Neutral 1
End if
Return true
End if
Return false

You might also like