I will try and take a look at it this week. Since I have been poking
around with
my own AI again recently, it shouldn't be too difficult for me to
figure out how best to fix this. I think that there is more than just
the Ambush that can cause the location to be different from the target
location. The current AI does use the returned location (if != the
target) to update its information, so that will need to be handled
properly.
John
On 2/12/07, Jörg Hinrichs <[EMAIL PROTECTED]> wrote:
Hi all,
I experienced another OOS recently while playing a game and i took the
opportunity to investigate. Here is what i found out:
What happens:
The ai has 2 units that it wants to move. The first is ambushed. The second
doesn't consider this and tries to move beyond the ambusher.
The reason:
Normally ai moves are recalculated if ambush occurs. But ambush is not being
detected right. It is done by comparing the actual location (after moving)
to the planned destination. If they differ, the unit was ambushed. This
however does not work, if the unit is being ambushed on the very last hex of
its way. Which happened in that game.
How to fix it:
This is the reason i am writing this mail. I can see several ways to deal
with the problem but i don't like most of them. And i am not so familiar
with the ai code so i would like someone else to jump in here. The problem
is located in ai_interface::move_unit_partial, ai_interface::move_unit,
ai::move_group and ai::move_to_targets. They return the location where the
unit moved to but no reliable information if it was ambushed.
1.
We could add another bool parameter to these methods. I don't like that much
because we then have two return values, a "real" one and an output
parameter. Not really intuitive.
2.
We could add the ambush information to the return value by making a
structure or something out of it, that contains the location and the bool.
Doesn't look very elegant to me either.
3.
We could use a global variable for this. Urgh. Don't like that.
4.
If (and only if) the return location is just used for detecting ambush, we
could change it to a bool and everything is fine. This is very promising but
i don't feel comfortable in judging it since i know little to nothing about
that part of the code.
There might be more solutions i didn't even think of. Feel free to elaborate
on this. As i said, i can implement a solution but i would appreciate
someone else to take care of this.
Greetings
Yogi
_______________________________________________
Wesnoth-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-dev
--
-------------------------------------------------------------------
"In theory, theory and practice are the same,
but in practice they're different."
-------------------------------------------------------------------
John W. C. McNabb
-------------------------------------------------------------------
_______________________________________________
Wesnoth-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-dev