Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-implement the Easy AI pt. 1 #4858

Merged
merged 46 commits into from
May 4, 2023
Merged

Conversation

Garanas
Copy link
Member

@Garanas Garanas commented Apr 4, 2023

Brain

Doubles-down on the new idea of having separate brain classes. Each brain class can load in the datastructures / files that it requires. The start of this can be found in lua/aibrains/easy-ai.lua, where the easy AI tells the game to:

  • Generate the navigational mesh
  • Generate expansion markers
  • Retrieve a reference to the reclaim grid
  • Create an instance of the recon grid
  • Create an instance of the brain grid

And soon more to follow. These data structures are built to simplify all sorts of queries into simple, low-complexity operations. As a result they can be queried many times over without you having to worry about performance problems.

Introduces the OnBeginSession event which triggers after all props, resources and (initial) units exist.

Navigational mesh

Introduces various new utility functions that work seamlessly with the navigational mesh. They can be found in lua/sim/NavUtils.lua, as a summary:

  • DirectionsFrom computes all directions one can take from a given layer / position. Returns a list of vectors that represent the locations you can navigate to. Accepts a length parameter so that all distances are at an equal length from the position. Useful to generate rally points or to generate a series of directions a platoon can navigate towards to

image

  • RandomDirectionFrom similar to DirectionsFrom but instead of returning a table of waypoints it returns one at random.

  • RetreatDirectionFrom returns a random retreat direction given a layer, position and a threat that you wish to retreat from. The direction is choosen randomly, in the future this may change.

  • DirectionTo similar to PathTo but instead of returning a table of waypoints it returns the next waypoint at a given length. This is a basic approach to 'smoothing' the path and it guarantees that each waypoint is of a certain length from the origin.

Platoons

Introduces a new platoon framework, including one example: the simple raid platoon. The new framework does not rely on callbacks. It can directly interact with unit events. This is not only more efficient but it also gives us as a developer more control packed in better code style.

@Garanas Garanas added area: sim Area that is affected by the Simulation of the Game area: AI related to AI functions labels Apr 4, 2023
@Garanas Garanas added this to the Development iteration II milestone Apr 4, 2023
@Garanas Garanas marked this pull request as draft April 4, 2023 19:17
@Garanas Garanas changed the title Refactor engineer manager Re-implement the Easy AI Apr 9, 2023
@Garanas
Copy link
Member Author

Garanas commented Apr 22, 2023

Using the new function (renamed to GetDirections) we can generate rally point markers, marked in red:

image

Similar, but marked in white:

image

image

image

@Garanas
Copy link
Member Author

Garanas commented Apr 24, 2023

@relent0r introduced a basic silo behavior. You can enable the behavior through this hotkey:

image

All selected units are assigned to the platoon that manages (tactical) silo's. You can find the file here:

  • lua/aibrains/platoons/platoon-silo.lua

This resembles a very basic platoon: the moment the silo is done building it triggers the platoon to start scanning for targets. It will scan for targets and pick one randomly. The scanning thread stops when it runs out of ammo, just to be triggered again when the silo is done building the next missile

basic-silo-platoon.mp4

The behavior is very basic, it could be improved in a thousand ways:

  • Keep track of the same target until it is destroyed
  • Keep track of TMD or shields by using the missile intercept events
  • Keep track of other (allied) launchers and combine their volleys

But the idea was to show an initial basic platoon! I'll create another platoon that resembles the HuntAI behavior of the original platoon functions

@Garanas
Copy link
Member Author

Garanas commented Apr 24, 2023

Adjusted the silo behavior so that it supports multiple launchers:

basic-silo-platoon-02.mp4

@Garanas Garanas changed the title Re-implement the Easy AI Re-implement the Easy AI pt. 1 May 4, 2023
@Garanas Garanas marked this pull request as ready for review May 4, 2023 11:59
@Garanas Garanas merged commit f66c76e into deploy/fafdevelop May 4, 2023
2 checks passed
@Garanas Garanas deleted the refactor/engineer-manager branch May 4, 2023 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: AI related to AI functions area: sim Area that is affected by the Simulation of the Game
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant