back to math cats love MicroWorlds
MicroWorlds index
Card Trick Overview
Go to the card trick project!
Get the MicroWorlds Web Player
so you can use the project

Card Trick is shared by Daniel Ajoy of Quito, Ecuador -

screenshots of the card trick project (inactive buttons)





To use this project, you need the free MicroWorlds Web Player, but you do not need to know anything about MicroWorlds.

The computer guesses the card you have chosen, after scrambling the cards three times and asking you which row your card is in. Can you figure out how the trick works?

If you own MicroWorlds and would like to create your own card trick project from scratch, here are the procedures. Create buttons and textboxes as shown. You will need to import the card shapes. (There is also an invisible turtle on each page which takes on the shape of each card and stamps itself on the page.)

* * * * *

Procedures for Card Trick:

to startup
ht
make "deck [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27]
Show! 0
end

to Split!
make "copy :deck
make "stk1 []
make "stk2 []
make "stk3 []
repeat 9 [
make "nstk 1
repeat 3 [
make (word "stk :nstk) fput (first :copy) thing (word "stk :nstk)
make "nstk :nstk + 1
make "copy bf :copy
]
]
end

to Message!
ct insert item (:try + 1) [
[OK. I'll ask you three times. Please tell me, where is your card?]
[OK. Two more times. Please tell me, where is your card?]
[OK. One more time. Please tell me, where is your card?]
[OK. I believe your card is:]
[Please, now press Reset!]
]
if :try = 4 [make "try 3 stopall]
end

to Continue!
page2
make "try 0 Message!
Show! 0 Split!
end

to Reset!
ht clean
page1
startup
end

to It_is_here_A
make "deck (se :stk2 :stk1 :stk3)
Next!
end

to It_is_here_B
make "deck (se :stk1 :stk2 :stk3)
Next!
end

to It_is_here_C
make "deck (se :stk1 :stk3 :stk2)
Next!
end

to Next!
make "try :try + 1
Message!
if :try = 3 [Tell! stop]
Show! 3 Split!
end

to Tell!
setpos [216 20]
setsh item 14 :deck
st
end

to Shuffle!
make "deck shuffle :deck
Show! 3
end

to Show! :speed
make "copy :deck
clean setx -232
repeat 9 [
sety 102 seth 180
repeat 3 [
setsh first :copy
stamp
fd 104
wait :speed
make "copy bf :copy
]
seth 90 fd 30
]
end

to shuffle :l
if 2 > count :l [op :l]
op shuffleA pick :l :l
end

to shuffleA :e :l
make "l drop :e :l
if 2 > count :l [op fput :e :l]
op fput :e shuffleA pick :l :l
end

to drop :e :l
if empty? :l [op []]
if :e = first :l [op bf :l]
op fput first :l drop :e bf :l
end

©  copyright 2001 -   by Daniel Ajoy. All rights reserved. Reposted with permission.