×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Two math questions

## Two math questions

(OP)
ok two questions for anyone clever enough to answer as im stumped ^_^

Q1.

Say i have values 1-10 and i have variables box1 - box10

how do i set a script that on enter frame it sets box1 to a random one of those values, then sets box2 to one of the remaining 9 values that are left and so on til box10 is given the last one.?

---------------------------------------------------------

Q2.

In the main game the values of 1-10 will be more like cash values like $10$100 \$25000 ect.... so how would i make a code so that after 3 boxes have been opened...it added together all the remaining values and divided by how many boxes there are left to get an average...then pick a random value within a range of this value
-----------------------------------------------------------

ill add some coding to this when i get a minute...

thanks

Peter Butler

### RE: Two math questions

I'll do something like this to accomplish the first one:

-- Movie script
on populateVars
global gBoxList
gBoxList = []
numList = []
repeat with i = 1 to 10
numList[i] = i
end repeat
repeat while numList.count
randomNum = random(numList.count)
gBoxList.append(numList[randomNum])
numList.deleteAt(randomNum)
end repeat
put("gBoxList:" && gBoxList)
end populateVars
--

Then you just call populateVars() and get the result such as "gBoxList: [2, 6, 8, 10, 3, 4, 7, 5, 9, 1]".

To access a variable, use gBoxList[index]. For example if you want to get the box no.6:

--
put gBoxList[6]
-- 4
--

Kenneth Kawamoto
www.materiaprima.co.uk

### RE: Two math questions

(OP)
[img ="http://www.tandokuno.com/hosted/Deal_Or_No_Deal.jpg]

Hey kenneth, thanks for your coding but im fairly new to lingo so that kind of went right over my head :S

Let me explain what im trying to achieve (i made a picture too which may help-see link at beginning of post!)

I am trying to make a Director game for the game show Deal or No Deal. In the English version of this game there are 22 sealed red boxes (see fig 1) each with a secret value (see fig 3).

Basically at the start of the show, someone is picked at random and comes to the front with their box. They are the person who plays.

Because all boxes are sealed nobody know what is in each one. The order of play is as figure 2 shows.

When the player picks a box it is removed from the values list. after the first 5 boxes, the dealer calls and offers the player a certain amount of cash to try and get them to deal and essentially sell their box.

The whole game basically revolves around the player trying to narrow the values down so that they are really high ones left so that th ebanker panics and offers a large amount. Sometimes players play right down til the last two boxes...at which point they can get the chance to swap their box with the one left. and then open the last one.

-----------------------------------------------------------

The only thing i seem to get the hang of in director lingo is how to use global variables..

i would probably start it as something like

--code in the first frame--

global gBox1, gBox2, gBox3,  gBox4, gBox5, gBox6, gBox7, gBox8, gBox9, gBox10, gBox11, gBox12, gBox13, gBox14, gBox15, gBox16, gBox17, gBox18, gBox19, gBox20, gBox21, gBox22,

on enterFrame
set gBox1 = [one value from a list of all the values]
set gBox2 = etc etc
all the way down to
gBox22

--Perhaps if rather than trying to randomly generate the box numbers, i just had a few set variables

so if i had one variable where the boxes all equaled certain amounts specifeid by me, then anothe rone with a different combination...and so on... then at the beginning of the game it just randomly picks one of these variables and sets the bowxes to them... how woudl i do that?

### RE: Two math questions

I've never watched "Deal or no deal" (your link to the JPEG doesn't work, by the way.)

--
global gBox1, gBox2, gBox3,  gBox4, gBox5, gBox6, gBox7, gBox8, gBox9, gBox10, gBox11, gBox12, gBox13, gBox14, gBox15, gBox16, gBox17, gBox18, gBox19, gBox20, gBox21, gBox22,

on enterFrame
gBox1 = "£100"
gBox2 = "£200"
-- all the way down to gBox22
end enterFrame
--

You can do:

--
global gBoxList

on enterFrame
gBoxList = ["£100", "£200", ... "£2200"]
end enterFrame
--

Or:

--
global gBoxList

on enterFrame
gBoxList = [#Box1: "£100", #Box2: "£200", ... #Box22: "£2200"]
end enterFrame
--

It's far easier to manage, and less typing!

Kenneth Kawamoto
www.materiaprima.co.uk

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!