URL:
  <http://gna.org/bugs/?13218>

                 Summary: infinite loop in the AI if it persistently tries to
move unit to occupied square
                 Project: Battle for Wesnoth
            Submitted by: crab
            Submitted on: Thursday 03/19/2009 at 07:51
                Category: Bug
                Severity: 4 - Important
                Priority: 5 - Normal
              Item Group: Artificial Intelligence
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: r33849
        Operating System: Debian GNU/Linu

    _______________________________________________________

Details:

How-to-reproduce:

start multiplayer\local game
use map 2p-Caves of the Basilisk,
options: Unlimited turns, village gold 2, exp mod 50%, 
0=use map settings, 1=observers, 0=time limit

two players:
#1 (me): loyalists\lieutenant
#2 (default ai): drakes\drake flare
[or download attached save]
do nothing for two turns. Wesnoth hangs.
See the screenshot to understand what the AI tries to do - it tries to return
leader to nearest keep, but it is already occupied.

in  ai::move_unit ( src/ai.cpp:704 ) , unit will not be moved if the
destination square is not empty (which is reasonable), and  ai::move_unit
will return 'from' to tell that no move was done. but,
formula_ai::execute_variant (src/formula_ai.cpp:1904) ignores that return
value and instead checks 'is the destination square now occupied'. Therefore,
if the AI persistently tries to move unit from A to occupied B (in my case, AI
tried to return leader to the starting keep), it will get in a nice infinite
loop, since it is 'it doesn't make a move and yet returns true' situation. 
--

the solution is two-fold. 
Firstly, formula_ai::execute_variant (in src/formula_ai.cpp) must be modified
to check the return value of ai::move_unit (see the attached patch). Wesnoth
will not hang anymore, but the AI will sit still and try to repeat this move
each turn.

Secondly, the AI must be changed to avoid moves to occupied squares.




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Thursday 03/19/2009 at 07:51  Name: formula_ai.patch  Size: 1kB   By:
crab

<http://gna.org/bugs/download.php?file_id=5453>
-------------------------------------------------------
Date: Thursday 03/19/2009 at 07:51  Name: bug1.gz  Size: 28kB   By: crab

<http://gna.org/bugs/download.php?file_id=5454>

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?13218>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs

Reply via email to