Page 41 of 70
Re: Random Hits OXP - Version 1.3.6 (Updated 5/8/09)
Posted: Fri Jan 07, 2011 12:38 pm
by Eric Walch
curtsibling wrote:I tried a little experiment to see what I could change -
You should not change that number. I intentionally scripted a bit complex so you need to change several numbers to keep things in sync.
When you want more mission sets you should look 3 lines higher:
if (Date.now() - startTime > 500)
change 500 to a higher value. 500 is the maximum allowed time in milli seconds. Change it to 1000 or 2000 and there might be up to 9 pages.
But as said, I didn't like the long pause so I added the time limit in it. Interesting was that I got 2 sets on my machine when I added the limiter. Today with the same machine I only got 1 set. That means that with my current oxp set it took more than 500 msec to generate the first 3 pages. When I tried with last weeks trunk (still with JS 1.70) it also stopped after 3 pages. But with yesterdays trunk (With JS 1.75) I got the full set of 9 pages, meaning that at least the first 6 were generated within 500 msec. So a clear speed increase for the future JS system used by Oolite.
(I should note that there was no slow down on my 2004 vintage PC.)
The calculations result in a black screen after showing the docking tunnel. With a short delay it just feels as a natural delay to build up the next screen. Only from a certain delay on, you start recognising it as a delay.
NB those hit pages are not stored anywhere, so any info is always lost on loading a new game. It sounds odd that the same pages are generated after a restart.
Re: Random Hits OXP - Version 1.3.6 (Updated 5/8/09)
Posted: Fri Jan 07, 2011 1:27 pm
by curtsibling
Thanks for the timer advice, Eric! I will try it out.
Indeed, I kept getting the same 3 missions and bad guys to hunt down, the easy/medium/hard choice. Even after a re-install.
When I did change the (j+1) part it did lead to random generation endlessly, just like the 1.3.6 version.
Would you have the time to indicate what parts also to change to synch the script with change the 1 to a 3?
PS
My sincere kudos for taking the time to advise and help here!
Re: Random Hits OXP - Version 1.3.6 (Updated 5/8/09)
Posted: Fri Jan 07, 2011 1:42 pm
by curtsibling
Tried increasing the timescale from 500 to 2000.
It had the effect for making the target ship choices and distance more random.
But the name of the three targets and client still stays the same, as I choose between easy/med/hard.
Perhaps the problem lies with the list that picks names for the assassination targets?
I feel we are close to uncloaking what the problem might be - It must be something small and buggy!
Re: Random Hits OXP - Version 1.3.6 (Updated 5/8/09)
Posted: Fri Jan 07, 2011 2:00 pm
by Eric Walch
curtsibling wrote:But the name of the three targets and client still stays the same, as I choose between easy/med/hard.
Perhaps the problem lies with the list that picks names for the assassination targets?
I feel we are close to uncloaking what the problem might be - It must be something small and buggy!
I found the cause now. It is use of the function:
System.infoForSystem(galaxyNumber, 44).routeToSystem(system.info).distance
That is the function I use to calculate the distance to the target system. This function resets the random generator of oolite.
e.g try typing:
System.infoForSystem(galaxyNumber, 44).routeToSystem(system.info);expandDescription("[mark_first_name-1]")
in the console. You will see that it always generates the same random name. That pseudo "randomness" was also a problem for Little Bear and he had to use 3 different name sets for the missions to not get the same name for each mission.
This is one of the most buggiest parts of Oolite: it uses the random generator for both fixed random and true random numbers. So a lot of internal functions reset the random generator for a certain system to a fixed seed but forget to restore the seed when ready. So this must be fixed in Oolite itself and won't be fixed before the next Oolite release.
Re: Random Hits OXP - Version 1.3.6 (Updated 5/8/09)
Posted: Fri Jan 07, 2011 2:30 pm
by Eric Walch
Ok, I now wrote a fix for this that I also used at other places in the code. Find the
this.setupHitpages = function (){
and add the two lines as shown next between the comment symbols. I use the JS random generator to change the seed value again after the problem command:
Code: Select all
for (var j=0; j<this.sets; j++){
for (var i=0; i<3; i++){
var nr = i+3*j;
var targetSystem = this.selectOneSystemInRange(5+i*2, 21+i*4);
var distance = Math.ceil(system.info.distanceToSystem(targetSystem)*10)/10;
this.pages[nr].mark_system = targetSystem.name;
//
count = Math.round(Math.random()*10);
for (var k=0; k<count; k++) name = expandDescription("[nom11]"); // mix up the random generator
//
this.pages[nr].mark_direction = "(at "+distance+" LY to the "+this.positionToDirection(targetSystem.coordinates)+")";
this.pages[nr].mark_gender = expandDescription("[mark_gender]");
It worked before and works here also.
Re: Random Hits OXP - Version 1.3.6 (Updated 5/8/09)
Posted: Fri Jan 07, 2011 3:14 pm
by curtsibling
Great work, Eric!
Should I keep the comment symbols like you have, or just paste the text where you shown?
Re: Random Hits OXP - Version 1.3.6 (Updated 5/8/09)
Posted: Fri Jan 07, 2011 3:30 pm
by JensAyton
Eric Walch wrote:This is one of the most buggiest parts of Oolite: it uses the random generator for both fixed random and true random numbers.
Indeed. The big problem here is that it’s very difficult to fix, because some code is used both for “fixed” stuff and “really random” stuff. For instance, system descriptions are generated by calling the equivalent of
expandDescription("[system-description-string]")
after setting the PRNG seed appropriately. Some things internally rely on a previous sequence of random number generator calls being stable. Some missions (especially in the legacy scripting system) rely on stable results, while others don’t want them.
Cleaning this up is a very delicate procedure, so I don’t want to try it (any more than has already been done) before MNSR.
Re: Random Hits OXP - Version 1.3.6 (Updated 5/8/09)
Posted: Fri Jan 07, 2011 4:20 pm
by curtsibling
Been trying RH out with Eric's code patching there, and things in the missions do seem more random!
It offers same 3-6 missions, but with many variations now - And hopefully when a mark is killed, he'll stay dead!
I'm am going to complete a few missions and check the same seedy bars - I will report my findings!
Re: Random Hits OXP - Version 1.3.6 (Updated 5/8/09)
Posted: Fri Jan 07, 2011 4:27 pm
by JensAyton
On further consideration, explicitly making JS expandDescription()
and expandMissionText()
“really random” shouldn’t be a problem, since they’re newish methods.
Re: Random Hits OXP - Version 1.3.6 (Updated 5/8/09)
Posted: Fri Jan 07, 2011 4:43 pm
by curtsibling
Had a mission to kill a person called "Alexeena" from Riedquat. I iced her/him/it and upon my return, a fresh batch of baddies were on offer!
Seems like the random-ness is back! The system appears to retain various assassin-targets at a spacebar bulletin until you kill one, and then it resets.
That seems like a good method. Of course, I have not tested it over prolonged period, but there seems to be no mass-duplication of targets in all spacebars.
As Ahruman points out, even more randomness would be great! I'd love to see an endless series of random targets generated, never seeing the same target twice.
PS
I was wondering also - Would it require many edits to turn "The Great One" rank into "Lawmaster"?
Re: Random Hits OXP - Version 1.3.6 (Updated 5/8/09)
Posted: Fri Jan 07, 2011 5:49 pm
by Fatleaf
Hi, I have a slight problem and need a little help. My mark is at Reenri in G7. which is fine until when I remembered that the Rats in Assassins Guild have made the sun go nova! Is there any way I can alter things to move the mark or do I have to decline the hit at the Seedy Space Bar?
Also a big thanks for getting the Oolite Bulletin up and running again so soon.
Re: Random Hits OXP - Version 1.3.6 (Updated 5/8/09)
Posted: Mon Jan 10, 2011 9:13 am
by Eric Walch
curtsibling wrote:Been trying RH out with Eric's code patching there, and things in the missions do seem more random!
I now had time to do some tests myself. Randomness was still disappointing. Problem was the command
System.systemNameForID(Math.floor(Math.random()*256))
I used to generate system name. That one also resets the random seed. Bringing that line before my randomization fix, really fixed it.
I still want to do some more tests before a release. Specially because I want it to work with trunk also. And in 1.75 we will have a time limiter for JS functions. It should not trigger with normal code, only with bugs. But as page building takes long, I want to make sure it won't trigger. Logging times for building individual pages gave some very surprising info.
For testing I logged the time for building each page with mac 1.74.2 and current mac nighty
1.74.2
Code: Select all
[test handlers] OOJSGlobal.m:206: Player will dock at: A Seedy Space Bar
[Random_Hits] OOJSGlobal.m:206: Created page 1 after 144 msec.
[Random_Hits] OOJSGlobal.m:206: Created page 2 after 320 msec.
[Random_Hits] OOJSGlobal.m:206: Created page 3 after 539 msec.
[test handlers] OOJSGlobal.m:206: Player has docked at: A Seedy Space Bar
Trunk (future 1.75)
Code: Select all
[test handlers] OOJSGlobal.m:235: Player will dock at: A Seedy Space Bar
[Random_Hits] OOJSGlobal.m:235: Created page 1 after 30 msec.
[Random_Hits] OOJSGlobal.m:235: Created page 2 after 66 msec.
[Random_Hits] OOJSGlobal.m:235: Created page 3 after 108 msec.
[Random_Hits] OOJSGlobal.m:235: Created page 4 after 138 msec.
[Random_Hits] OOJSGlobal.m:235: Created page 5 after 174 msec.
[Random_Hits] OOJSGlobal.m:235: Created page 6 after 216 msec.
[Random_Hits] OOJSGlobal.m:235: Created page 7 after 245 msec.
[Random_Hits] OOJSGlobal.m:235: Created page 8 after 281 msec.
[Random_Hits] OOJSGlobal.m:235: Created page 9 after 323 msec.
[test handlers] OOJSGlobal.m:235: Player has docked at: A Seedy Space Bar
I knew the new JS would be faster, but I didn't expect such a speed increase.
Building 9 pages with trunk goes faster than building 3 pages with current 1.74.2. Both test are done with my usual full sets of oxps installed.
Re: Random Hits OXP - Version 1.3.6 (Updated 5/8/09)
Posted: Mon Jan 10, 2011 9:45 am
by curtsibling
Good news about the speed increases!
I have been getting an acceptable level of randomness in my hits.
But having more and also nine pages is something to look forward to!
Re: Random Hits OXP - Version 1.3.6 (Updated 5/8/09)
Posted: Mon Jan 10, 2011 5:51 pm
by Switeck
Just an idea, not one you may want to take up, but could the hits locations be changed to randomly anywhere from 1 LY out to ~16 LY?
Changing this:
var targetSystem = this.selectOneSystemInRange(5+i*2, 21+i*4);
To this:
var targetSystem = this.selectOneSystemInRange(1, 8+i*4);
in the oolite-randomHits.js file.
This would make the hits easier to get to while still sometimes needing multiple jumps. The balance to this is you'll be far more likely to be hit by criminal retribution attacks since you can do random hits more often. The criminal hate score reduces each jump you make.
Re: Random Hits OXP - Version 1.3.6 (Updated 5/8/09)
Posted: Mon Jan 10, 2011 9:27 pm
by curtsibling
Actually, now that I think of it, there has been very little in the way of criminal retribution for all my hits lately.
And not many (only one or two) mass crook attacks on the space bars!