1. Help please.

Hey I am having trouble with a certian code. This is suposta act as a 
gambling table. A guy picks a number in his mind and with out telling 
you (random 1 - 10) you have to guess it. If you guess right then you 
get 10 times you wager. If you guess wrong you lose your bet.

I know that for this you will need:
integer gold --to let you know how much gold you have.
integer wager --to let you know what you bet out of your gold, from a 
text box (ie textedit).
integer bet --to let you know what number you think the man is thinking 
of.
integer number = rand(10) --to set the number the man is thinking of.
---------------------
My problem is ... How would you set this up?

new topic     » topic index » view message » categorize

2. Re: Help please.

> My problem is ... How would you set this up?

an integer is in the range -1073741824 to +1073741823
Atoms can have any integer or double-precision floating point value. 
They can range from approximately -1e300 (minus one times 10 to the power 300) 
to +1e300 with 15 decimal digits of accuracy. 

Pretty safe bet you'll be using integers for this program

Lots of great info on Euphoria is contained in the Help files.

Give yourself time to read the docs before you actually code anything.

Hint: Win32lib is a safe bet for coding this program really fast.

Euman
euman at bellsouth.net

new topic     » goto parent     » topic index » view message » categorize

3. Re: Help please.

On Saturday 15 December 2001 01:22 am, you wrote:
>
> Hey I am having trouble with a certian code. This is suposta act as a
> gambling table. A guy picks a number in his mind and with out telling
> you (random 1 - 10) you have to guess it. If you guess right then you
> get 10 times you wager. If you guess wrong you lose your bet.
>
> I know that for this you will need:
> integer gold --to let you know how much gold you have.
> integer wager --to let you know what you bet out of your gold, from a
> text box (ie textedit).
> integer bet --to let you know what number you think the man is thinking
> of.
> integer number = rand(10) --to set the number the man is thinking of.
> ---------------------
> My problem is ... How would you set this up?

You've got a good start; just continue to outline (in English) what your 
program must do

--  Player enters her life savings into gold

--new wager:
--   player enters amount she wants to wager
--   player enters her guess into bet
--   player clicks a button to make the bet
--   man selects a random number

--   if guess = number then gold =  gold plus (wager * 10)
--   else gold = gold - wager

--   if gold <= 0 then 
--     print "Sorry, you're broke!"
--     end the game
--   else
--     go back to new wager....

Make this outlne in the form of comments, and put it into the [GENERAL] area 
of your program (use Judith's IDE), along with the variables you declared 
earlier.

Next, set up a nice looking window with entries for
gold,  wager,  and guess, a button to make the bet, and a label to 
display the results.

Determine what 'events' your program must respond to:
1. Player clicks the bet button

Set the 'onClick' event of that button to do what your pseudo-code describes:

number = rand(10)
if get_number(guess) = number then
   gold += get_number(wager) * 10
   set_text(label,"You Won!")
else
   gold -= get_number(wager)
   set_text(label,sprintf("Sorry, the correct answer was %d",number))
end if

set_text(goldentry,sprintf("%8.0f",gold)) -- update the amount left

if gold <= 0 then
   set_text(label,"Sorry, you're broke!")
   close_window(MainWindow)
end if

Note that you do not need to write any loop code. Windows will handle the 
looping for you - basically just waiting for a click on the bet button.

Now, you'll be able to run the program and find out what else you need to 
code, like checks to be sure there has been an amount entered into gold, 
an amount entered into wager and bet, and which entry boxes should be 
cleared out after each round. I might also disable the 'bet' button until the 
player has entered all the needed info. Probably you'll also want to add 
a button or menu item for "Start a new game", rather than just ending 
when the player goes broke.

This should take 5 minutes or less to get working; add several hours if you 
want to make it entertaining (music, SFX, some nice graphics)

Regards,
Irv

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu