Author Topic: [fixed] The AI starves its units  (Read 1500 times)

Manric

  • Guest
[fixed] The AI starves its units
« on: 5 January 2013, 18:35:03 »
Problem: At some point in a game, a CPU-controlled faction suffers a massive death of units (usually all workers, being the ones with the weakest HP).

Comment: This has proved to be a problem rather difficult to reproduce. It happens only on long-duration games with few battles, when the AI is able to produce a lot of units while suffering little loss. I built a map to that effect and made tests with many factions, with this result:
Factions affected by this problem:
From Megapack, Egypt and Persian.
Non-megapack, Japanese and Elves.

Diagnose: The cause seem to be the units consuming more than 1 food. In the case of Elves, a particularly hungry faction, it is very easy to observe this mass death. On the other hand, take a “safe” faction like Tech and modify some of its units to need 2 food instead of 1. Then it will not be long before its workers suffer the same fate. Apparently the AI calculates food production counting the number of units, not the real food needs.
« Last Edit: 16 January 2013, 13:47:44 by tomreyn »

tomreyn

  • Local Moderator
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Re: [fixed] The AI starves its units
« Reply #1 on: 5 January 2013, 18:57:58 »
I've also observed this, but never had a good explanation for it. Yours sounds reasonable to me.
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

-Archmage-

  • Moderator
  • Dragon
  • ********
  • Posts: 5,887
  • Make it so.
    • View Profile
    • My Website
Re: [fixed] The AI starves its units
« Reply #2 on: 5 January 2013, 20:01:56 »
We're sort of fixing the Megapack up.... and Elves is kinda my baby now... It could use to much work though.
Egypt Remastered!

Proof: Owner of glest@mail.com

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: [fixed] The AI starves its units
« Reply #3 on: 9 January 2013, 19:18:05 »
Currently the AI is hard coded to want a minimum of 20 static resources. This can be ovverriden by the work i did to allow telling a faction how the AI should behave in another post here: https://forum.megaglest.org/index.php?topic=8202.msg81414#msg81414

I will look into making this more intelligent by default.

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: [fixed] The AI starves its units
« Reply #4 on: 12 January 2013, 01:14:01 »
Starting with svn rev#: 4015 the AI will harvest sooner to avoid this problem. Please test and let me know how well they behave in this condition.

Manric

  • Guest
Re: [fixed] The AI starves its units
« Reply #5 on: 13 January 2013, 10:01:48 »
@softcoder : Thank you for your answer. I downloaded rev.4019 and ran tests using Elves, the worst-offending faction (in food need terms), in a game environment of frantic production and no battles. It didn't go well. The poor guys perished after some time, just as before the change.
However, I would not worry any more with this issue. I originally placed this post in the bugs section because technically it is one, but in practical terms it is more of a curio. You can play hundreds of games without ever encountering this problem. I only came across it because I like to experiment with factions and the AI, placing them in extreme situations just for the fun of watching what happens.

tomreyn

  • Local Moderator
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Re: [fixed] The AI starves its units
« Reply #6 on: 13 January 2013, 20:33:29 »
I've tagged this thread not a bug since it's the modders' responsibility to provide information on how much food a faction needs to produce. The engine can only go so far as to make a guess and to react quickly when there is a problem.
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

Manric

  • Guest
Re: [fixed] The AI starves its units
« Reply #7 on: 14 January 2013, 08:35:53 »
I've tagged this thread not a bug since it's the modders' responsibility to provide information on how much food a faction needs to produce. The engine can only go so far as to make a guess and to react quickly when there is a problem.

I must confess that I do not understand what you mean here. Where should the modder place this information about food? If you are thinking of setting options thru <ai-behavior>, I can tell you that I tried this as well, with no success.
Otherwise, I agree in that this food shortage is not properly a bug, since it does not show under normal conditions. It only happens under an extreme stress of overpopulation.

tomreyn

  • Local Moderator
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Re: [fixed] The AI starves its units
« Reply #8 on: 16 January 2013, 03:56:45 »
<ai-behavior> is indeed what I had in mind. If this doesn't work as espected (what have you tried, what was the actual result?) then this would actually make this a bug I'd say.
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

Manric

  • Guest
Re: [fixed] The AI starves its units
« Reply #9 on: 16 January 2013, 08:28:53 »
Following Softcoder advice:

Currently the AI is hard coded to want a minimum of 20 static resources. This can be ovverriden by the work i did to allow telling a faction how the AI should behave in another post here: https://forum.megaglest.org/index.php?topic=8202.msg81414#msg81414

I tried this change of minimum resources:
          <static type-name="MinStaticResourceCount" value="90"/>
It had no effect, and I put it down to food being a consumable, not a static resource. Then I thought of setting a minimum food-producing building count, but this is a tricky proposition. If it is set too low, it is of little use; if too high (say, 20 buildings), the faction's development is seriously hampered. On the whole, it is better to let the AI take its own decisions.

tomreyn

  • Local Moderator
  • Airship
  • ********
  • Posts: 2,764
    • View Profile
    • MegaGlest - the free and open source cross platform 3D real-time strategy game
Re: [fixed] The AI starves its units
« Reply #10 on: 20 June 2013, 12:45:07 »
Bug triage question: Is this considered to be by design, should it be considered fixed due to the change made, or do the developers consider this to need another improvement?

Thanks.
atibox: Ryzen 1800X (8 cores @3.6GHz), 32 GB RAM, MSI Radeon RX 580 Gaming X 8G, PCI subsystem ID [1462:3417], (Radeon RX 580 chipset, POLARIS10) @3440x1440; latest stable Ubuntu release, (open source) radeon (amdgpu) / mesa video driver
atibox (old): Core2Quad Q9400 (4 cores @2.66GHz), 8 GB RAM, XFX HD-467X-DDF2, PCI subsystem ID [1682:2931], (Radeon HD 4670, RV730 XT) @1680x1050; latest stable Ubuntu release, (open source) radeon / mesa video driver
notebook: HP envy13d020ng
internet access: VDSL2+

· · · How YOU can contribute to MG · Latest development snapshot · How to build yourself · Megapack techtree · Currently hosted MG games · · ·

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
Re: [fixed] The AI starves its units
« Reply #11 on: 20 June 2013, 14:20:48 »
I think the starving issues is resolved now. How the AI resolves it is another issue.