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

Improves the harvester AI. #778

Conversation

Rampastring
Copy link
Member

@Rampastring Rampastring commented Apr 21, 2022

Closes #201, Closes #202, Closes #203

NOTE This implementation has been noted to cause sync errors when manually ordering harvesters to enter refineries. I'll fix the implementation later.

This pull request implements 3 features to significantly improve the harvester AI:

  • The harvester's refinery-seeking algorithm now considers both free refineries and occupied refineries when figuring out which refinery to unload at. If the closest occupied refinery is much closer to the harvester than the closest free refinery, the harvester queues for the occipied refinery instead of going for the free refinery.

  • If a refinery is reserved for a harvester that is far away and a nearby harvester is seeking for a refinery to unload to, the nearby harvester takes the far-away harvester's place in the refinery queue. This feature is also known as "queue jumping" as coined by cfehunter in his mod for TD Remastered that he has since taken down.

  • In vanilla TS, harvesters always go for the northernmost tiberium patch if there is one. This means that on some starting locations, harvesters tend to move just further and further away from your refinery as they harvest, because on each cycle they just go further and further to the north. On other starting locations this behaviour, on the other hand, is usually beneficial (if your refineries are to the north of a tiberium field). This creates a bad imbalance for most maps. Instead of having fixed preferred directions for the tiberium-seeking algorithm, harvesters now pick the most valuable patch that's also closest to their last refinery. This keeps the resources flowing faster, keeps your harvesters safe and levels the playing field between different starting locations.

These features are also explained in the following issues:

#201
#202
#203

Rules.ini settings

To allow customizing the behaviour of these features, this PR adds the following Rules.ini keys, section [General]:

; When looking for refineries, harvesters will prefer a distant free
; refinery over a closer occupied refinery if the refineries' distance
; difference in cells is less than this.
MaxFreeRefineryDistanceBias=<int> ; defaults to 16

; If a refinery is already occupied by a returning harvester and another
; harvester is also looking to dock, allow the new harvester to take over
; the refinery if the difference in distance to the refinery between
; the existing harvester and the new harvester is at least this many cells.
MinHarvesterQueueJumpDistance=<int> ; defaults to 7

@github-actions
Copy link

github-actions bot commented Apr 21, 2022

This comment is automaticly generated by Nightly.link and allows non-registered users to get download the artifacts for this pull request.

These links are also updated when the pull request is pushed to.

@Rampastring Rampastring changed the title Improves harvester AI. #201, #202 and #203 Closes #201, closes #202, closes #203: improves harvester AI. Apr 21, 2022
@CCHyper CCHyper changed the title Closes #201, closes #202, closes #203: improves harvester AI. Improves the harvester AI. Apr 21, 2022
… and Vinifera-Developers#203

Implements smarter harvester refinery-seeking algorithm. Vinifera-Developers#201

Implements harvester refinery queue jumping. Vinifera-Developers#202

Adds patch to make harvesters consider distance to refinery when selecting tiberium patch to harvest. Vinifera-Developers#203
@CCHyper CCHyper force-pushed the develop branch 2 times, most recently from 07c9446 to 379970b Compare November 9, 2022 14:53
@Rampastring Rampastring changed the title Improves the harvester AI. Draft: Improves the harvester AI. Dec 3, 2022
@Rampastring Rampastring marked this pull request as draft December 3, 2022 02:07
@Rampastring Rampastring changed the title Draft: Improves the harvester AI. Improves the harvester AI. Dec 3, 2022
@Rampastring Rampastring closed this Dec 3, 2022
@Rampastring Rampastring deleted the improved-harvester-ai branch December 3, 2022 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant