Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3097 closed defect (fixed)

Whale always moving to the right side of the map on Cycladic Archipelago

Reported by: elexis Owned by: Itms
Priority: Must Have Milestone: Alpha 19
Component: Core engine Keywords: pathfinding
Cc: Patch:

Description

When playing the random map Cycladic Archipelago, one can notice that most of the whale instantaneously decides to move to the right side of the map. After 2-4 minutes of gametime usually all whale has gathered in this area, giving players on those islands a huge food advantage, since

(a) whale has 2000 food (instead of 1000 for regular fish) (b) fishboats have 2 times faster gathering speed in comparison to women on fields (c) players on the left side have less fish, since the whale run away.

Attachments (1)

ticket3097_reduce_whale_roaming_distance.patch (1.4 KB ) - added by elexis 9 years ago.
Reduces roaming distance to 32, adds TODO to the roaming function in UnitAI.js. FleeDistance reduced too for consistency.

Download all attachments as: .zip

Change History (10)

comment:1 by elexis, 9 years ago

It does not seem to be an issue with the random map script, as the whale's starting positions seem to be random. Test with huge map size, 8 players and revealed map.

I suspected the roaming functionality defined in MoveRandomly in binaries/data/mods/public/simulation/components/UnitAI.js and added debug output to find out if the random direction chosen is really random. It seems to be... I will investigate further.

comment:2 by elexis, 9 years ago

The "Fin Whale" on the custom skirmish map Northern Island http://wildfiregames.com/forum/index.php?showtopic=19653 also shows this behaviour.

There are no islands blocking it, they swim straight to the right side of the map. Eventually when they bump into something they will go to the left for some short amount of time, but soon after 1 or 2 seconds they decide to get back to the right side. This problem happens in real life too with beached whales. Lets help those poor animals...

comment:3 by sanderd17, 9 years ago

The random walk is implemented as such: The unit is asked to move to a circle a certain distance (the roaming distance) away from its current position. It's the same thing that happens when you task an archer to attack something.

This code makes sure that random units don't get stuck in certain obstructed things. The code normally makes that they go for the more open planes.

Now, as it seems to work for other fauna, it's a question why it doesn't work for whales.

First of all, there's a difference in environment. Oceans generally don't have a lot of obstructions, so the preffered way should be random there.

Then there's the fact that a whale is always moving, while other fauna is grazing a lot. This could mean that the whale is closer to a certain point in the circle, and that the position in the circle isn't chosen randomly.

There's also the possibility of the distance influencing it. A whale has a roaming distance of 60 (I guess that's expressed in tiles, but it could be meters too), while most other fauna has a roaming distance of 8.

I think experimenting with the RoamTimeMin, RoamTimeMax and RoamDistance might give a more satisfactory result.

If that doesn't help, we must assume that the function is always biased, and that deer luckily walk too slow to notice them drifting to a side.

comment:4 by elexis, 9 years ago

Obviously a good test map is water without any islands and some whales. Also I suggest to edit binaries/data/mods/public/simulation/data/game_speeds.sjon and set Insane Speed to 50.

If you change the RoamDistance to 34, the whale still moves to the right very quickly. Putting this value to 33 or less the issue doesn't appear any more (at least not in 2 hours of gametime).

comment:5 by wraitii, 9 years ago

I suspect this has something to do with the "circle" behavior on smaller maps, it's probably always picking the first point on the right in those situations or something.

Moving the RoamDistance to 32 sounds like a good enough fix to me, perhaps also add a comment to the function itself that values higher than 33 seem to bug and TODO change it :P

Nice detective work anyhow.

Last edited 9 years ago by wraitii (previous) (diff)

by elexis, 9 years ago

Reduces roaming distance to 32, adds TODO to the roaming function in UnitAI.js. FleeDistance reduced too for consistency.

comment:6 by elexis, 9 years ago

Keywords: review added
Priority: Should HaveMust Have
Summary: Whale always moving to the right side of the map on Cycladic Archipelago[PATCH] Whale always moving to the right side of the map on Cycladic Archipelago

comment:7 by Itms, 9 years ago

Keywords: pathfinding added; review removed
Summary: [PATCH] Whale always moving to the right side of the map on Cycladic ArchipelagoWhale always moving to the right side of the map on Cycladic Archipelago

Funnily enough, this doesn't happen with the new pathfinder, so the problem came from MoveToPointRange but I don't know which change fixed that!

Consider it fixed ;)

comment:8 by Itms, 9 years ago

Owner: set to Itms
Resolution: fixed
Status: newclosed

In 16751:

New long-range pathfinder.

Based on Philip's work located at http://git.wildfiregames.com/gitweb/?p=0ad.git;a=shortlog;h=refs/heads/projects/philip/pathfinder
Includes code by wraitii, sanderd17 and kanetaka.

An updated version of docs/pathfinder.pdf describing the changes in detail will be committed ASAP.

Running update-workspaces is needed after this change.

Fixes #1756.
Fixes #930, #1259, #2908, #2960, #3097
Refs #1200, #1914, #1942, #2568, #2132, #2563

comment:9 by elexis, 9 years ago

Works, thanks helping the stranded whale!

Note: See TracTickets for help on using tickets.