euddraft icon indicating copy to clipboard operation
euddraft copied to clipboard

[epScript] Reduce overuse of DoActions in basic actions

Open armoha opened this issue 3 years ago • 1 comments

Copied from https://github.com/phu54321/eudplib/issues/9 and phu54321/epScript#5

function afterTriggerExec() {
  while(Bring(P1, AtLeast, 1, "Zerg Drone", "Anywhere")) {
    MoveLocation("loc", "Zerg Drone", P1, "Anywhere");
    RemoveUnitAt(1, "Zerg Drone", "loc", P1);
    CreateUnit(1, "Zerg Mutalisk", "loc", P1);
  }
}

/* __epspy__ makes 3 Triggers for 3 actions, 2 objects are wasted.
It should use 1 DoActions in a series of actions for performance and map file size.
def afterTriggerExec():
  if EUDWhile()(Bring(P1, AtLeast, 1, "Zerg Drone", "Anywhere")):
    DoActions(MoveLocation("loc", "Zerg Drone", P1, "Anywhere"))
    DoActions(RemoveUnitAt(1, "Zerg Drone", "loc", P1))
    DoActions(CreateUnit(1, "Zerg Mutalisk", "loc", P1))
  EUDEndWhile()
*/

We had partial success on optimizing if block by https://github.com/armoha/eudplib/commit/dfc25694adf33803301ba4f67a47b26d22926817 since euddraft 0.9.3.3. But optimizing trigger actions will improve much more performance than conditions. Unlike conditionals, this is hard to resolve in eudplib so fixing epScript compiler to recognize basic actions to merge would be a way to go.

Stepwise tasks from easiest to hardest one.

  • [ ] Optimize sequence of basic actions with constant arguments.
  • [ ] Optimize basic actions with ConstExpr. (example: var += 1; array[0] = 2; SetMemory(db, SetTo, 3);)
  • [ ] Optimize actions with runtime patch to SeqCompute or VProc if possible.
  • [ ] Optimize custom user-defined actions. It would be impossible to optimize any epScript code which import eudplib module so there should be a way to define and use custom action in epScript.

Related parser rule: https://github.com/armoha/eudplib/blob/855a4e8c97b57f4bb432787ef28f05d77d669287/eudplib/epscript/cpp/parser/epparser.lemon#L1193-L1197

armoha avatar Aug 30 '21 18:08 armoha

epsepseps Still work in progress, buggy as hell :P 🚧 WIP eudplib PR🔗 : https://github.com/armoha/eudplib/pull/1

TODO list

  • [ ] Separate trigger constants (P1, SetTo, CurrentPlayer, Custom, Razings, etc) from TOKEN_NAME.

armoha avatar Aug 31 '21 23:08 armoha