Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

guzhogi

macrumors 68040
Original poster
Aug 31, 2003
3,766
1,885
Wherever my feet take me…
I work in an elementary school and was thinking of writing a program based on "Deal or No Deal". So far, I've set up the GUI, but I'm not sure how to write the code. What I want to do is have a set of 24 buttons which would act as the briefcases and create an array of 24 objects, one for each button. Each object would be the value of that button, assigned using a random # generator. I have another set of 24 buttons which just show which values are left. o when someone presses one of the "briefcase" buttons, a alert panel would pop up saying what was in that case and disable the button pressed as well as the button under the possible values. My question is, how do I assign the value to each button? I'm not very good at programming. I'm thinking about using an array, but I don't know how to assign each object of the array to its own button. Any help would be greatly appreciated! Thanks in advance!
 

steelphantom

macrumors 6502a
Oct 15, 2005
555
1
What language? Visual Basic (or REALbasic for the Mac) would probably be good for this in your situation.
 

guzhogi

macrumors 68040
Original poster
Aug 31, 2003
3,766
1,885
Wherever my feet take me…
Objective-C in xCode. Also, any suggestions for the algorithm to use in the calculation of the offer? I was thinking maybe of just using the average of the remaining values.

If I get this working, I think I'll open-source it, but I've never published a program before so how do I?
 

iSee

macrumors 68040
Oct 25, 2004
3,540
272
guzhogi said:
Objective-C in xCode. Also, any suggestions for the algorithm to use in the calculation of the offer? I was thinking maybe of just using the average of the remaining values.

If I get this working, I think I'll open-source it, but I've never published a program before so how do I?

The average is a pretty good number. I've only watched two shows, but it looked like to me that the banker stays around this value. In the ones I watched, his early offers were as low as about 1/2 the average value, but later on increased the offers (relative to the average value). They aren't purely mathematical, though. In one show the banker followed an offer of 16,000 with an offer of 16,001 (the expected value was around twice that) just to tick off the contestant. So, you could just do the average, or use the average as a basis and add or subtract a certain percent, or even occasionally put in a real low-ball, insulting offer, like in the real show.

If you release the game, you should give it a different name. The concept is an old one, so the TV show doesn't own that (I don't think!), but the name is theirs.

It sounds to me like you should work through a book on programming in objective-C and work through it, at least until you've got the hang of the syntax, using arrays, and connecting buttons to code.
 

Thom_Edwards

macrumors regular
Apr 11, 2003
240
0
guzhogi said:
Also, any suggestions for the algorithm to use in the calculation of the offer? I was thinking maybe of just using the average of the remaining values.

If I get this working, I think I'll open-source it, but I've never published a program before so how do I?

iSee may be right about the algorithm, but i always thought it was more like this: whatever percent chance the highest value is in the contestant's briefcase times the highest value still in play is the offer. so, if 100,000 was the highest value in play and there were five cases still in play (meaning a 20% chance the contestant had 100,000), the offer would be 20,000.

i may be WAY off, though. i haven't tested this (or any other) theory while watching the show, but i definitely will the next time i see it.

btw, great idea for a 'learning how to program' program! and for open sourcing it, you can just put up a web site that links to a download for your code. you could use sourceforge, too. either way, you will have to promote the project. if you just expect people to contribute, it seems kind of easy for a small project to go unnoticed due to the large number of projects going. and why wait until you get it working anyway? part of the kewlness of open source is having several people involved in the development. this is all, of course, assuming you want people to contribute!

good luck and keep us posted!
 

GeeYouEye

macrumors 68000
Dec 9, 2001
1,669
10
State of Denial
For the how-to end, if you laid out each button individually, delete them all, and create an NSMatrix of the correct size made out of the right cells you need. Next, create a new class in IB - "DealNoDealController", and add one outlet "briefcases" and an action "briefcaseClick:". Create the files for the class. Instantiate the class. Hook up "briefcases" to the matrix, and hook up the matrix to the "DealNoDealController" instance, connecting it to "briefcaseClick:"

Be sure to tag the elements in the matrix so you can get which button sent the click and respond appropriately.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.