- Joined
- Mar 27, 2012
- Messages
- 3,232
NOTE: I have not begun writing the system. I'm only designing it atm and will not start progress on any actual code before the design is solid.
I'm in the process of designing an AI API that could be used both for unit-specific AIs and player-specific ones.
The structure of the system is as follows:
*Each unit and player can have a list of programs.
*Each program has a list of routines, which represent program functionalities. It is perfectly fine to have routines that handle the entirety of a program, but the system is designed to allow recombination of functionality in case someone needs it.(I do)
*The system periodically iterates over all registered units and players, running the programs that are referenced to them.
*The program can iterate in 3 ways:
**Rate - A specific amount of units is checked per tick. (scales well, but the reaction time per unit/player can get sluggish)
**Ratio - A factor of all currently registered units is checked per tick. (scales fairly evenly with number of units and keeps the reaction delay somewhat consistent)
**Total - Every unit is checked every single tick.(scales poorly, but provides a 100% consistent delay)
*Each program can return either true or false. If a program returns true, all subsequent programs on that unit/player are skipped this iteration. (can be toggled off in configuration)
How the system works:
Periodically, all units registered to the system are iterated over.
The programs on each unit are run and the iteration stops if any of them returns true(can be disabled in configuration).
The programs are user-defined and as such, their exact implementation is not handled by the system. The system does handle their registration and running though.
CreateProgram
RegisterRoutine - Creates a new routine type. A routine has some code, which may include calls to subroutines.
CreateRoutine
ProgramAddRoutine
ProgramRemoveRoutine
DestroyRoutine
UnitAddProgram
UnitRemoveProgram
PlayerAddProgram
PlayerRemoveProgram
DestroyProgram
IsUnitIdle(unit)
Checks if the unit currently has any orders other than "stop"
IsUnitIdleCondition - Doesn't take a unit as argument.
Instead assumes that the unit is the one currently running programs
Meant for use along with the If routine
UnitHasProgram
ProgramHasRoutine
GetProgramIterations - Returns the amount of programs that have returned true on this unit in this tick.
PauseProgram - Makes the system skip this program indefinitely
ResumeProgram
PauseUnitPrograms - Makes the system indefinitely skip all programs on this unit
ResumeUnitPrograms
PausePlayerPrograms
UnitRunProgram - Runs a specific program on a unit. Intended to be used with event-based programs.
ProgramRunRoutine - Runs a specific routine. Intended to be used from inside a routine to implement subroutines.
PlayerRunProgram
ResumePlayerPrograms
SetUnitSkip(bool)
SetPlayerSkip(bool)
Predefined routines:
If
*Takes two routines and a condition
*If condition is true, runs the first routine
*Otherwise runs the second routine
Why I am posting this:
*To estimate how much use such a system would have.
*To fix design mistakes without having to redesign the system halfway.
*To get feedback on what features would be desired in addition to the ones listed.
*To open up the field of WC3 AI by providing some insights into how things can be done.
*Because I intend to write this system, even if for myself.(duh)
I'm in the process of designing an AI API that could be used both for unit-specific AIs and player-specific ones.
The structure of the system is as follows:
*Each unit and player can have a list of programs.
*Each program has a list of routines, which represent program functionalities. It is perfectly fine to have routines that handle the entirety of a program, but the system is designed to allow recombination of functionality in case someone needs it.(I do)
*The system periodically iterates over all registered units and players, running the programs that are referenced to them.
*The program can iterate in 3 ways:
**Rate - A specific amount of units is checked per tick. (scales well, but the reaction time per unit/player can get sluggish)
**Ratio - A factor of all currently registered units is checked per tick. (scales fairly evenly with number of units and keeps the reaction delay somewhat consistent)
**Total - Every unit is checked every single tick.(scales poorly, but provides a 100% consistent delay)
*Each program can return either true or false. If a program returns true, all subsequent programs on that unit/player are skipped this iteration. (can be toggled off in configuration)
How the system works:
Periodically, all units registered to the system are iterated over.
The programs on each unit are run and the iteration stops if any of them returns true(can be disabled in configuration).
The programs are user-defined and as such, their exact implementation is not handled by the system. The system does handle their registration and running though.
CreateProgram
RegisterRoutine - Creates a new routine type. A routine has some code, which may include calls to subroutines.
CreateRoutine
ProgramAddRoutine
ProgramRemoveRoutine
DestroyRoutine
UnitAddProgram
UnitRemoveProgram
PlayerAddProgram
PlayerRemoveProgram
DestroyProgram
IsUnitIdle(unit)
Checks if the unit currently has any orders other than "stop"
IsUnitIdleCondition - Doesn't take a unit as argument.
Instead assumes that the unit is the one currently running programs
Meant for use along with the If routine
UnitHasProgram
ProgramHasRoutine
GetProgramIterations - Returns the amount of programs that have returned true on this unit in this tick.
PauseProgram - Makes the system skip this program indefinitely
ResumeProgram
PauseUnitPrograms - Makes the system indefinitely skip all programs on this unit
ResumeUnitPrograms
PausePlayerPrograms
UnitRunProgram - Runs a specific program on a unit. Intended to be used with event-based programs.
ProgramRunRoutine - Runs a specific routine. Intended to be used from inside a routine to implement subroutines.
PlayerRunProgram
ResumePlayerPrograms
SetUnitSkip(bool)
SetPlayerSkip(bool)
Predefined routines:
If
*Takes two routines and a condition
*If condition is true, runs the first routine
*Otherwise runs the second routine
Why I am posting this:
*To estimate how much use such a system would have.
*To fix design mistakes without having to redesign the system halfway.
*To get feedback on what features would be desired in addition to the ones listed.
*To open up the field of WC3 AI by providing some insights into how things can be done.
*Because I intend to write this system, even if for myself.(duh)