Regenerating 1 Fuel Bug

Describe your experience with the latest version of FreeOrion to help us improve it.

Moderator: Oberlus

Forum rules
Always mention the exact version of FreeOrion you are testing.

When reporting an issue regarding the AI, if possible provide the relevant AI log file and a save game file that demonstrates the issue.
Post Reply
Message
Author
Daybreak
Vacuum Dragon
Posts: 641
Joined: Mon Aug 13, 2018 10:14 pm

Regenerating 1 Fuel Bug

#1 Post by Daybreak »

As first reported by Wobbly
When regenerating fuel, after you reach 1 fuel from 0.90 fuel, you are still unable to jump one starlane.

This seems to only occur in MP games

MP21
Turn 79 to 80

Here we have the ship which has just regenerated fule form 0.9 to 1'
b
1FuelTurn79_2022-10-03 18_58_41-Window.png
1FuelTurn79_2022-10-03 18_58_41-Window.png (33.25 KiB) Viewed 1011 times
After exiting game ad re-entering game, we can see the ship now poised to move, but path has dissapeared.
b
1FuelTurn79No_Path_2022-10-03 19_03_19-Window.png
1FuelTurn79No_Path_2022-10-03 19_03_19-Window.png (30.55 KiB) Viewed 1011 times
and here on turn 80, we can see the ship did not move, ans now has 1.1 fuel
b
1FuelBugTurn80_2022-10-04 06_51_28-Window.png
1FuelBugTurn80_2022-10-04 06_51_28-Window.png (19.02 KiB) Viewed 1011 times
Thoughts are -
Daybreak wrote: Thu Sep 29, 2022 11:17 am I wonder if there is a rounding error of some type on the fuel, so although it reads 1 fuel, it is only 0.99 fuel- just throwing this out there, but it is a total guess based on what may be happening.
Oberlus wrote: Thu Sep 29, 2022 11:43 am That was and still is my first bet, some rounding inconsistencies plus a bug in the code base: e.g. the client thinks 1.00, the server thinks 0.99, the order is sent and (the real bug) the ship is set to "travelling", the server doesn't move the ship (because not enough fuel: 0.99<1.0), following turns the ship is stuck because it can no longer refuel (it is a travelling ship outside of supply, so no +0.1 per turn or anything).

wobbly
Cosmic Dragon
Posts: 1873
Joined: Thu Oct 10, 2013 6:48 pm

Re: Regenerating 1 Fuel Bug

#2 Post by wobbly »

Probably time to open a github issue. I'm at work. I'll open 1 when I get home if no one opens 1 by then.

User avatar
Grummel7
Space Dragon
Posts: 335
Joined: Mon Oct 09, 2017 3:44 pm

Re: Regenerating 1 Fuel Bug

#3 Post by Grummel7 »

The fact that the client shows 1.00 does not mean it thinks it is exactly that. Internally it probably has something like 0,99999982, and in this case the client may even show 1.0 and still tell you the move is not possible. The only effect of multi-player should have here is that server and client may run on different platforms and have different precision.

If it is a rounding issue, there should be easy fix:
Change the basic fuel increase from 0.1 to something like 0.10001. Players will never see the extra fuel, but it should make sure that rounding is always done in favor of the ship.

wobbly
Cosmic Dragon
Posts: 1873
Joined: Thu Oct 10, 2013 6:48 pm

Re: Regenerating 1 Fuel Bug

#4 Post by wobbly »

Grummel7 wrote: Tue Oct 04, 2022 7:20 pm Change the basic fuel increase from 0.1 to something like 0.10001. Players will never see the extra fuel, but it should make sure that rounding is always done in favor of the ship.
Its already like that in the scripting

User avatar
LienRag
Cosmic Dragon
Posts: 2146
Joined: Fri May 17, 2019 5:03 pm

Re: Regenerating 1 Fuel Bug

#5 Post by LienRag »

But how can it be 0,99999 or something when it goes up by steps of at minimum 0,1 and goes down by steps of 1 ?

User avatar
Grummel7
Space Dragon
Posts: 335
Joined: Mon Oct 09, 2017 3:44 pm

Re: Regenerating 1 Fuel Bug

#6 Post by Grummel7 »

LienRag wrote: Tue Oct 04, 2022 7:37 pm But how can it be 0,99999 or something when it goes up by steps of at minimum 0,1 and goes down by steps of 1 ?
Well, that is basic computer science: 0.1 cannot be encoded exactly as a floating point value, it has to be encoded as something slightly less or more then 0.1, neither can 0.2. And there is no guarantee that float(0.1) + float(0.1) == float(0.2). That's rounding issues.

User avatar
Grummel7
Space Dragon
Posts: 335
Joined: Mon Oct 09, 2017 3:44 pm

Re: Regenerating 1 Fuel Bug

#7 Post by Grummel7 »

wobbly wrote: Tue Oct 04, 2022 7:30 pm Its already like that in the scripting
Indeed, I didn't know that...
But that means it cannot be a rounding issue!

Post Reply