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

Add an initial setup for the AI base chunk manager #6677

Draft
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

Garanas
Copy link
Member

@Garanas Garanas commented Feb 27, 2025

Description of the proposed changes

Continuation of #6674

Revisits the base chunk format to be easier to use. Introduces a small base chunk manager that we'll use in the near future to load in the base chunks of an AI. It is a brain component, therefore existing AIs can add the component and then load in the chunks that they find relevant.

Testing done on the proposed changes

The following:

image

Is turned into:

-- Count per type:
-- - categories.DIRECTFIRE: 1
-- - categories.WALL: 36
-- - categories.FACTORY: 1
-- - categories.ANTIAIR: 1
-- - categories.ENERGYPRODUCTION: 4


-- Count per tech:
-- - categories.TECH1: 43,

BaseChunk = {
  Size = 16,
  BuildingSites = {
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 1.000000, OffsetZ = 13.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.ENERGYPRODUCTION, OffsetX = 3.000000, OffsetZ = 11.000000, Size = 2.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 15.000000, OffsetZ = 10.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.DIRECTFIRE, OffsetX = 14.000000, OffsetZ = 14.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 15.000000, OffsetZ = 9.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 1.000000, OffsetZ = 11.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.ENERGYPRODUCTION, OffsetX = 9.000000, OffsetZ = 11.000000, Size = 2.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.ENERGYPRODUCTION, OffsetX = 7.000000, OffsetZ = 11.000000, Size = 2.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.ENERGYPRODUCTION, OffsetX = 5.000000, OffsetZ = 11.000000, Size = 2.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 8.000000, OffsetZ = 1.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 9.000000, OffsetZ = 1.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 7.000000, OffsetZ = 1.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 1.000000, OffsetZ = 10.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 1.000000, OffsetZ = 12.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 15.000000, OffsetZ = 15.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 10.000000, OffsetZ = 1.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.FACTORY, OffsetX = 6.000000, OffsetZ = 6.000000, Size = 8.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 2.000000, OffsetZ = 1.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 3.000000, OffsetZ = 1.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.ANTIAIR, OffsetX = 14.000000, OffsetZ = 9.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 14.000000, OffsetZ = 15.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 15.000000, OffsetZ = 8.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 13.000000, OffsetZ = 15.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 6.000000, OffsetZ = 1.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 5.000000, OffsetZ = 1.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 4.000000, OffsetZ = 1.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 15.000000, OffsetZ = 14.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 15.000000, OffsetZ = 13.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 2.000000, OffsetZ = 13.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 8.000000, OffsetZ = 15.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 9.000000, OffsetZ = 15.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 6.000000, OffsetZ = 15.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 4.000000, OffsetZ = 13.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 3.000000, OffsetZ = 13.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 2.000000, OffsetZ = 15.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 4.000000, OffsetZ = 15.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 11.000000, OffsetZ = 15.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 12.000000, OffsetZ = 15.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 1.000000, OffsetZ = 15.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 5.000000, OffsetZ = 15.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 3.000000, OffsetZ = 15.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 7.000000, OffsetZ = 15.000000, Size = 1.000000 },
      { TypePreference = categories.TECH1, TechPreference = categories.WALL, OffsetX = 10.000000, OffsetZ = 15.000000, Size = 1.000000 },
    },
}

Additional context

Also introduces a utility function to convert a base chunk into a regular build template. This will be used in the future to debug the loaded base chunks 😄 !

Checklist

  • Changes are annotated, including comments where useful
  • Changes are documented in the changelog for the next game version

@github-actions github-actions bot marked this pull request as draft February 27, 2025 15:06
@relent0r
Copy link
Contributor

This looks good.

A couple of things that popped into my head.

How could we make it easier to include adjacency information in the chunk? having a reference to adjacent sites so an AI could say build a factory here, what sites are adjacent to that? That would make adjacency much easier to figure out since they would instantly know what was available and what sizes they are so for example an AI would know if it wanted to build a t3 artillery what sites would be required to fully power it with t3 pgens. It would also help when it comes to reclaiming site positions since the AI would understand the preferred priority as it shifts tiers.

The front facing edge, which you mentioned could be simply set by the cursor position when the template is created.

Black listed positions. Which would not be something the chunk would include pre game, but having a data table for it, would be important at usage time. The AI can identify resource points and blacklist those positions when I chunk is queried. But that sounds very complex to get right when it comes to adaptive maps or something strange like crazy rush.
Would also be important when a team mate goes and builds structures within a chunk.
This has other use cases that the AI could determine in game through its own logic.

Can it have multiple TypePreferences for an offset? e.g If I have a TypePreference of TECH3, would I be able to still put a TECH1 unit there if the same size (obviously factories come to mind). Or would we be looking to use different chunk templates instead? I guess that would depend on what is recorded when an AI uses one to start building somewhere.

Template BIAS. Being able to say that a template has a bias category, simply front/rear from a start position. Not sure how to easily capture that. But being able to identify a chunk that we want to use at the rear of a base rather than the front of the base and vice versa. The AI can determine the direction of front and back in game.

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