Skip to content

Conversation

@danfireman
Copy link
Contributor

@danfireman danfireman commented Mar 7, 2023

TODO:

  • Refactor and move files to AI folder
  • Consider current E plus under construction E
  • Make mexers in proportion to how many remaining empty mexespots there are and current E production
  • Move "build close to" to lib
  • No duplicate pylons
  • gridders should separate
  • Don't make things close enough to chainsplode
  • terraform pylon spots when needed

Copy link
Member

@sprunk sprunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loose thoughts from briefly skimming the file

Comment on lines +1947 to +1949
local minEffectiveDist = 9999999
local bestPylon = -1
local bestPylonRange = -1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave nil if there's no good value; also use math.huge:

Suggested change
local minEffectiveDist = 9999999
local bestPylon = -1
local bestPylonRange = -1
local minEffectiveDist = math.huge
local bestPylon
local bestPylonRange

local minEffectiveDist = 9999999
local bestPylon = -1
local bestPylonRange = -1
for _, gridPylonData in ipairs(gridMates) do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer a normal loop over ipairs (much faster):

Suggested change
for _, gridPylonData in ipairs(gridMates) do
for i = 1, #gridMates do
local gridPylonData = gridMates[i]

Comment on lines +791 to +793
function GG.SetPriorityState(unitID, state)
SetPriorityState(unitID, state, CMD_PRIORITY)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the use of this func should be replaced by some sort of Spring.GiveOrderToUnit(unitId, CMD_PRIORITY, state, 0)

Comment on lines +621 to +623
if not gadgetHandler:IsSyncedCode() then
return
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The synced code check should be at the very top of the gadget.

------------------------------------------------------------
-- Debug
------------------------------------------------------------
local function printThing(theKey, theTable, indent)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's something like Spring.Utilities.TableEcho (or maybe EchoTable?), use it

Comment on lines +146 to +148
if next(teamdata) == nil then
initializeTeams()
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would ideally be done once, likely in Initialize, instead of in half the callins

end
end
end
if frame%5 then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This produces a number so is always a truthy value.

Comment on lines +547 to +549
spGiveOrderToUnit(unitId, -conjurerDefID, {}, {})
spGiveOrderToUnit(unitId, 115, {1}, {}) -- repeat build
spGiveOrderToUnit(unitId, 34220, {0}, {}) -- priority low
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer named order constants over magic numbers, table-less parameters when there's a single one, and numerical command options:

Suggested change
spGiveOrderToUnit(unitId, -conjurerDefID, {}, {})
spGiveOrderToUnit(unitId, 115, {1}, {}) -- repeat build
spGiveOrderToUnit(unitId, 34220, {0}, {}) -- priority low
spGiveOrderToUnit(unitId, -conjurerDefID, 0, 0)
spGiveOrderToUnit(unitId, CMD.REPEAT, 1, 0) -- repeat build
spGiveOrderToUnit(unitId, CMD_PRIORITY, 0, 0) -- priority low

Comment on lines +553 to +557
if current > 200 then
spGiveOrderToUnit(unitId, 13921, {1}, {})
else
spGiveOrderToUnit(unitId, 13921, {0}, {})
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto:

Suggested change
if current > 200 then
spGiveOrderToUnit(unitId, 13921, {1}, {})
else
spGiveOrderToUnit(unitId, 13921, {0}, {})
end
spGiveOrderToUnit(unitId, CMD_FACTORY_GUARD, current > 200 and 1 or 0, 0)


local function updateRoleList(teamData)
for unitId,role in pairs(teamData.conRoles) do
if spGetUnitIsDead ( unitId ) == nil then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like this belongs in gadget:UnitDestroyed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants