Page 1 of 1
EOS - How to go to random pages with % liklihood
Posted: Sat Jun 05, 2021 4:54 pm
by boundupone
Image we have a simple tease -
Start
Option-a
Option-b
Option-c
In start page the mistress will decide which punishment to give the slave. I want to randmonise which one she chooses, but multiplied by %
So if we imagine there is a 70% chance she will choose option-a 25% she will choose option-b, and just 5% she will choose option-c
Any help appreciated as I haven't been able to get an eval to work, but it should be simple
Re: EOS - How to go to random pages with % liklihood
Posted: Sat Jun 05, 2021 9:17 pm
by Batman314
I know I'm not the best programmer on here, but I think this will work pretty well for your idea:
Code: Select all
//the function should go in the init script
function choosePunishment(weight1, weight2, weight3){
//an array with the names of the pages
var pageArray = ['punishment1', 'punishment2', 'punishment3']
//random range is the sum of the weights, you can use percentage
//but they don't need to add to 100 this way
var randomRange = Math.random() * (weight1 + weight2 + weight3)
//the pageChoice variable will choose the location in the
//pageArray, and will be updated in the if statements
var pageChoice = 0
if (randomRange < weight1) {
pageChoice = 0
}
else if (randomRange < (weight1 + weight2)){
pageChoice = 1
}
else {
pageChoice = 2
}
//the function will output a string from page array
//at a location chosen by the the pageChoice variable
return pageArray[pageChoice]
}//end of function
//you can call the function in a page eval action
//add whatever weights you want in the function
var nextPage = choosePunishment(70, 25, 5)
pages.goto(nextPage)
Hope it helps!
-Batman314
Re: EOS - How to go to random pages with % liklihood
Posted: Sun Jun 06, 2021 7:49 am
by Drool
Hi.
There is also a possibility to do this without any eval.
If you have the pages
Option-a
Option-b
Option-c
and you use "goto Option-*" (note the STAR), EOS will randomly jump to one of these pages with a probability of 1/3.
If you simply copy pages and name them like
Option-a
Option-a1 (copy of Option-a)
Option-a2 (copy of Option-a)
Option-b
Option-b1 (copy of Option-b)
Option-c
you have 1/2 for 'a' 1/3 for 'b' and 1/6 for 'c'.
Crude. Primitive. The way I like it.

Re: EOS - How to go to random pages with % liklihood
Posted: Sun Jun 06, 2021 5:22 pm
by fapnip
boundupone wrote: Sat Jun 05, 2021 4:54 pm
So if we imagine there is a 70% chance she will choose option-a 25% she will choose option-b, and just 5% she will choose option-c
There's 101 ways to do it, but here's another option:
Code: Select all
var n=Math.floor(Math.random()*100)
if (n<70) {
pages.goto('Option-a')
} else if (n<95) {
pages.goto('Option-b')
} else {
pages.goto('Option-c')
}
Re: EOS - How to go to random pages with % liklihood
Posted: Mon Jun 07, 2021 4:33 pm
by boundupone
fapnip wrote: Sun Jun 06, 2021 5:22 pm
boundupone wrote: Sat Jun 05, 2021 4:54 pm
So if we imagine there is a 70% chance she will choose option-a 25% she will choose option-b, and just 5% she will choose option-c
There's 101 ways to do it, but here's another option:
Code: Select all
var n=Math.floor(Math.random()*100)
if (n<70) {
pages.goto('Option-a')
} else if (n<95) {
pages.goto('Option-b')
} else {
pages.goto('Option-c')
}
Brilliant, thanks, that works perfectly. I had something very similar but made a few school boy errors so it didnt work, this is perfect though
Re: EOS - How to go to random pages with % liklihood
Posted: Mon Jun 07, 2021 4:34 pm
by boundupone
Drool wrote: Sun Jun 06, 2021 7:49 am
Hi.
There is also a possibility to do this without any eval.
If you have the pages
Option-a
Option-b
Option-c
and you use "goto Option-*" (note the STAR), EOS will randomly jump to one of these pages with a probability of 1/3.
If you simply copy pages and name them like
Option-a
Option-a1 (copy of Option-a)
Option-a2 (copy of Option-a)
Option-b
Option-b1 (copy of Option-b)
Option-c
you have 1/2 for 'a' 1/3 for 'b' and 1/6 for 'c'.
Crude. Primitive. The way I like it.
That is a simple workaround, thanks for the idea. For my tease though I would end up with a lot of pages!
Re: EOS - How to go to random pages with % liklihood
Posted: Mon Jun 07, 2021 4:35 pm
by boundupone
Batman314 wrote: Sat Jun 05, 2021 9:17 pm
I know I'm not the best programmer on here, but I think this will work pretty well for your idea:
Code: Select all
//the function should go in the init script
function choosePunishment(weight1, weight2, weight3){
//an array with the names of the pages
var pageArray = ['punishment1', 'punishment2', 'punishment3']
//random range is the sum of the weights, you can use percentage
//but they don't need to add to 100 this way
var randomRange = Math.random() * (weight1 + weight2 + weight3)
//the pageChoice variable will choose the location in the
//pageArray, and will be updated in the if statements
var pageChoice = 0
if (randomRange < weight1) {
pageChoice = 0
}
else if (randomRange < (weight1 + weight2)){
pageChoice = 1
}
else {
pageChoice = 2
}
//the function will output a string from page array
//at a location chosen by the the pageChoice variable
return pageArray[pageChoice]
}//end of function
//you can call the function in a page eval action
//add whatever weights you want in the function
var nextPage = choosePunishment(70, 25, 5)
pages.goto(nextPage)
Hope it helps!
-Batman314
Thank you, really appreciate you taking the time to put this. fapnip's solution is a simpler one I am going to use, but this was interested for me to follow through to see how you did this. thank you for your help