random numbers to make simple bingo game


hi folks.

i making simple bingo game in director.

1. generate random number 75; number=random(75)
2. check if number on list
3. if not number valid , code executed display "bingo ball"
4. add number list
and repeat.

is valid? there problems approach, ie. numbers called, random number generated has more likelihood of being on list speed take hit? or there way this?

thanks in advance

the issue approach evident when you've removed bunch of numbers already. see number of times have repeat step 2 grow each time draw bing ball number of balls drawn increases. how approach in reverse...

1. create list of numbers 1 75, procedurally @ beginning:

bingolist = []
repeat witih j = 1 75
bingolist.add(j)
end repeat

-- gives list containing numbers 1 75.

2. now, have generate random number based off number of items in list , remove item list:

listcount = bingolist.count
bingoballposition = random(listcount)
-- bingo ball value @ position in list:
bingoball = bingolist[bingoballposition]
-- remove ball number list
bingolist.deleteat(bingoballposition)

you have other things such setting bingolist global or property variable depending on how code project....

you may want se in moviescript if you're novice programmer can call handlers anywhere in project... you'd want create newgame handler set list (and other stuff)....

-- moviescript

global bingolist, bingoball

on newgame
bingolist = []
repeat witih j = 1 75
bingolist.add(j)
end repeat
end newgame

on getbingoball
listcount = bingolist.count
bingoballposition = random(listcount)
-- bingo ball value @ position in list:
bingoball = bingolist[bingoballposition]
-- remove ball number list
bingolist.deleteat(bingoball)
-- other stuff here such display bingo ball
end getbingoball


More discussions in Director Lingo


adobe

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums