bugBos Wars - Bugs: bug #30994, Make AI work with naval units

 
 

bug #30994: Make AI work with naval units

Submitted by:  Michiel van der Wulp <mvw>
Submitted on:  Wed 08 Sep 2010 06:32:09 AM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: FixedPrivacy: Public
Assigned to: Kalle Olavi Niemitalo <kon>Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Sun 21 Nov 2010 12:17:46 PM UTC, comment #10:

After r9979, file #21413 no longer applies to trunk. And I think it was never needed anyway. Thus closing this bug.

Kalle Olavi Niemitalo <kon>
Project MemberIn charge of this item.
Sun 19 Sep 2010 12:23:57 PM UTC, comment #9:

I applied my patches (file #21433 and file #21494) in r9961 and r9962. Your file #21413 is not in yet.

Kalle Olavi Niemitalo <kon>
Project MemberIn charge of this item.
Sun 19 Sep 2010 08:07:23 AM UTC, comment #8:

The attached patch should let the destroyers attack. Please apply this after file #21433. I added many assertions; I hope they won't fail in some corner case.

(file #21494)

Kalle Olavi Niemitalo <kon>
Project MemberIn charge of this item.
Sat 18 Sep 2010 10:44:39 PM UTC, comment #7:

The destroyers do not attack because the AI does not find a path to any enemy unit. That happens because unit-destroyer is 2x2 tiles and, when the pathfinder is checking whether the unit could move one step to the north for example, it finds that two of the four tiles at that position are already reserved... by the unit itself! If you set TileSize = {1, 1} in units/destroyer/unit-destroyer.lua, then it will attack.

The other mobile units with large TileSize are unit-bomber and unit-jet. If you made a force using only those, that would hit the same bug, I think. The bug is not specific to naval units.

Some other parts of the engine use UnmarkUnitFieldFlags and MarkUnitFieldFlags to temporarily unreserve the tiles for the duration of pathfinding; the same should be done here, but I'm not sure what would be the appropriate place for that in all these layers of functions.

Kalle Olavi Niemitalo <kon>
Project MemberIn charge of this item.
Thu 16 Sep 2010 12:52:58 PM UTC, comment #6:

Hi Kalle,

Same result with your latest patch - the shipyard is built, and destroyers constructed, but they do not attack...

Regards

Michiel van der Wulp <mvw>
Project Member
Sat 11 Sep 2010 03:05:52 PM UTC, comment #5:

Hi Kalle,

The first version of your patch made the AI construct the shipyard. I only tested this shortly - more later hopefully.

The shipyard then constructed destroyers, but they did not attack - I will investigate this later.

I will also try your latest patch.

I attached the missing patches to patch 7263.

Michiel van der Wulp <mvw>
Project Member
Sat 11 Sep 2010 11:47:50 AM UTC, comment #4:

File #21414 (overpopulation-B-03.map.zip) uses some of the graphics that are missing from patch #7263.

engine/stratagus/iolib.cpp:403: File `patches/goshgeom/terrain4056.png' not found
Can't open file: No such file or directory
Can't load the graphic `patches/goshgeom/terrain4056.png'

Kalle Olavi Niemitalo <kon>
Project MemberIn charge of this item.
Sat 11 Sep 2010 08:16:04 AM UTC, comment #3:

Second version of the patch for engine/ai/ai_building.cpp.

(file #21433)

Kalle Olavi Niemitalo <kon>
Project MemberIn charge of this item.
Fri 10 Sep 2010 11:37:43 PM UTC, comment #2:

I fixed the assertion failure of comment #1 in r9949, I think.
The attached patch should let the AI find places for shipyards; but it's well past midnight here so I won't be testing it now.
On scripts/ai.lua, I hope Feb will apply your patch.

(file #21429)

Kalle Olavi Niemitalo <kon>
Project MemberIn charge of this item.
Wed 08 Sep 2010 06:42:47 AM UTC, comment #1:

One more comment:
When running in debug mode, boswars gives the following message:

engine/ai/ai_building.cpp:337: Want to build a unit-shipyard(Shipyard)
Assertion failed at engine/unit/build.cpp:234: xMin + type->TileWidth < Map.Info.MapWidth
Aborted

Michiel van der Wulp <mvw>
Project Member
Wed 08 Sep 2010 06:32:09 AM UTC, original submission:

I am trying to make an AI script that is able to use naval units for attack. This does not work yet, due to different reasons. All tests done with the svn version of yesterday.

1. We need to apply the following patch to scripts/ai.lua - see attachment "NavalAI-01.patch". This patch makes it possible for an engineer to build a unit-shipyard, and for a shipyard to train both naval units, and for an engineer to repair the shipyard.

2. To test this behaviour, I am experimenting with a new map. See attachment "overpopulation-B-03.map.zip". Please do not yet commit this map to the core Boswars - it is not yet finished. This map is based on the goshgeom patchset - see another ticket of me at https://savannah.nongnu.org/patch/?7263.
Start the game, and watch what the enemy is doing: it works correctly through the AI, but when it is time to build a shipyard, the engineers just stand there. The debugging printouts on the commandline show where we are stuck (just count the functions).

3. Hence, the remaining problem I am not able to solve myself: The AI is still not able to pass the line "function() return AiWait("unit-shipyard") end," in the example map, see the "naval.lua" file in that map.

I do not know why, but my guess is that the algorithm to find an empty spot to build a building does not cope with a shipyard, which needs a combination of sea and land (or coast) tiles.
Please help!

Michiel van der Wulp <mvw>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #21494:  0002-Unmark-unit-field-flags-for-pathfinder-calls.patch added by kon (6KiB - text/x-patch - [PATCHv2 2/2] Unmark unit field flags for pathfinder calls)
file #21433:  0001-Help-the-AI-find-places-to-build-shipyards.patch added by kon (6KiB - text/x-patch - [PATCHv2] Help the AI find places to build shipyards)
file #21429:  0001-Help-the-AI-find-places-to-build-shipyards.patch added by kon (7KiB - text/x-patch - [PATCH] Help the AI find places to build shipyards)
file #21413:  NavalAI-01.patch added by mvw (1KiB - text/x-patch)
file #21414:  overpopulation-B-03.map.zip added by mvw (6KiB - application/zip)

 

Digest:
   patch dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by feb (Updated the item)
  • -unavailable- added by kon (Updated the item)
  • -unavailable- added by mvw (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 11 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 21 Nov 2010 12:17:46 PM UTCkonStatusPatch available=>Fixed
      Assigned tofeb=>kon
      Open/ClosedOpen=>Closed
    Sun 17 Oct 2010 08:13:52 PM UTCfebAssigned toNone=>feb
    Sun 19 Sep 2010 08:07:23 AM UTCkonAttached File-=>Added 0002-Unmark-unit-field-flags-for-pathfinder-calls.patch, #21494
    Sat 11 Sep 2010 01:20:45 PM UTCkonStatusNone=>Patch available
    Sat 11 Sep 2010 11:47:50 AM UTCkonDependencies-=>Depends on patch #7263
    Sat 11 Sep 2010 08:16:04 AM UTCkonAttached File-=>Added 0001-Help-the-AI-find-places-to-build-shipyards.patch, #21433
    Fri 10 Sep 2010 11:37:43 PM UTCkonAttached File-=>Added 0001-Help-the-AI-find-places-to-build-shipyards.patch, #21429
    Wed 08 Sep 2010 06:32:10 AM UTCmvwAttached File-=>Added NavalAI-01.patch, #21413
      Attached File-=>Added overpopulation-B-03.map.zip, #21414

    Back to the top


    Powered by Savane 3.1-cleanup1