I made a little Mini Micro program that can read your mind! It's an implementation of a card trick described here.
import "mathUtil"
clear
spriteDisp = display(4)
// Define Card as a Sprite subclass that knows how to
// go to a position after a delay.
Card = new Sprite
Card.x = 50
Card.y = 400
Card.target = null
Card.speed = 20 // pixels/frame
Card.delay = 0 // delay in frames
Card.update = function()
if self.delay > 0 then
self.delay = self.delay - 1
if not self.delay then
// We're about to start moving, so go to the top.
spriteDisp.sprites.remove spriteDisp.sprites.indexOf(self)
spriteDisp.sprites.push self
end if
else
mathUtil.moveTowardsXY self, self.target, self.speed
end if
end function
// Gather cards as sprites.
// NOT NEEDED: cardBack = file.loadImage("/sys/pics/cards/cardBack_blue3.png")
cards = []
for f in file.children("/sys/pics/cards")
if f[-4:] != ".png" or f.indexOf("Back") != null then continue
card = new Card
card.image = file.loadImage("/sys/pics/cards/" + f)
cards.push card
end for
// shuffle the cards, and then throw out all but the first 21
cards.shuffle
cards = cards[:21]
// function to deal the cards into three piles
deal = function()
globals.piles = [[], [], []]
spriteDisp.sprites = []
pileNum = 0
while cards
card = cards.pop
card.target = {}
card.target.x = 415 + 200 * pileNum + 5 * rnd
card.target.y = 500 - 64 * piles[pileNum].len
card.delay = 20 * piles[pileNum].len + 3 * pileNum
piles[pileNum].push card
spriteDisp.sprites.insert 0, card
pileNum = (pileNum + 1) % 3
end while
for i in range(180)
for sp in spriteDisp.sprites; sp.update; end for
yield
end for
end function
// Function to gather all the cards back up in a pile.
// (Cards should already be in the `cards` list.)
gather = function()
for card in cards
card.target.x = 100
card.target.y = 520
end for
for i in range(100)
for sp in spriteDisp.sprites; sp.update; end for
yield
end for
end function
deal
text.row = 20
print "I am programmed to read"
print "your mind!"
print
print "But you must think hard."
print "Pick a card - any card."
print "Focus on it carefully."
print
print "Press Return when ready."
key.get
for dealNum in range(1,3)
text.clear
text.row = 25; text.column = 29; print "1"
text.row = 25; text.column = 43; print "2"
text.row = 25; text.column = 58; print "3"
print
print "Which column (1-3)"
print "is your card in?"
while true
k = key.get.val - 1
if k == 0 then
globals.cards = piles[1] + piles[0] + piles[2]
else if k == 1 then
globals.cards = piles[0] + piles[1] + piles[2]
else if k == 2 then
globals.cards = piles[0] + piles[2] + piles[1]
end if
if cards then break
end while
text.clear
gather
deal
end for
text.clear
text.row = 20
print "I have read your mind,"
print "and your card is..."
wait 2
card = piles[1][3]
card.scale = 1.25
print
print "This one!"