Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » how do i get math questions with lists randomized?
- caroteen
-
Scratcher
26 posts
how do i get math questions with lists randomized?
i am making a Baldi game but i cannot get the questions randomized i made 1 list for the questions one list for the answers and 1 list for 1-20 because i have 20 questions but i cannot make it work to randomize i originally had read something on this but it was not explained well so can you explain to me futher?
the code i ma using is not a code i just made 1 list with 1-20 questions and another with 1-20 answers and another with numbers 1-20
how do i continue from there?
the code i ma using is not a code i just made 1 list with 1-20 questions and another with 1-20 answers and another with numbers 1-20
how do i continue from there?
Last edited by caroteen (Oct. 12, 2020 01:45:59)
- thatmathkid
-
Scratcher
100+ posts
how do i get math questions with lists randomized?
Can you show the code you're using?
- caroteen
-
Scratcher
26 posts
how do i get math questions with lists randomized?
Can you show the code you're using?
this does not answer my question unless te project does…
- jromagnoli
-
Scratcher
1000+ posts
how do i get math questions with lists randomized?
He needs to be able to see the context of your question otherwise he won't be able to help you.Can you show the code you're using?
this does not answer my question unless te project does…
- deck26
-
Scratcher
1000+ posts
how do i get math questions with lists randomized?
You have lists containing 20 items. One easy option is to randomly swap each item with one other item but you need to keep your answers and questions in corresponding places.
In pseudo code
set index to 1
repeat until index > length of list
set rand to pick random 1 to 20
if not rand = index then
set temp to item index of list 1
set item index of list1 to item rand of list1
set item rand of list1 to temp
repeat above 3 lines for list2
end
change index by 1
end
In pseudo code
set index to 1
repeat until index > length of list
set rand to pick random 1 to 20
if not rand = index then
set temp to item index of list 1
set item index of list1 to item rand of list1
set item rand of list1 to temp
repeat above 3 lines for list2
end
change index by 1
end
- caroteen
-
Scratcher
26 posts
how do i get math questions with lists randomized?
You have lists containing 20 items. One easy option is to randomly swap each item with one other item but you need to keep your answers and questions in corresponding places.
In pseudo code
set index to 1
repeat until index > length of list
set rand to pick random 1 to 20
if not rand = index then
set temp to item index of list 1
set item index of list1 to item rand of list1
set item rand of list1 to temp
repeat above 3 lines for list2
end
change index by 1
end
can you explain what that would mean in smaller words?
- caroteen
-
Scratcher
26 posts
how do i get math questions with lists randomized?
Can you show the code you're using?
i posted this yesterday!
- Wyan100
-
Scratcher
1000+ posts
how do i get math questions with lists randomized?
Although be careful making a Baldi game, it is “technically” a horror game as the purpose of the game is to escape the evil teacher before you get jump-scared…
- caroteen
-
Scratcher
26 posts
how do i get math questions with lists randomized?
Although be careful making a Baldi game, it is “technically” a horror game as the purpose of the game is to escape the evil teacher before you get jump-scared…
i am not making it so that you can move Baldi asks questions and then if you get it wrong you lose 1 of 5 lives!
- SMKAS
-
Scratcher
500+ posts
how do i get math questions with lists randomized?
delete all of [Questions v] ::list
add [Question 1] to [Questions v]
...//Add other questions
(item (pick random (1) to (length of [Questions v] :: list)) of [Questions v] :: list)//to pick a random questio
delete (item# of [Question] in [Question v] :: list) of [Question v]//to remove it from the question
- deck26
-
Scratcher
1000+ posts
how do i get math questions with lists randomized?
That is about as close as I can get without actually giving you the Scratchblocks! If you can't cope with that perhaps you need to build more experience before trying something like this.You have lists containing 20 items. One easy option is to randomly swap each item with one other item but you need to keep your answers and questions in corresponding places.
In pseudo code
set index to 1
repeat until index > length of list
set rand to pick random 1 to 20
if not rand = index then
set temp to item index of list 1
set item index of list1 to item rand of list1
set item rand of list1 to temp
repeat above 3 lines for list2
end
change index by 1
end
can you explain what that would mean in smaller words?
- awtyagrawals
-
Scratcher
100+ posts
how do i get math questions with lists randomized?
You have to randomise these things in an order: 0,1,2,3,4,5,6,7,8,9,*,/,-,+ and then use a loop and join block to calculate and then you have the equation and answer
- Vanilla2011
-
Scratcher
500+ posts
how do i get math questions with lists randomized?
Why does it matter if you posted it yesterday? You can post the project today so we can see inside and look for any mistakes you made.Can you show the code you're using?i posted this yesterday!
- caroteen
-
Scratcher
26 posts
how do i get math questions with lists randomized?
Why does it matter if you posted it yesterday? You can post the project today so we can see inside and look for any mistakes you made.Can you show the code you're using?i posted this yesterday!
ok look for it… now! i will call it Baldi in progress
- MeIzAwezomeDede
-
Scratcher
1000+ posts
how do i get math questions with lists randomized?
Although be careful making a Baldi game, it is “technically” a horror game as the purpose of the game is to escape the evil teacher before you get jump-scared…It is indeed a horror game, although extremely tame compared to FNAF and other horror franchises.
- caroteen
-
Scratcher
26 posts
how do i get math questions with lists randomized?
You have lists containing 20 items. One easy option is to randomly swap each item with one other item but you need to keep your answers and questions in corresponding places.
In pseudo code
set index to 1
repeat until index > length of list
set rand to pick random 1 to 20
if not rand = index then
set temp to item index of list 1
set item index of list1 to item rand of list1
set item rand of list1 to temp
repeat above 3 lines for list2
end
change index by 1
end
what do you mean when you say pseudo code or index?
- deck26
-
Scratcher
1000+ posts
how do i get math questions with lists randomized?
You seem confused.
item 1 of questions list is 197-59
item 10 of questions is 9x5
So what do you think a random block with those as parameters is going to produce? The answer is 0 because it doesn't make sense to the block - it sees those as text strings so pick random ‘197-59’ to ‘9x5’ is complete nonsense. Are you just trying to choose one random item from the questions list? If so
and you use randomQ to refer to the question and answer = item randomQ of list.
item 1 of questions list is 197-59
item 10 of questions is 9x5
So what do you think a random block with those as parameters is going to produce? The answer is 0 because it doesn't make sense to the block - it sees those as text strings so pick random ‘197-59’ to ‘9x5’ is complete nonsense. Are you just trying to choose one random item from the questions list? If so
set [randomQ v] to (pick random (1) to (length of [question-list v] :: list))
and you use randomQ to refer to the question and answer = item randomQ of list.
Last edited by deck26 (Oct. 12, 2020 18:27:58)
- help_with_scripts
-
Scratcher
100+ posts
how do i get math questions with lists randomized?
index is a counter. pseudo code is explaining code in a mix between coding and englishYou have lists containing 20 items. One easy option is to randomly swap each item with one other item but you need to keep your answers and questions in corresponding places.
In pseudo code
set index to 1
repeat until index > length of list
set rand to pick random 1 to 20
if not rand = index then
set temp to item index of list 1
set item index of list1 to item rand of list1
set item rand of list1 to temp
repeat above 3 lines for list2
end
change index by 1
end
what do you mean when you say pseudo code or index?
- caroteen
-
Scratcher
26 posts
how do i get math questions with lists randomized?
You have lists containing 20 items. One easy option is to randomly swap each item with one other item but you need to keep your answers and questions in corresponding places.
In pseudo code
set index to 1
repeat until index > length of list
set rand to pick random 1 to 20
if not rand = index then
set temp to item index of list 1
set item index of list1 to item rand of list1
set item rand of list1 to temp
repeat above 3 lines for list2
end
change index by 1
end
what do you mean when you say pseudo code or index?
i know what index means but what about pseudo or temp?
- caroteen
-
Scratcher
26 posts
how do i get math questions with lists randomized?
index is a counter. pseudo code is explaining code in a mix between coding and englishYou have lists containing 20 items. One easy option is to randomly swap each item with one other item but you need to keep your answers and questions in corresponding places.
In pseudo code
set index to 1
repeat until index > length of list
set rand to pick random 1 to 20
if not rand = index then
set temp to item index of list 1
set item index of list1 to item rand of list1
set item rand of list1 to temp
repeat above 3 lines for list2
end
change index by 1
end
what do you mean when you say pseudo code or index?
what do you mean by list 1?
- Discussion Forums
- » Help with Scripts
-
» how do i get math questions with lists randomized?









