Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Shuffling a progressively excluding list

3 years ago
I have a character with loads of different phrases displayed on a page controlled by on-page script via a variable that runs from 1-200. I'd like to randomise these phrases via link script while also excluding phrases that have already been displayed. I can't figure out how to do it without some shitey superfluous fever dream script that will take days to complete and probably won't work. If somebody has a good solution for this I would appreciate it as it could be quite versatile for other ideas I have.

Shuffling a progressively excluding list

3 years ago

Shuffling a progressively excluding list

3 years ago
The things I do for mildly more interactive content

Shuffling a progressively excluding list

3 years ago
Since you're going through all the trouble anyway: it can be done with JS. Add a counter/iterative to the following script to get no repeats; and obviously name/format the output however you want.


<script>
var kappa = new Array()

kappa[kappa.length] = "A"

kappa[kappa.length] = "B"

kappa[kappa.length] = "C"

kappa[kappa.length] = "D"

kappa[kappa.length] = "E"

kappa[kappa.length] = "F"

kappa[kappa.length] = "G"

document.write("<p>"+kappa[Math.floor(kappa.length*Math.random())]+"</p>")
</script>

Shuffling a progressively excluding list

3 years ago
So the advanced editor allows the alien language of JS as long as I wack a script bracket around it?

Shuffling a progressively excluding list

3 years ago
yeah on global page and pagescript dialogues you can do $PAGETEXT := $PAGETEXT + "[html garbage]"

Shuffling a progressively excluding list

3 years ago
Alright tried this but it doesn't output anything. I'm not familiar with JS so am I missing something here?

Shuffling a progressively excluding list

3 years ago
Something like this?

Note I haven't read the article or your post, I'm just taking a wild guess.

Shuffling a progressively excluding list

3 years ago
^Yeah that consarnit!

Shuffling a progressively excluding list

3 years ago
Yeah, that's a step by step example of what I mentioned below (forgot that was done already lol).

Shuffling a progressively excluding list

3 years ago
E: I did read through your guide, but I think I misunderstood its utility. Just trying to adapt it to this situation now, thanks (and to Killa too)!

Shuffling a progressively excluding list

3 years ago
This is an interesting situation where you're mixing actual randomness with what you need to implement. What you should do is "shuffle" the list in the beginning, have an index variable, then increment that each time, presenting the user with a new text each time. I do something along those lines in my card game:

#Then shuffle them
#---------------Card1
%RAND := 1D48
IF %RAND = 1 THEN
BEGIN
%TEMP := %CARD1
%CARD1 := %CARD1
%CARD1 := %TEMP
END
IF %RAND = 2 THEN
BEGIN
%TEMP := %CARD2
%CARD2 := %CARD1
%CARD1 := %TEMP
END

Thing is, you have to do this for each "phrase", which already has a predetermined value. Effectively, you go through your existing list, which are all set to your predetermined values, and switch them. By the time you reach the end, you have a randomized list. In your case, you would then use your index, to set the current value, to whatever the "phrase" matching the index number is.

So in your case, 200 things have to be shuffled and each time given 1 of 200 options.

Shuffling a progressively excluding list

3 years ago
Right, just trying to implement this and tested it with 5 items, which works and didn't take too long to script. Am I right in thinking your code shuffles card 1 with 48 other cards, and then you have 48 iterations of that code shuffling card 2 with every other card, then card 3, etc. until every card has the potential to be shuffled with every other card? If so, that must be a crazy amount of code, and doing that 200 times will be even crazier. Am I missing something here or did that take you ages to script given the non-linear expansion stipulated by more items needing shuffling? Was trying to teach myself CYSugar subroutines and loops to do it but once I hit >@10 it just reads it as @1 and @20 as @2 etc.

Shuffling a progressively excluding list

3 years ago
No you're right. I used a script to generate the code involved actually haha. My shuffle code is 13971 lines long.

Yours would be ~240200 I think.

Shuffling a progressively excluding list

3 years ago
Oh God I was hoping I was wrong. Any chance you can point me towards how you generated that? Or @BrandinDvorak do you know if this can be done with CYSugar? Just started trying to use loops and shit and I tried to generate this all on CYSugar but I ran into some issues. This is what I got so far: killme

Shuffling a progressively excluding list

3 years ago
I mean you're just making lines. A python script printing the results to a file that goes along the lines of.

for(x=0;x<200;x++)
{
for(y=0;y<200;y++)
{
println(IF %RAND = y THEN)
println(BEGIN)
println(%TEMP := %CARDX)
println(%CARDX := %CARDY)
println(%CARDY := %TEMP)
println(END)
}
}

Obviously this isnt python syntax, but you get the idea. Its worth remembering i went all the way to the end for true randomness. You could stop before then if you just need it to be "mostly" random.

Shuffling a progressively excluding list

3 years ago
End already posted the only reasonable solution.

Shuffling a progressively excluding list

3 years ago
I created a 35,000 word word fishing system with over 250 fish in a part of my story that's difficult to get to. I don't need reasonable dammit I need results!

Shuffling a progressively excluding list

3 years ago
I do like fishing minigames in most things that have them.

Shuffling a progressively excluding list

3 years ago
I don't know much about Python and didn't know CYS could use python tbh. How do you get a Python script to run in a storygame? E: nm just got that you used python to automate writing the script and then copy and paste it.

Shuffling a progressively excluding list

3 years ago
You'd only need 20100 lines with my method.

Shuffling a progressively excluding list

3 years ago
Lies! You'd need at least 20200!

Shuffling a progressively excluding list

3 years ago
What's CYSugar?

Shuffling a progressively excluding list

3 years ago

A delicious food additive part of any balanced breakfast.

Shuffling a progressively excluding list

3 years ago
I thought that was cocaine...