Project

General

Profile

Bug #2781

sleep interruption is a little off (is this an added feature?)

Added by vivec Ae Seht over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Game Mechanics
Target version:
Start date:
07/16/2015
% Done:

100%

Spent time:
Reproducibility:
Always
Operating system:
Linux
Severity:
Minor

Description

resting in wild for 1 hour results in a random encounter 100% of the time for me.
resting for 24 hours seemingly results in random encounters ~20% of the time for me.

I feel this is a little off, as resting longer should increase my chances of running into an enemy, instead of decrease the odds.

However, It feels amazing to be able to spam-train rats/nix hounds so fast (as an alchemy buff, this is quite nice).

I am working on screencapping this as soon as i figure out how to do so on ubuntu linux.

v0.36.0

Associated revisions

Revision c57e72fe (diff)
Added by Jannik Heller over 1 year ago

Adjust the sleep interruption chance (Fixes #2781)

History

#1 Updated by Jannik Heller over 1 year ago

I asked Hrnchamd for comment a few weeks ago. https://wiki.openmw.org/index.php?title=Research:todo

#2 Updated by vivec Ae Seht over 1 year ago

Ahh, I was certain it was off. looks like I was right.

This, to me, almost feels like an improvement, though (minus the fact that sometimes i try to rest to levelup, and it gets interrupted 100% of the time).

what does roll(int) do, though?
is roll the same as (RANDOM % int)?
//(34 % 1) == 0
//if (0 < 0.3)
//due to the type mismatch, if (0 < 0)?

#3 Updated by vivec Ae Seht over 1 year ago

Ahh, I was certain it was off. looks like I was right.

This, to me, almost feels like an improvement, though (minus the fact that sometimes i try to rest to levelup, and it gets interrupted 100% of the time).

what does roll(int) do, though?
is roll the same as (RANDOM % int)?
//(34 % 1) == 0
//if (0 < 0.3)
//due to the type mismatch, if (0 < 0)?

If it is indeed roll(int)=(RANDOM % int), you might be able to fix this by just adding one to this...
roll(int)=(1+(RANDOM % int));
as anything mod 1 is always 0...

#4 Updated by vivec Ae Seht over 1 year ago

Jyby in IRC is helping me diagnose this issue. It seems to be only my computer that is experiencing this issue, or that it is a linux specific issue

Problem still happening in 0.36.git20150804.632~Ubuntu15.04.1

#5 Updated by vivec Ae Seht over 1 year ago

https://www.youtube.com/watch?v=3445waxJooM

video of bug being created. also noting what i had to do to fix it within the game's source code.

#6 Updated by Jeffrey Haines over 1 year ago

  • Status changed from New to Closed
  • Assignee set to Jeffrey Haines

#7 Updated by Jeffrey Haines over 1 year ago

Assisted tester, did not find problem with compiler or code. Worked on his laptop, doesn't work on his linux machine. Ran a test to ensure his linux machine rand(), time, and arithmetic were working correctly. Closed pending more sightings.

#8 Updated by vivec Ae Seht over 1 year ago

issue seems to be related to the openmw-daily PPA for ubuntu.
problem does not exist on https://launchpad.net/~openmw/+archive/ubuntu/openmw

only on https://launchpad.net/~openmw/+archive/ubuntu/openmw-daily

#9 Updated by Denis Smirnov over 1 year ago

vivec Ae Seht wrote:

Jyby in IRC is helping me diagnose this issue. It seems to be only my computer that is experiencing this issue, or that it is a linux specific issue

Seems like it's neither your computer, nor linux, cause I see this issue on my Win7 x64 laptop with one of this week's nightly builds. Every 1-hour sleep is interrupted.

#10 Updated by Jannik Heller over 1 year ago

  • Status changed from Closed to Confirmed
  • Assignee deleted (Jeffrey Haines)

#11 Updated by Jannik Heller over 1 year ago

  • Status changed from Confirmed to Resolved
  • Assignee set to Jannik Heller
  • Target version changed from openmw-0.41 to openmw-0.37
  • % Done changed from 0 to 100

#12 Updated by vivec Ae Seht over 1 year ago

Denis Smirnov wrote:

vivec Ae Seht wrote:

Jyby in IRC is helping me diagnose this issue. It seems to be only my computer that is experiencing this issue, or that it is a linux specific issue

Seems like it's neither your computer, nor linux, cause I see this issue on my Win7 x64 laptop with one of this week's nightly builds. Every 1-hour sleep is interrupted.

oh, so i was right, i even did math and was baffled that no one else was experiencing this issue. it doesn't happen when i install from the openmw ppa, but does happen from source, or the openmw-daily PPA.

https://forum.openmw.org/viewtopic.php?f=6&t=2891&p=34263#p34263
the current formula is almost backwards.

resting 1 hour should either be a 0% chance, or close to it.
resting 24 hours should be 75%->85% chance, going from experience.

with the current formula, and implementation, it's 100% for 1 hour
and about 25% for 24 hours.

the formula is seemingly fundamentally wrong.

#13 Updated by vivec Ae Seht over 1 year ago

the fSleepRestMod part is working well, the issue seems to be with

if(x < fSleepRandMod * hoursToWait)

this function closely follows the approximate curve found in Vanilla morrowind's encounter rate when resting:
P(x)= (100*fSleepRandMod) ln x;
where x is the number of hours to rest, and P is the probability of an encounter.

This isn't exactly the right rate, but based on my modelling, experience, and math, it is approximate.

#14 Updated by vivec Ae Seht over 1 year ago

int x = Misc::Rng::rollDice(100);
//(...)
if(x < (100*fSleepRandMod * log(hoursToWait) )){
//prep for battle

https://ideone.com/0NkrfE

#15 Updated by vivec Ae Seht over 1 year ago

edit: this feels right to me, but on further inspection vanillaMW had a much lower interruption rate than a i modeled for.

#16 Updated by vivec Ae Seht over 1 year ago

vivec Ae Seht wrote:

int x = Misc::Rng::rollDice(100);
//(...)
if(x < (100*fSleepRandMod * log(hoursToWait) )){
//prep for battle

https://ideone.com/0NkrfE

although this feels about right to me, it still needs tweaked.

this works, similarly to vanilla, in the fact that if you rest long enough ('until healed' can be > 24h), it should eventually be such that you will be interrupted 100% of the time. with the current formula, the odds decrease as the number of hours being rested increases. this is backwards.

//(if you save before resting, and rest, and reload, et al)!

"if(x < (60*fSleepRandMod * log(hoursToWait))" seems to be better in terms of encounter rates.
percent chance, rest hours
10% 2h
16%
3h
27% 6h
38%
12h
48% 24h
59%
50h
70% 100h
80%
200h
90% 400h
100%
736h

This feels too slow to me still

...oh. this was marked as resolved...

#17 Updated by Jannik Heller over 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF