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

Use the internal unit statistics #6129

Draft
wants to merge 2 commits into
base: deploy/fafdevelop
Choose a base branch
from

Conversation

Garanas
Copy link
Member

@Garanas Garanas commented Apr 27, 2024

Description of the proposed changes

Remove the tracking of unit statistics. They are unnecessary as the engine tracks the same information.

Testing done on the proposed changes

Launch a game using 2badd41 and compare the results when you exit. You should see something like this in your logs:

INFO: 1	uel0001	0	->	nil -- killed
INFO: 1	uel0001	1	->	nil -- created
INFO: 1	uel0001	1	->	1   -- still alive
INFO: 1	uea0303	0	->	nil
INFO: 1	uea0303	8	->	8
INFO: 1	uea0303	3	->	3
INFO: 1	uel0401	0	->	nil
INFO: 1	uel0401	1	->	1
INFO: 1	uel0401	0	->	nil
INFO: 2	ual0001	0	->	nil
INFO: 2	ual0001	1	->	nil
INFO: 2	ual0001	1	->	1
INFO: 2	uel0001	1	->	1
INFO: 2	uel0001	0	->	nil
INFO: 2	uel0001	0	->	nil
INFO: 2	uea0303	1	->	1
INFO: 2	uea0303	0	->	nil
INFO: 2	uea0303	0	->	nil
INFO: 3	ual0001	1	->	1
INFO: 3	ual0001	0	->	nil
INFO: 3	ual0001	0	->	nil
INFO: 3	xsl0001	1	->	1
INFO: 3	xsl0001	0	->	nil
INFO: 3	xsl0001	0	->	nil
INFO: 3	ura0303	0	->	nil
INFO: 3	ura0303	7	->	7
INFO: 3	ura0303	2	->	2
INFO: 3	xsa0303	7	->	7
INFO: 3	xsa0303	0	->	nil
INFO: 3	xsa0303	0	->	nil
INFO: 3	url0402	0	->	nil
INFO: 3	url0402	1	->	1
INFO: 3	url0402	0	->	nil
INFO: 3	xrl0403	0	->	nil
INFO: 3	xrl0403	1	->	1
INFO: 3	xrl0403	0	->	nil
INFO: 3	xsl0401	2	->	2
INFO: 3	xsl0401	0	->	nil
INFO: 3	xsl0401	0	->	nil
INFO: 4	xsl0001	0	->	nil
INFO: 4	xsl0001	1	->	nil
INFO: 4	xsl0001	1	->	1
INFO: 4	ura0303	2	->	2
INFO: 4	ura0303	0	->	nil
INFO: 4	ura0303	0	->	nil
INFO: 4	uea0303	2	->	2
INFO: 4	uea0303	0	->	nil
INFO: 4	uea0303	0	->	nil
INFO: 4	xsa0303	0	->	2
INFO: 4	xsa0303	6	->	6
INFO: 4	xsa0303	6	->	9
INFO: 4	xsl0401	0	->	nil
INFO: 4	xsl0401	0	->	nil
INFO: 4	xsl0401	0	->	2

Additional context

This was introduced 8 years ago in 06690e0. The use of JSON instead of XML is fine, but it appears the introduction of this logic to track the status quo of units was not necessary.

Checklist

  • Changes are annotated, including comments where useful
  • Changes are documented in the changelog for the next game version
  • Keep support for the 'lowest health' ACU achievement

@Garanas Garanas added the feature: achievements related to the achievements that people can achieve in the client label Apr 27, 2024
@Garanas
Copy link
Member Author

Garanas commented Apr 27, 2024

@relent0r / @maudlin27 These brain functions may also be interesting to you as an AI developer. They make it trivial for you to retrieve various interesting properties. And the properties in question appear to be cached, so it's not re-computed as you go.

For example, these statistics are available:

        LOG("Units_BeingBuilt: ", repr(self.Brain:GetBlueprintStat('Units_BeingBuilt', categories.TECH3)))
        LOG("Units_History: ", repr(self.Brain:GetBlueprintStat('Units_History', categories.ALLUNITS)))
        LOG("Enemies_Killed: ", repr(self.Brain:GetBlueprintStat('Enemies_Killed', categories.ALLUNITS)))
        LOG("Enemies_Lost: ", repr(self.Brain:GetBlueprintStat('Enemies_Lost', categories.ALLUNITS)))
        LOG("Units_TotalDamageDealt: ", repr(self.Brain:GetBlueprintStat('Units_TotalDamageDealt', categories.ALLUNITS)))
        LOG("Units_TotalDamageReceive: ", repr(self.Brain:GetBlueprintStat('Units_TotalDamageReceive', categories.ALLUNITS)))

Example output:

INFO: Units_BeingBuilt: 	1
INFO: Units_History: 	186
INFO: Enemies_Killed: 	15
INFO: Enemies_Lost: 	0
INFO: Units_TotalDamageDealt: 	47671
INFO: Units_TotalDamageReceive: 	77500

@Garanas Garanas marked this pull request as draft April 27, 2024 15:49
@Garanas
Copy link
Member Author

Garanas commented May 12, 2024

@relent0r I noticed that your AI makes use of the unit data that is stored in the brain. Are you aware of the engine alternatives that allow you to gather data based on categories, for example?

@Garanas
Copy link
Member Author

Garanas commented May 12, 2024

@lL1l1 what are your thoughts on replacing the Lua-based statistics tracking with the engine-based statistics tracking? It feels more cohesive and reduces the Lua overhead, even if it is just a little bit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: achievements related to the achievements that people can achieve in the client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant