How do I shuffle textfile data in array without duplicates

Get help using Construct 2

Post » Fri Jul 17, 2015 2:08 pm

Need assistance on shuffling text file data without repetition in array. thank you =)
B
12
S
1
Posts: 63
Reputation: 633

Post » Fri Jul 17, 2015 8:34 pm

I would use a Knuth shuffle algorithm:
http://stackoverflow.com/questions/2450 ... ript-array

Most of the functions used here are already built into Construct.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
22
S
6
G
1
Posts: 1,418
Reputation: 4,830

Post » Sat Jul 18, 2015 5:31 am

If you are trying to find unique values (it's not clear what you want) then one trick is to store them as dictionary keys and values, because each dictionary can only have one of each key.
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328

Post » Tue Jul 21, 2015 8:03 am

The case is like this I am using a txt file to store my 10 questions in it and can retrieve them accordingly using array. I like to make it display 10 questions randomly without duplicates which is inside my txt file. Thanks for replying =D
B
12
S
1
Posts: 63
Reputation: 633

Post » Tue Jul 21, 2015 8:31 am

Don't use a text file, rather use a array.

Here is how to random the array with no duplicates.

If you only have 10 questions then make array width the number of questions it will random that. Save those random numbers and into another arrar, and delete them one buy one as you use the questions.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Tue Jul 21, 2015 1:11 pm

I am currently making a multiple choice quiz game for kids
B
12
S
1
Posts: 63
Reputation: 633

Post » Tue Jul 21, 2015 1:54 pm

@DayDream,

Because its is for kids... I went digging into my swipe bin and deep into my archives: Trivia Game ;)

Use previous capx for non duplicates to get list of questions numbers for sequence of questions.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,718

Post » Mon Jul 27, 2015 10:21 am

This helps a lot =) thanks.
B
12
S
1
Posts: 63
Reputation: 633

Post » Wed Aug 05, 2015 3:08 pm

How can I restore the deleted index in the array??? haha here's the scenario:

When I run the app it works perfectly so when I went to the Result Layout there is a button if the user will retake the quiz again. This is the part where I find it stressful, When the user press the "Retry button" The layout which the quiz should be displayed is blank or a white page. When I rechecked the events I appeared to deleted the index of the elements ( for shuffle ). Is there a way how can restore or probably pass the value of arrayQuestions to arrayStorage to prevent it from deleting and at the same time when I click the "Retry button" the value of arrayStorage will copy or transfer the value of it to arrayQuestions
B
12
S
1
Posts: 63
Reputation: 633


Return to How do I....?

Who is online

Users browsing this forum: JackTYGA, maranpis, oosyrag and 20 guests