DrD2k9
He/Him
Editor, Judge, Expert player (2080)
Joined: 8/21/2016
Posts: 1016
Location: US
c-square wrote:
Even before that, have you done a quick test to see if what FF says is true? I was just trying the game on DosBox, and clicking on the command box does absolutely nothing. If you can't get it to work either, then your run is optimal and you can submit it!
It works, but you have to click inside the small box where the text command is, not just inside the general box.
Oh, and BTW, the wait for the surveyors to leave is hard set to 30 something (cycles? seconds? both?).
Well good, that's one less RNG to worry about. Too bad it takes them so long to leave. Maybe I'll have Roger pace back and forth while he's waiting.
Active player (372)
Joined: 9/25/2011
Posts: 652
I still think you stand a good chance of getting your original run published if you want. You’d just need to calculate how much the missed savings are (0.1 seconds x number of command entries) and then explain that, since splicing in the changes is not possible, redoing the run from scratch is not worth it for a couple seconds saved that are invisible to the viewer. Take a look at my QFG 2 submission it had known flaws but was accepted even so.
Editor, Skilled player (1941)
Joined: 6/15/2005
Posts: 3247
c-square wrote:
EDIT: The Two Guys' whining is somewhat skipable! This should at least be worth investigating since it's right at the end of the run.
I always assumed that there was a set time until the fighters attack you, so that it doesn't matter whether you listen to the Two Guys or look at the computer screen. But I didn't time it precisely, so I might be wrong. (There may be some extra messages depending on when you look at the screen.)
Player (26)
Joined: 8/29/2011
Posts: 1206
Location: Amsterdam
DrD2k9 wrote:
EDIT: Radiant, are you interested in helping dig into the RNG some more since I have to start over anyway?
Certainly.
Player (26)
Joined: 8/29/2011
Posts: 1206
Location: Amsterdam
Minor note - the Arnoid robot is chasing Roger because of vending machine fraud (says so on his visor), i.e. the whistle in SQ2; not the slot machine in SQ1. Breaking the slot machine is optional, anyway. During the wait time on Ortega, you could do something funny with the mouse cursor, perhaps. Such as around the 30 second mark in the SQIV run, https://www.youtube.com/watch?v=qKm42lwk0JM And I agree with c-square that your first run is probably publishable; just because there's a known improvement doesn't mean you have to redo everything.
DrD2k9
He/Him
Editor, Judge, Expert player (2080)
Joined: 8/21/2016
Posts: 1016
Location: US
c-square wrote:
The Two Guys' whining is somewhat skipable! This should at least be worth investigating since it's right at the end of the run. Also, I noticed that in the video he shot even before it was locked on and it hit. You could try taking shots before lock on too.
The time before the battle warning is frame-equal whether or not you watch the Two Guys dialogue. Even requiring the extra text command doesn't affect this timer. I chose to watch the dialogue for entertainment reasons. As far as shooting before lock: the ships won't be destroyed even if the bullets pass right through the ship. I'm guessing the animation of the ships being destroyed is set to the center of the viewscreen and thus only a locked shot will work. The bullets can be fired before the lock occurs as long as the lock sets before the bullets get to the ship.
Radiant wrote:
Minor note - the Arnoid robot is chasing Roger because of vending machine fraud (says so on his visor), i.e. the whistle in SQ2; not the slot machine in SQ1. Breaking the slot machine is optional, anyway.
It's probably a bit of both as Gippazoid is the owner of the Slot Machine as well. If the VGA remake of SQ1 is retconned, using the widget to defeat the slot machine would be fraudulent. I'll update the submission text on the next submission.
Radiant wrote:
During the wait time on Ortega, you could do something funny with the mouse cursor, perhaps. Such as around the 30 second mark in the SQIV run, https://www.youtube.com/watch?v=qKm42lwk0JM
I'll have to look into that....not sure what I'd do yet.
Radiant wrote:
And I agree with c-square that your first run is probably publishable; just because there's a known improvement doesn't mean you have to redo everything.
I realize it won't be a huge difference. But since I know about the improvement possibility before the current run was even claimed for judging, I'll redo it. It's more of wanting the best for my own work than anything else. I really don't mind taking the time, as much as I sarcastically whine about it in other posts. And redoing it now will prevent a publisher/encoder from having to do it twice. My temp encodes take over 2 hours to dump as it is. (My PC is slow) One last thing. This would be awesome (for any SQ games) if completed!
Player (26)
Joined: 8/29/2011
Posts: 1206
Location: Amsterdam
No luck so far in finding out the randomness algorithm for SQ3. Unlike for AGI, the reverse engineering for SCI appears to be incomplete, and the sole new implementation I've found (FreeSCI / ScummVM) implements its own randomness.
DrD2k9
He/Him
Editor, Judge, Expert player (2080)
Joined: 8/21/2016
Posts: 1016
Location: US
Radiant wrote:
No luck so far in finding out the randomness algorithm for SQ3. Unlike for AGI, the reverse engineering for SCI appears to be incomplete, and the sole new implementation I've found (FreeSCI / ScummVM) implements its own randomness.
I'm not too worried about it, now that I know that waiting for the pirates to leave the survey site is a set time. The Arnoid timing is the only RNG i'd be worried about. Theoretically, using the same paths I did before should yield the same RNG for him which was pretty fast.
Skilled player (1651)
Joined: 7/1/2013
Posts: 433
DrD2k9 wrote:
It's more of wanting the best for my own work than anything else.
Hear, hear!
Editor, Skilled player (1941)
Joined: 6/15/2005
Posts: 3247
I used Cheat Engine on SQ3 in DOSBox to find out how the RNG sequence works for this game. The sequence is given by: x←31821*x mod 65536 Like AGI, 0 is a special case that seeds the RNG with some value (may depend on system clock). That's all I know so far. The SCI random function is called whenever there is a game over (to select the game over music). This is a good way to check where the address is in JPC-rr. Edit: OK, I figured out how the random method works (other than how it seeds the RNG value when the address has value 0). It works like this: - The RNG sequence is determined by: x ← 31821*x mod 65536. - The method, random(int min, int max), returns a value from min to max as follows, given the previous RNG value of x: -- Calculate a ← 31821*x. -- Calculate b ← floor(a/256) mod 65536 (in hexadecimal this is the central 4 digits of the 8-digit representation of a) -- Calculate c ← b*(max-min+1) -- Calculate d ← floor(c/65536) (in hexadecimal this is the number c dropping the rightmost 4 digits) -- Calculate res ← d + min - Then random(int min, int max) returns res. Example: Arnoid's appearance on the pod screen is given by:
		(switch global110
			(1
				(if (== (Random 1 2) 2)
					((= gNewAct (Act new:)) posn: 1000 1000 init:)
					(= gSeconds (Random 2 10))
				)
(following numbers are in hexadecimal) If the RNG value before entering the pod screen is 0001, then: 0001*7C4D=00007C4D, 007C*(1-0+1)=000F8, res=0+1=1 Since res is 1 instead of 2, Arnoid does not appear at all. If the RNG value before entering the pod screen is AAAA, then: AAAA*7C4D=52DDAD22, DDAD*(1-0+1)=1BB5A, res=1+1=2 Since res is 2, Arnoid appears. The current RNG value is now AD22 and the number of gSeconds is then given by: AD22*7C4D=54108B3A, 108B*(10-2+1)=094E3, res=0+2=2. So gSeconds before Arnoid appears is 2, the shortest possible time.
Player (26)
Joined: 8/29/2011
Posts: 1206
Location: Amsterdam
FractalFusion wrote:
I used Cheat Engine on SQ3 in DOSBox to find out how the RNG sequence works for this game. The sequence is given by: x←31821*x mod 65536
I note that this is exactly the same as the random number generator in AGI, except using 16-bit variables instead of 8-bit. Given that both engines were made by basically the same people, that should be unsurprising. I'm willing to bet, then, that the initial seed is also the same, based on the time after midnight. AGI's initial seed is (time in seconds) * 20 + ((time in milliseconds) / 1000) * 20, calculated when the random function is first used in-game (and note that creating the seed will immediately advance it once).
Editor, Skilled player (1941)
Joined: 6/15/2005
Posts: 3247
Radiant wrote:
FractalFusion wrote:
I used Cheat Engine on SQ3 in DOSBox to find out how the RNG sequence works for this game. The sequence is given by: x←31821*x mod 65536
I note that this is exactly the same as the random number generator in AGI, except using 16-bit variables instead of 8-bit.
Not exactly the same, there is no +1 in the formula. (The AGI formula is x←31821*x+1 mod 65536.)
DrD2k9
He/Him
Editor, Judge, Expert player (2080)
Joined: 8/21/2016
Posts: 1016
Location: US
Great. Is there an easy way to modify C-Square's lua for displaying the random seed that will work with the SCI games?
Active player (372)
Joined: 9/25/2011
Posts: 652
DrD2k9 wrote:
Great. Is there an easy way to modify C-Square's lua for displaying the random seed that will work with the SCI games?
First we need to figure out the memory address for the seed. I could do that if I could get the game to run in Jpc-rr (which I’ve been unsuccessful so far) and then get a save game file from you.
DrD2k9
He/Him
Editor, Judge, Expert player (2080)
Joined: 8/21/2016
Posts: 1016
Location: US
c-square wrote:
DrD2k9 wrote:
Great. Is there an easy way to modify C-Square's lua for displaying the random seed that will work with the SCI games?
First we need to figure out the memory address for the seed. I could do that if I could get the game to run in Jpc-rr (which I’ve been unsuccessful so far) and then get a save game file from you.
What problems are you having getting it running?
DrD2k9
He/Him
Editor, Judge, Expert player (2080)
Joined: 8/21/2016
Posts: 1016
Location: US
FYI: I'm about 2 seconds improved by the time the Aluminum Mallard finds Phleebhut on the Navigation scanner. Better, but not by alot. I'm also doing what I can to keep the mouse pointer out of the way of the action (something I didn't do last time). I may have missed a place here or there though. I also have and idea for the wait time at the survey site. As far as RNG, if we can deduce it by the time I start messing with Arnoid, I'll manipulate RTC to get the ideal spawn. Considering the shortest path to the pod screen is the path I took before (minus the extra screen transition), if we can guarantee he'll arrive the first time that I'm there, that'd be great. As strange as it seems, the shortest delay on his arrival may be too quick, because Roger is arriving from the top of the screen which takes a bit of time to get to the pod-cave. A longer time delay for Arnoid's arrival may be necessary to avoid getting caught before getting past him and into the cave. I think when Arnoid arrives from the north as well, he spawns behind the leg of the cave arch.
Active player (372)
Joined: 9/25/2011
Posts: 652
Okay, I've got it running, however my file list is very different than yours:
20/12/2017  11:06 PM    <DIR>          .
20/12/2017  11:06 PM    <DIR>          ..
24/12/1996  11:32 PM             8,803 ADL.DRV
24/12/1996  11:32 PM             2,017 CGA320BW.DRV
24/12/1996  11:32 PM             2,376 CGA320C.DRV
24/12/1996  11:32 PM             1,952 EGA320.DRV
24/12/1996  11:32 PM               574 EXISTS.COM
24/12/1996  11:32 PM               507 GODIR.COM
24/12/1996  11:32 PM             2,193 HERCMONO.DRV
24/12/1996  11:32 PM               442 IBMKBD.DRV
24/12/1996  11:32 PM             2,221 IMF.DRV
24/12/1996  11:32 PM            20,329 INSTALL.EXE
24/12/1996  11:32 PM             7,322 INSTALL.HLP
24/12/1996  11:32 PM               494 JOYSTICK.DRV
24/12/1996  11:32 PM             2,935 JR.DRV
24/12/1996  11:32 PM             1,602 MCGA320.DRV
24/12/1996  11:32 PM             2,743 MT32.DRV
24/12/1996  11:32 PM             2,450 MT540.DRV
24/12/1996  11:32 PM             1,660 PCJR320.DRV
24/12/1996  11:32 PM                68 QAFILE
24/12/1996  11:32 PM           170,494 RESOURCE.001
24/12/1996  11:32 PM           312,557 RESOURCE.002
24/12/1996  11:32 PM           325,581 RESOURCE.003
24/12/1996  11:32 PM           321,222 RESOURCE.004
24/12/1996  11:32 PM           328,278 RESOURCE.005
24/12/1996  11:32 PM           356,702 RESOURCE.006
24/12/1996  11:32 PM                74 RESOURCE.CFG
24/12/1996  11:32 PM             5,598 RESOURCE.MAP
24/12/1996  11:32 PM            74,337 SCIV.EXE
24/12/1996  11:32 PM               538 SIERRA.COM
23/12/2017  09:41 PM            37,499 SQ3SG.000
23/12/2017  09:41 PM                 9 SQ3SG.DIR
24/12/1996  11:32 PM             2,393 STD.DRV
24/12/1996  11:32 PM             3,337 TANDY.DRV
24/12/1996  11:32 PM             1,650 TANDY320.DRV
24/12/1996  11:32 PM               491 TANDYKBD.DRV
DrD2k9 wrote:
FYI: I'm about 2 seconds improved by the time the Aluminum Mallard finds Phleebhut on the Navigation scanner. Better, but not by alot.
Still, it's nice to see the improvement.
DrD2k9 wrote:
I'm also doing what I can to keep the mouse pointer out of the way of the action (something I didn't do last time). I may have missed a place here or there though.
Use 'j' and 'k' shortcut keys to send the mouse pointer to the bottom-left or bottom-right of the screen. Performs a single frame advance to move it. Send me a save file and I'll try finding the rng address.
DrD2k9
He/Him
Editor, Judge, Expert player (2080)
Joined: 8/21/2016
Posts: 1016
Location: US
c-square wrote:
Okay, I've got it running, however my file list is very different than yours:
More files than mine....different (newer?) version? Mine is from GOG; I deleted all the GOG stuff from the directory including the useless .INF files. Basically all the files that are in all CAPS are game files and the files with lower case are the added GOG stuff (exception is the .inf files).
Send me a save file and I'll try finding the rng address.
You could just pull the old submission file. EDIT: Unless you want a save-state instead of a movie file.
Active player (372)
Joined: 9/25/2011
Posts: 652
DrD2k9 wrote:
More files than mine....different (newer?) version?
If anything, it seems it might be older. When I call "About Game", it says my version is 1.0U - 4/13/89.
You could just pull the old submission file
Unfortunately it desyncs right on the first screen. Looks like I need to work at getting the same file setup as you first. EDIT: I have all the files except my resource.cfg is a different size and I don't have default.cfg.
Editor, Skilled player (1941)
Joined: 6/15/2005
Posts: 3247
By the way, for entertainment purposes, on the crt (computer) screen that you pilot the ship, you can click on the invalid options to get error messages or error sounds while waiting (e.g. waiting for the "LAND" option to activate). Up to you how you wish to do that. Can't think of too many other options for entertainment, other than replacing parser words with ones of the same length, or using the mouse somehow. By the way, both the rat scene from the first visit to Script n015 as well as World O' Wonders (every visit to Script n043) throw a whole bunch of RNG values, so unfortunately it may not be easy to predict the RNG for Arnoid. On the other hand, waiting at World O' Wonders for a few more frames may be faster than extra screen transitions.
Player (26)
Joined: 8/29/2011
Posts: 1206
Location: Amsterdam
Does the run sync if you change the RTC time value? That may be the easiest way to adjust the Arnoid. I think that anything randomized before that is only cosmetic.
DrD2k9
He/Him
Editor, Judge, Expert player (2080)
Joined: 8/21/2016
Posts: 1016
Location: US
Radiant wrote:
Does the run sync if you change the RTC time value? That may be the easiest way to adjust the Arnoid. I think that anything randomized before that is only cosmetic.
I haven't tried...yet. My current WIP syncs through where I am thus far. The old run desyncs (as expected) on Phleebhut as that is the first place where RNG impacts routing.
DrD2k9
He/Him
Editor, Judge, Expert player (2080)
Joined: 8/21/2016
Posts: 1016
Location: US
FractalFusion wrote:
By the way, both the rat scene from the first visit to Script n015 as well as World O' Wonders (every visit to Script n043) throw a whole bunch of RNG values, so unfortunately it may not be easy to predict the RNG for Arnoid. On the other hand, waiting at World O' Wonders for a few more frames may be faster than extra screen transitions.
As far as the rat sequence, I believe the random calls are completely cosmetic. I've changed the initial RTC time and not had de-sync issues with that scene. The total number of random calls before a given point is not as important as knowing the sequence of seed/return values for when the random function is called. We don't need to predict Arnoid's RNG per-se so much as simply know what it is. If a table of the seed value sequence can be constructed (which should be an easy modification of the old one), then it only becomes necessary to change the initial RTC time to yield the desired RNG seed value for the screen on which Arnoid arrives. The biggest challenge is finding the memory address for the RNG seed, which c-square is attempting to do. We can then use his lua to follow the RNG. Once we have that we can choose an initial RTC that will both prevent the scorpazoid from spawning as well as yielding the shortest usable time for Arnoid. I hope all that made sense.
DrD2k9
He/Him
Editor, Judge, Expert player (2080)
Joined: 8/21/2016
Posts: 1016
Location: US
FractalFusion wrote:
I used Cheat Engine on SQ3 in DOSBox to find out how the RNG sequence works for this game. The sequence is given by: x←31821*x mod 65536 Like AGI, 0 is a special case that seeds the RNG with some value (may depend on system clock). That's all I know so far. The SCI random function is called whenever there is a game over (to select the game over music). This is a good way to check where the address is in JPC-rr. Edit: OK, I figured out how the random method works (other than how it seeds the RNG value when the address has value 0). It works like this: - The RNG sequence is determined by: x ← 31821*x mod 65536. - The method, random(int min, int max), returns a value from min to max as follows, given the previous RNG value of x: -- Calculate a ← 31821*x. -- Calculate b ← floor(a/256) mod 65536 (in hexadecimal this is the central 4 digits of the 8-digit representation of a) -- Calculate c ← b*(max-min+1) -- Calculate d ← floor(c/65536) (in hexadecimal this is the number c dropping the rightmost 4 digits) -- Calculate res ← d + min - Then random(int min, int max) returns res. Example: Arnoid's appearance on the pod screen is given by:
		(switch global110
			(1
				(if (== (Random 1 2) 2)
					((= gNewAct (Act new:)) posn: 1000 1000 init:)
					(= gSeconds (Random 2 10))
				)
(following numbers are in hexadecimal) If the RNG value before entering the pod screen is 0001, then: 0001*7C4D=00007C4D, 007C*(1-0+1)=000F8, res=0+1=1 Since res is 1 instead of 2, Arnoid does not appear at all. If the RNG value before entering the pod screen is AAAA, then: AAAA*7C4D=52DDAD22, DDAD*(1-0+1)=1BB5A, res=1+1=2 Since res is 2, Arnoid appears. The current RNG value is now AD22 and the number of gSeconds is then given by: AD22*7C4D=54108B3A, 108B*(10-2+1)=094E3, res=0+2=2. So gSeconds before Arnoid appears is 2, the shortest possible time.
So is the returned value for a random(min,max) call calculated before or after the RNG seed is updated? If before, then your above calculations would be correct. However, if random(min,max) is calculated afterwards, then the calculation for the new RNG seed is your step 'a' above and the result of that step would never exceed 65535. Thus you'd never have anything but zeros in the left 4 hex digits for step 'b' Or am I misreading/miscalculating something?
Editor, Skilled player (1941)
Joined: 6/15/2005
Posts: 3247
You can think of random(min,max) being calculated first to get some value, then the RNG updated with x←31821*x mod 65536. Sorry if I didn't make it clear.