Author Topic: Weird handling of AI base goals  (Read 834 times)

0 Members and 1 Guest are viewing this topic.

Offline scient

Weird handling of AI base goals
« on: February 06, 2021, 03:32:42 AM »
While working through validating and cleaning up some draft code, I started working on base_mark(). It gets called near the end of the function that handles the creation of a base using the new base id as the parameter. It is also called in a loop against all existing bases after a base is removed from the game. Most of it is pretty straight forward. It sets the base radius and using flags for nearby map tiles. It also clears the map site value. I don't fully understand the nuances between sites and goals yet but they basically tie into AI priorities. The last part of the code stuck out to me when I first decompiled it. The call to del_site() is using the last radius coordinates. This is unusual since most of the code I've worked on uses these radius coordinates in a loop similar to the one above it. This is the first time I've seen these type of radius coordinates used outside a loop like this.

So why does this matter? That last bit of code is attempting to clear any AI goals for building bases near the newly created base (see del_site() for more details). What happens with the original code is that because it's using the radius loop coordinates, it's only clearing these goals on the left side of where the base is created. It won't even clear a goal that's one tile to the right of the newly built base. So you could end up in a situation where the AI really, really wants to build a base next to another base even when that's not possible. This could mess with AI base planning.

It was hard for me to picture this in my head so I made a visual aid in a test game.

Here are a set of colonize goals prior to building a base in the middle:


Here are the same goals after the base is built using the original code. Note only the left side is cleared.


Lastly, here is an outline for the various base_mark changes. The right greenish square is where the base is built. The left greenish square would be where the x_radius/y_radius coordinates use as the focal point. The yellowish area is where the colonize goals are cleared. The pinkish area is where the base radius and using flags are set on the map. The bluish area is where the the map site value is set to 0 which includes the left greenish focal point square.


I wanted to open this up to discussion on how people think this should work and whether they've observed clustering or odd base building behavior by the AI that could be explained by this code. I highly doubt this was the original intent. There are a couple ways I think this could be fixed. One could be to only clear the goals inside the blueish area by using the base x and y coordinates as the focal point. Another would be to tweak the existing code to mirror how it clears the area on the left side to the other three quadrants. I'm just not sure if this might make the AI build bases too far apart. This might be something that would need to be an experimental build change for testing how it affects the AI.

Offline scient

Re: Weird handling of AI base goals
« Reply #1 on: February 06, 2021, 06:24:04 AM »
It looks like there is another area of code that ends up clearing sites/goals for tiles that have base radius flag set. So it's not nearly as bad as having zombie goals in the immediate squares of the new base. There is a delay with refreshing the UI display. Still doesn't explain the other weird behavior.

Offline bvanevery

  • Emperor of the Tanks
  • Thinker
  • *
  • Posts: 6370
  • €659
  • View Inventory
  • Send /Gift
  • Allows access to AC2's quiz & chess sections for 144 hours from time of use.  You can't do without Leadship  Must. have. caffeine. -Ahhhhh; good.  Premium environmentally-responsible coffee, grown with love and care by Gaian experts.  
  • Planning for the next 20 years of SMACX.
  • AC2 Hall Of Fame AC Text modder Author of at least one AAR
    • View Profile
    • Awards
Re: Weird handling of AI base goals
« Reply #2 on: February 07, 2021, 07:20:29 AM »
I admire your fortitude in reverse engineering such AI behaviors!  However I also think it's game production suicide to go down these roads.  Makes me think I should be getting back to my programming language project, so that I can take forever before writing such errors from scratch.   ;lol

 

* User

Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Select language:

* Community poll

SMAC v.4 SMAX v.2 (or previous versions)
-=-
24 (7%)
XP Compatibility patch
-=-
9 (2%)
Gog version for Windows
-=-
103 (32%)
Scient (unofficial) patch
-=-
40 (12%)
Kyrub's latest patch
-=-
14 (4%)
Yitzi's latest patch
-=-
89 (28%)
AC for Mac
-=-
3 (0%)
AC for Linux
-=-
6 (1%)
Gog version for Mac
-=-
10 (3%)
No patch
-=-
16 (5%)
Total Members Voted: 314
AC2 Wiki Logo
-click pic for wik-

* Random quote

The sea... vast, mysterious... and full of wealth! And the nations of Planet send their trade across it without a thought. Well, the sea doesn't care about them, so it lets them pass. But we can give the sea a little hand in teaching the landlubbers a lesson in humility.
~Captain Ulrik Svensgaard 'The Ripple and the Wave'

* Select your theme

*
Templates: 5: index (default), PortaMx/Mainindex (default), PortaMx/Frames (default), Display (default), GenericControls (default).
Sub templates: 8: init, html_above, body_above, portamx_above, main, portamx_below, body_below, html_below.
Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
Style sheets: 0: .
Files included: 45 - 1228KB. (show)
Queries used: 38.

[Show Queries]