Post subject: Finding the best character movement
Samtastic
He/Him
Player (60)
Joined: 11/30/2012
Posts: 765
So I am recreating my TAS again and I wonder how do people find the best movements for NPC's in the game whilst recording input. Does loading save states actually change the character AI or is it done using a tool on the emulator?
Enjoys speedrunning, playing and TASing Oddworld games! Has TASed: Oddworld: Abe's Oddysee in 12.06.13 (with Dooty) Oddworld: Adventures II in 20.03.78 (with Dooty) Oddworld: Abe's Exoddus 100% in 2:08:28.4 (with Dooty) Oddworld: Abe's Oddysee 100% in 1:05:01.65 Oddworld: Abe's Exoddus in 37:18 Oddworld: Abe's Exoddus in 37:15 Oddworld: Abe's Exoddus 100% in 2:!5.44.12 Oddworld: Abe's Oddysee any% in 13:01.3 Oddworld: Abe's Oddysee any% in 12:59.95 Oddworld: Abe's Oddysee 100% in 1:04:16.27 Oddworld: Abe's Oddysee 100% in 1:04:01.07 Currently working on: Waiting for Windows TAS Tools to work so I can TAS PC version of Exoddus.
Post subject: Re: Finding the best character movement
Editor, Skilled player (1505)
Joined: 7/9/2010
Posts: 1317
Samtastic wrote:
Does re-loading save states actually change the character AI oris there a tool in the emulator that changes the movements?
You probably want to read that sentence you wrote again.
Favorite animal: STOCK Gt(ROSA)26Sortm1.1(rtTA,EGFP)Nagy Grm7Tg(SMN2)89Ahmb Smn1tm1Msd Tg(SMN2*delta7)4299Ahmb Tg(tetO-SMN2,-luc)#aAhmb/J YouTube Twitch
Post subject: Re: Finding the best character movement
Editor, Skilled player (1404)
Joined: 3/31/2010
Posts: 2086
It depends very much on the game and what the "best" movements are. That is, are you trying to get an NPC to go close to you as quick as possible so you can talk to him earlier? Usually, you need to figure out if there is randomness and what randomness there is by the process of observation. Sometimes trial and error also helps.
Samtastic wrote:
Does re-loading save states actually change the character AI oris there a tool in the emulator that changes the movements?
This should never ever be the case, or you got a desync on your hands.
Active player (353)
Joined: 1/16/2008
Posts: 358
Location: The Netherlands
The goal of most emulators is to produce exactly the same output if it is given exactly the same input. For emulators that are used for making TASes this is a strict requirement. This also means that loading a save-state and doing some things should result in the AI doing exactly the same. Somewhere inside the game there is an algorithm (a computer program) that determines how an NPC should behave. Typically such an algorithm takes several inputs (eg where is the human player) to decide what the result will be (eg where should the NPC move). All information that is used as input is emulated. So the only way to get a different result is to make sure that the algorithm gets a different input. Another way to say this, is that the only way to get a different result is to make sure that the emulator is in a different state. Many games have behavior that seems to be random. For example movement of NPCs, trajectories of bullets, when/where enemies spawn, what bonus you get, etc. For this is it common for games to use a Random Number Generator. Again this is an algorithm with input and output. However in this case the input can be just some bytes in the memory of the game that are only there for the RNG. Also the algorithm was designed to produce hard-to-predict (ie 'random') results. Even in this case, if you start from the same state the result will be the same. One way to manipulate an RNG is to make sure the game uses it more or less often. For you as a starting point I would recommend to start analysing what has and what does not have an effect on the behavior of the NPC
TASes: [URL=http://tasvideos.org/Movies-298up-Obs.html]Mr. Nutz (SNES), Young Merlin 100% (SNES), Animaniacs 100% (SNES)[/URL]
Samtastic
He/Him
Player (60)
Joined: 11/30/2012
Posts: 765
I'm at a standstill in my Oddysee 100% TAS at the moment. Basically I get to the same Slog every time and my movement is frame perfect and its in the secret area in Free Fire Zone and the same movement with the Slog happens every time I try to re-record the input. The RNG must be in a loop. there is a secret area before going to the slog secret so maybe it has something to do with that. There is a loading screen before the slogs are loaded.
Enjoys speedrunning, playing and TASing Oddworld games! Has TASed: Oddworld: Abe's Oddysee in 12.06.13 (with Dooty) Oddworld: Adventures II in 20.03.78 (with Dooty) Oddworld: Abe's Exoddus 100% in 2:08:28.4 (with Dooty) Oddworld: Abe's Oddysee 100% in 1:05:01.65 Oddworld: Abe's Exoddus in 37:18 Oddworld: Abe's Exoddus in 37:15 Oddworld: Abe's Exoddus 100% in 2:!5.44.12 Oddworld: Abe's Oddysee any% in 13:01.3 Oddworld: Abe's Oddysee any% in 12:59.95 Oddworld: Abe's Oddysee 100% in 1:04:16.27 Oddworld: Abe's Oddysee 100% in 1:04:01.07 Currently working on: Waiting for Windows TAS Tools to work so I can TAS PC version of Exoddus.
ALAKTORN
He/Him
Player (99)
Joined: 10/19/2009
Posts: 2527
Location: Italy
^Well find the RNG address in RAM. That’ll show you how it changes and you can figure out how it can be manipulated.
Samtastic
He/Him
Player (60)
Joined: 11/30/2012
Posts: 765
Ok. I have been playing around with RAM Watch and Hex Editing and changing the hex values doesn't help the Slog. I'm not sure which Hex nubmer is the Slog. But here is my WIP. It's a bit strange cuz in my old WIP the slog bypassed Abe. So if anyone can find out what the hex number is for the Slog, it would be much appreciated. http://tasvideos.org/userfiles/info/28175120347566314
Enjoys speedrunning, playing and TASing Oddworld games! Has TASed: Oddworld: Abe's Oddysee in 12.06.13 (with Dooty) Oddworld: Adventures II in 20.03.78 (with Dooty) Oddworld: Abe's Exoddus 100% in 2:08:28.4 (with Dooty) Oddworld: Abe's Oddysee 100% in 1:05:01.65 Oddworld: Abe's Exoddus in 37:18 Oddworld: Abe's Exoddus in 37:15 Oddworld: Abe's Exoddus 100% in 2:!5.44.12 Oddworld: Abe's Oddysee any% in 13:01.3 Oddworld: Abe's Oddysee any% in 12:59.95 Oddworld: Abe's Oddysee 100% in 1:04:16.27 Oddworld: Abe's Oddysee 100% in 1:04:01.07 Currently working on: Waiting for Windows TAS Tools to work so I can TAS PC version of Exoddus.
ALAKTORN
He/Him
Player (99)
Joined: 10/19/2009
Posts: 2527
Location: Italy
If you’re changing the game’s memory, that’s cheating. It’s fine to do for testing but it won’t be recorded in an input file. You need to use RAM Search, not RAM Watch, to find useful addresses. The RNG is probably a 4-bytes unsigned value, so search for that. http://tasvideos.org/EmulatorResources/RamSearch.html http://tasvideos.org/MemorySearch.html There seem to be 2 different articles about it, not sure why.
Samtastic
He/Him
Player (60)
Joined: 11/30/2012
Posts: 765
Can accurate emulation cause the RNG to behave different? I can get the slog to behave when hoisting up a ledge on a later frame with just a stop and turn.
Enjoys speedrunning, playing and TASing Oddworld games! Has TASed: Oddworld: Abe's Oddysee in 12.06.13 (with Dooty) Oddworld: Adventures II in 20.03.78 (with Dooty) Oddworld: Abe's Exoddus 100% in 2:08:28.4 (with Dooty) Oddworld: Abe's Oddysee 100% in 1:05:01.65 Oddworld: Abe's Exoddus in 37:18 Oddworld: Abe's Exoddus in 37:15 Oddworld: Abe's Exoddus 100% in 2:!5.44.12 Oddworld: Abe's Oddysee any% in 13:01.3 Oddworld: Abe's Oddysee any% in 12:59.95 Oddworld: Abe's Oddysee 100% in 1:04:16.27 Oddworld: Abe's Oddysee 100% in 1:04:01.07 Currently working on: Waiting for Windows TAS Tools to work so I can TAS PC version of Exoddus.
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
Why would accurate emulation influence that? The RNG always behaves the same when given the same input unless the savestate loading doesn't restore the entire system state (which would be a bug).
Site Admin, Skilled player (1236)
Joined: 4/17/2010
Posts: 11270
Location: RU
Emulation accuracy can affect the factors that RNG uses, but the principle is the same.
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
ALAKTORN
He/Him
Player (99)
Joined: 10/19/2009
Posts: 2527
Location: Italy
Samtastic wrote:
Can accurate emulation cause the RNG to behave different? I can get the slog to behave when hoisting up a ledge on a later frame with just a stop and turn.
What does that even mean? If you’re changing your movement of course the RNG is going to change… what’s emulation got to do with anything? I think you may have no idea what an RNG is. It’s called a “random number generator”, but in truth it’s only pseudo-random. All it is is a mathematical formula that takes some specific inputs to spit out a number, then the game is programmed to interpret the number and create an outcome from it. If the RNG’s only input is your character’s movement, then unless you move differently the randomness is never going to change.
Samtastic
He/Him
Player (60)
Joined: 11/30/2012
Posts: 765
ALAKTORN wrote:
Samtastic wrote:
Can accurate emulation cause the RNG to behave different? I can get the slog to behave when hoisting up a ledge on a later frame with just a stop and turn.
What does that even mean? If you’re changing your movement of course the RNG is going to change… what’s emulation got to do with anything? I think you may have no idea what an RNG is. It’s called a “random number generator”, but in truth it’s only pseudo-random. All it is is a mathematical formula that takes some specific inputs to spit out a number, then the game is programmed to interpret the number and create an outcome from it. If the RNG’s only input is your character’s movement, then unless you move differently the randomness is never going to change.
PSXHawk has a more accurate rate than PCSX does.
Enjoys speedrunning, playing and TASing Oddworld games! Has TASed: Oddworld: Abe's Oddysee in 12.06.13 (with Dooty) Oddworld: Adventures II in 20.03.78 (with Dooty) Oddworld: Abe's Exoddus 100% in 2:08:28.4 (with Dooty) Oddworld: Abe's Oddysee 100% in 1:05:01.65 Oddworld: Abe's Exoddus in 37:18 Oddworld: Abe's Exoddus in 37:15 Oddworld: Abe's Exoddus 100% in 2:!5.44.12 Oddworld: Abe's Oddysee any% in 13:01.3 Oddworld: Abe's Oddysee any% in 12:59.95 Oddworld: Abe's Oddysee 100% in 1:04:16.27 Oddworld: Abe's Oddysee 100% in 1:04:01.07 Currently working on: Waiting for Windows TAS Tools to work so I can TAS PC version of Exoddus.
ALAKTORN
He/Him
Player (99)
Joined: 10/19/2009
Posts: 2527
Location: Italy
Samtastic wrote:
PSXHawk has a more accurate rate than PCSX does.
Ah, OK. No, something like RNG should be simple enough that all emulators get it right. I doubt there are any RNG differences between emulators.
Samtastic
He/Him
Player (60)
Joined: 11/30/2012
Posts: 765
Well, I managed to fix the Slog in the Secret area just by rolling at a different frame so maybe the RNG is different compared to PCSX. I'm sure there will be other hurdles I'll come across, so I just need to try the next movement at different frames to get a perfect RNG.
Enjoys speedrunning, playing and TASing Oddworld games! Has TASed: Oddworld: Abe's Oddysee in 12.06.13 (with Dooty) Oddworld: Adventures II in 20.03.78 (with Dooty) Oddworld: Abe's Exoddus 100% in 2:08:28.4 (with Dooty) Oddworld: Abe's Oddysee 100% in 1:05:01.65 Oddworld: Abe's Exoddus in 37:18 Oddworld: Abe's Exoddus in 37:15 Oddworld: Abe's Exoddus 100% in 2:!5.44.12 Oddworld: Abe's Oddysee any% in 13:01.3 Oddworld: Abe's Oddysee any% in 12:59.95 Oddworld: Abe's Oddysee 100% in 1:04:16.27 Oddworld: Abe's Oddysee 100% in 1:04:01.07 Currently working on: Waiting for Windows TAS Tools to work so I can TAS PC version of Exoddus.
creaothceann
He/Him
Editor
Joined: 4/7/2005
Posts: 1874
Location: Germany
RNG = generator for random numbers It's an algorithm built into the game. Maybe you mean the "current RNG state".
ALAKTORN
He/Him
Player (99)
Joined: 10/19/2009
Posts: 2527
Location: Italy
Samtastic wrote:
Well, I managed to fix the Slog in the Secret area just by rolling at a different frame so maybe the RNG is different compared to PCSX. I'm sure there will be other hurdles I'll come across, so I just need to try the next movement at different frames to get a perfect RNG.
Ah, you’re trying to port a TAS from PCSX to BizHawk? You must’ve done something wrong if the RNG desynced… maybe you lost or gained a frame somewhere?
Joined: 2/25/2006
Posts: 407
ALAKTORN wrote:
Samtastic wrote:
Well, I managed to fix the Slog in the Secret area just by rolling at a different frame so maybe the RNG is different compared to PCSX. I'm sure there will be other hurdles I'll come across, so I just need to try the next movement at different frames to get a perfect RNG.
Ah, you’re trying to port a TAS from PCSX to BizHawk? You must’ve done something wrong if the RNG desynced… maybe you lost or gained a frame somewhere?
That is something that emulation accuracy can affect, hence the original question
Can accurate emulation cause the RNG to behave different?
Though to be fair he said "accurate" instead of "accuracy', but I feel he was meaning to use the latter word and simply made a mistake.
Ryzen 3700X, ASUS Crosshair VIII Hero (WiFi) Motherboard, 32GB 3600MHz RAM, MSI Geforce 1070Ti 8GB, Windows 10 Pro x64 http://tasvideos.org/Nach/FranpaAlert.html
Alyosha
He/Him
Editor, Expert player (3532)
Joined: 11/30/2014
Posts: 2729
Location: US
Emulation accuracy effecting RNG state is something that happens in NES all the time, so its quite possible that the same could be true in PCSX emulators. Some RNGs are implemented as idle loops and are thus cycle dependent, so it wouldn't surprise me if this is the case here if you can't seem to find any other explanation Samtastic. But it sounds like you fixed the problem, so all good anyway!
ALAKTORN
He/Him
Player (99)
Joined: 10/19/2009
Posts: 2527
Location: Italy
Alyosha wrote:
Some RNGs are implemented as idle loops and are thus cycle dependent,
What does this mean?
franpa wrote:
ALAKTORN wrote:
maybe you lost or gained a frame somewhere?
That is something that emulation accuracy can affect, hence the original question
I’m not really well-versed in emulation differences but isn’t the main thing lag differences rather than gameplay frames? I don’t think lag would affect the RNG.
Samtastic
He/Him
Player (60)
Joined: 11/30/2012
Posts: 765
Maybe that's why my overall time is slower than PCSX? Mayan the game lags more on psxhawk resulting in frame loss.
Enjoys speedrunning, playing and TASing Oddworld games! Has TASed: Oddworld: Abe's Oddysee in 12.06.13 (with Dooty) Oddworld: Adventures II in 20.03.78 (with Dooty) Oddworld: Abe's Exoddus 100% in 2:08:28.4 (with Dooty) Oddworld: Abe's Oddysee 100% in 1:05:01.65 Oddworld: Abe's Exoddus in 37:18 Oddworld: Abe's Exoddus in 37:15 Oddworld: Abe's Exoddus 100% in 2:!5.44.12 Oddworld: Abe's Oddysee any% in 13:01.3 Oddworld: Abe's Oddysee any% in 12:59.95 Oddworld: Abe's Oddysee 100% in 1:04:16.27 Oddworld: Abe's Oddysee 100% in 1:04:01.07 Currently working on: Waiting for Windows TAS Tools to work so I can TAS PC version of Exoddus.
Editor, Player (44)
Joined: 7/11/2010
Posts: 1022
ALAKTORN wrote:
Alyosha wrote:
Some RNGs are implemented as idle loops and are thus cycle dependent,
What does this mean?
To explain what it means, let me give an explanation of some background first. Most older games (including most NES games) use the following method to do their timing: they wait for "vertical blank" or "vblank" (which happens approximately 60 times a second and is normally used by both the emulator and the game as the definition of a frame), then do their calculations for that frame, then repeat. The fastest the game can run, therefore, is if all the calculations get done between one vertical blank and the next (the vblanks form a "frame rule" that causes everything to take an integral number of frames). How long the calculations take depends on the total number of clock cycles that are needed to run the instructions that form them (there's an (almost) constant number of clock cycles between vblanks). If the game is running at the fastest possible speed, i.e. all the calculations are done in less than one vblank's worth of clock cycles, we call this situation "not lagging"; otherwise, we talk about "lag frames" which are frames where the game is still busy trying to complete the calculations from the frame before. So lag is highly dependent on the total clock cycle cost of instructions, and this is something that can vary between emulators due to emulator inaccuracy. However, the total clock cycle cost per frame affects the game in other ways, too. When the game finishes its calculations for the frame, the processor doesn't just stop running; instead, it has to do something to wait. What it does while waiting for the next vblank is known as an "idle loop", and is typically a short sequence of instructions just designed to bide time. The number of times the idle loop runs is dependent on the number of clock cycles needed for the game's actual calculations, subtracted from the number of clock cycles available for the input frame (which is equal to the total number of frames, i.e. the number of lag frames + 1, that make up the input frame, multiplied by the number of clock cycles between vblanks). One thing that games sometimes choose to do with their idle loop is to update a random number generator. In this case, the random number generator is basically measuring the fractional part of lag (with actual lag frames measuring the integer part of lag). Depending on how the game works, this might well be highly chaotic and thus a good choice for randomness generation. Emulator inaccuracies in terms of cycle count measuring will be visible both as inconsistent lag behaviour, and inconsistent idle loop behaviour; thus if a game has an idle-loop-based RNG, then if two emulators emulate lag differently for that game (the integer part of (cycles for calculations) divided by (cycles per vblank), rounded down), they're definitely going to emulate randomness differently for that game (the fractional part of the same calculation).