Author Topic: [FIXED] Zigzag?  (Read 3887 times)

Offline Ethereal

  • Commander
  • *****
  • Posts: 684
    • View Profile
[FIXED] Zigzag?
« on: April 10, 2024, 09:23:30 am »
Meridian, What did you do that caused the units to zigzag as they run?  How to get rid of this?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9093
    • View Profile
Re: Zigzag?
« Reply #1 on: April 10, 2024, 09:51:11 am »
Meridian, What did you do that caused the units to zigzag as they run?  How to get rid of this?

You really believe I can do anything based on this description?

I don't see units zigzagging...

...if you want me to have a look at this, provide some actual evidence please:
- OXCE version number
- mod version number
- save game
- which unit should I look at (or a short video?)
- etc.
« Last Edit: April 10, 2024, 09:53:49 am by Meridian »

Offline Ethereal

  • Commander
  • *****
  • Posts: 684
    • View Profile
Re: Zigzag?
« Reply #2 on: April 10, 2024, 11:43:17 am »
OXCE 7.11.
I can’t provide a save because the current version of TFTU is very different from the public one and there is no English translation for it. Translation is in progress... a very slow progress.

I mean running with the "control" key. Sometimes units will begin to zigzag, especially when the movement is not strictly in a straight line, or the tiles between the start and end point of the route have different movement costs.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9093
    • View Profile
Re: Zigzag?
« Reply #3 on: April 11, 2024, 11:47:19 pm »
Extracted into a separate thread.

If somebody can provide a video, or a save or any kind of evidence, I'd appreciate it.
(Otherwise I have no idea what this is about.)

Offline Ethereal

  • Commander
  • *****
  • Posts: 684
    • View Profile
Re: Zigzag?
« Reply #4 on: April 12, 2024, 06:30:49 am »
Pure OXCE 7.12, without any modifications.

During normal movement, everything is fine. When running, with the "control" key pressed, the soldier therefore moves to a line lower, instead of walking in a straight line.

Offline CrazedHarpooner

  • Colonel
  • ****
  • Posts: 101
    • View Profile
Re: Zigzag?
« Reply #5 on: April 12, 2024, 01:48:41 pm »
It seems to me that the pathing is trying to use the least TU cost of tiles to decide which is the best running path based on the first two images I'm attaching (000,001) which results in some cases using a zig-zag pattern. Oddly enough if I choose a closer destination within the same path it won't zig-zag (002,003). The last two images are similar to the two first ones but with the destination changed to one tile over to denote the zig-zag pathing. As far as I can tell, the final cost of running to the destination in this particular case is the same for both TUs and energy regarless if you run in zig-zag or if you run in a straight line via shorter 'dashes' so the code decides to always move to a tile with least TU requirements (?), just guessing here.

My only suggestion at this point is, in the cases where more than one path cost exactly the same TU / Energy, pick the path with the least number of diagonal moves.
« Last Edit: April 12, 2024, 02:06:05 pm by CrazedHarpooner »

Offline Ethereal

  • Commander
  • *****
  • Posts: 684
    • View Profile
Re: Zigzag?
« Reply #6 on: April 12, 2024, 02:03:06 pm »
My only suggestion at this point is, in the cases where more than one path cost exactly the same TU / Energy, pick the path with the least number of diagonal moves.

In my opinion this is unnecessary. I don't need additional automation and calculations. I need the return of the original route search and that it be the same along the trajectory for both running and walking.

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Zigzag?
« Reply #7 on: April 12, 2024, 02:04:28 pm »
Short paths do not use complex pathfinding, if there is direct move then game use linear path even if is not optimal.
Long paths try find best move that have minimal cost to reach destination. As we see on screenshot there are objects (grass) on paths that
unit try move. If this grass affect move cost then pathfinding try avoid it as max as possible.

Offline Ethereal

  • Commander
  • *****
  • Posts: 684
    • View Profile
Re: Zigzag?
« Reply #8 on: April 12, 2024, 02:59:21 pm »
Long paths try find best move that have minimal cost to reach destination. As we see on screenshot there are objects (grass) on paths that
unit try move. If this grass affect move cost then pathfinding try avoid it as max as possible.

Is it possible to disable this optimization, or put it into a separate option that could be activated/disabled at will?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9093
    • View Profile
Re: Zigzag?
« Reply #9 on: April 12, 2024, 03:52:39 pm »
This algorithm is implemented since the beginning of OpenXcom.

I will try your save over the weekend to see if there are any unexpected effects/bugs.

But if the behavior in OXCE 7.12 is the same as in the older OXCE versions and in OXC, then it will not be changed (and it will also not be configurable).

(If there is a bug compared to earlier versions, it will of course be fixed.)

Offline psavola

  • Commander
  • *****
  • Posts: 832
    • View Profile
Re: Zigzag?
« Reply #10 on: April 12, 2024, 04:24:11 pm »
I'm not sure if the player should care all that much if the path taken differs slightly from the most direct path.

The issue mostly comes up if you have intentionally or unintentionally (e.g. a knocked out soldier) deployed proxy or other mines and you want to make sure that no-one will be moving next to them. Then the precise path to be taken is of vital importance. Then as a player you'll use path preview and other tools at your disposal to make sure the soldiers won't run into the mines.

In that case as a player I'd be most interested to ensure that path preview and the actual path taken would be the same. If I recall correctly, there have been some cases where the path preview and the actual path have been different, leading to nasty mine explosions.
« Last Edit: April 12, 2024, 04:40:16 pm by psavola »

Offline Ethereal

  • Commander
  • *****
  • Posts: 684
    • View Profile
Re: Zigzag?
« Reply #11 on: April 12, 2024, 05:03:19 pm »
But if the behavior in OXCE 7.12 is the same as in the older OXCE versions and in OXC, then it will not be changed (and it will also not be configurable).

(If there is a bug compared to earlier versions, it will of course be fixed.)

This bug starts with OXCE version 7.6-087f5ca19-2022-07-15. Earlier versions do not have this bug.


Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: Zigzag?
« Reply #12 on: April 12, 2024, 05:19:29 pm »
This is only bug if cost moving in straight line is smaller, if cost is bigger then this is feature as allows unit do more after reaching destination (more TU left to shoot or kneel).

Offline robin

  • Commander
  • *****
  • Posts: 1224
  • ULTIMATE ROOKIE
    • View Profile
Re: Zigzag?
« Reply #13 on: April 12, 2024, 10:27:10 pm »
The tall grass affects movement cost. It is an object-type MCD on top of the floor MCD: the movement cost of the two MCDs stacks (I dare to say that's how it works), meaning higher movement cost on those tiles.
I think the pathfinding is zigzaging to avoid the tall grass to optimize movement cost.

So the pathfinding should be tested on a map with a "pure" floor made of one single MCD (floor-type tiles can have different costs too).

Offline Ethereal

  • Commander
  • *****
  • Posts: 684
    • View Profile
Re: Zigzag?
« Reply #14 on: April 13, 2024, 06:12:10 am »
So the pathfinding should be tested on a map with a "pure" floor made of one single MCD (floor-type tiles can have different costs too).

This is completely unnecessary. I have had cases more than once when, as a result of such zigzags, a soldier came out from behind cover and came under enemy fire. So the formula: where you were sent, you came there along the shortest path, looks preferable to stupid calculations of the cost of movement.

It's like with mountain infantry. Why climb mountains if it’s easier and faster to get around them? But no, they climb and gain a tactical advantage over the enemy, instead of “unexpectedly” bumping their horns into a strong point on the road and unsuccessfully storming it for months.
« Last Edit: April 13, 2024, 06:18:02 am by Ethereal »