Can Anyone Help in writing a Pascal Program 
Author Message
 Can Anyone Help in writing a Pascal Program

I need to write a program that simulates Las Vegas Craps.  The program
should generate a pair of random numbers between 1 and 6.  The program
should play one hundred games and count the number of wins and loses.  It
also needs to print out the percentage of wins and loses.  Please help... I
havn't programmed in over 20 years.


Mon, 21 Oct 2002 03:00:00 GMT  
 Can Anyone Help in writing a Pascal Program

Quote:
> I need to write a program that simulates Las Vegas Craps.  The program
> should generate a pair of random numbers between 1 and 6.  The program
> should play one hundred games and count the number of wins and loses.  It
> also needs to print out the percentage of wins and loses.  Please help... I
> havn't programmed in over 20 years.

   What compiler/system are you using (or have available)?  The key issue
in writing such a program is how to generate pseudo random numbers, and
which system you'll use is all-important.


Mon, 21 Oct 2002 03:00:00 GMT  
 Can Anyone Help in writing a Pascal Program
Quote:

> What compiler/system are you using (or have available)?  The
> key issue in writing such a program is how to generate pseudo
> random numbers, and which system you'll use is all-important.

-----------------------------------------------------------------
Actually, I suspect that "Al C." lacks an understanding of the
process he is trying to model as well as the requisite skills to
implement it in Pascal.  Judging by the phrasing of the request,
he probably has only a vague idea of what "Las Vegas Craps" are
and comprehending the physical process is as important to
programming a simulation as the operation of the PRNG.
--------------------------------------------------------------
Derek Asari

Sent via Deja.com http://www.deja.com/
Before you buy.



Tue, 22 Oct 2002 03:00:00 GMT  
 Can Anyone Help in writing a Pascal Program



Quote:
>I need to write a program that simulates Las Vegas Craps.  The program
>should generate a pair of random numbers between 1 and 6.  The program
>should play one hundred games and count the number of wins and loses.  It
>also needs to print out the percentage of wins and loses.  Please help... I
>havn't programmed in over 20 years.

This is comp.lang.pascal.misc, where by charter all sorts of Pascal are
covered, EXCEPT those covered elsewhere.  Therefore we cannot know which
version of Pascal you are using.

If the Pascal you are using is similar to Turbo Pascal, then look up
Random & Randomize in whatever on-line help, manuals, textbooks are
available.  Web <URL: http://www.merlyn.demon.co.uk/pas-rand.htm>  may
help.

You should not expect us all to know the rules of the game, such as what
constitutes a win or loss.

Otherwise, the program just requires very basic Pascal, such as should
be covered in the course materials or textbooks that you should be
using; it can also be found in Pascal tutorials on the Web : there are
references in my pas-lnx2.htm, among other places.

As you are seemingly a mature student, you should realise that provision
of detailed help would not be in your best interests.

--

 <URL: http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
 <URL: ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ;
 <URL: http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ.



Tue, 22 Oct 2002 03:00:00 GMT  
 Can Anyone Help in writing a Pascal Program


Quote:
>I need to write a program that simulates Las Vegas Craps.  The program
>should generate a pair of random numbers between 1 and 6.  The program
>should play one hundred games and count the number of wins and loses.  It
>also needs to print out the percentage of wins and loses.  Please help... I
>havn't programmed in over 20 years.

20 years is a long time not to have written a program! Hope this will
aim you in the right direction. First, look up RANDOMIZE and RANDOM in
your online help and see how these work. In some dialects, RANDOM(20)
will generate the numbers 0..19 which you can add 1 to to cover 1..20.
In some dialects, a real number .000...  to .999999... is generated.
Multiplying this by 20 and rounding to an integer, which you can find
in your help also, will again generate 0..19. You only need one
RANDOMIZE in the body of your program.

You "roll" your random generator twice to get 1..6 and add the two
numbers to get your point. There are many variations of Craps and the
Las Vegas method is designed to increase the house percentage! The
following assumes simpler rules. On the first roll of the dice if you
roll a 7 or 11, you win. Otherwise you take as many rolls as you can
(without rolling a 7 or 11) to roll the same point as made on the
first roll. After a "point" roll, 7 or 11 loses. If it were me, I
would try this version first and then add the conditions you require
later. This is also a test of "good" programming technique. Write your
program such that it is easily modified. Using CONST, PROCEDURE and
FUNCTION makes for a good "tops down" method of programming which is a
strong point of PASCAL.

A DO loop is suggested to keep up with the number of games played. An
integer variable, 'win' for example, should be initialized to 0 and
then incremented, INC(win), each time you have a winner. Nested within
the DO loop you have other loop(s) of the REPEAT or WHILE type. To
check for wins/losses you need conditional comparisons of the
IF..THEN..ELSE or CASE kind.      

Don't try to write the whole program at once. I suggest you write a
loop that will show 20 random numbers in the 1..6 range and display
them on the screen and go from there.

Although I am sure you want to do this by yourself as much as
possible, feel free to send email for hints, clarification or where to
look for help.

Regards,



Wed, 23 Oct 2002 03:00:00 GMT  
 Can Anyone Help in writing a Pascal Program
OOOPS!!! Sorry I could not correct my blunder sooner.

If your random number generator generates .000... to .999, when you
multiply by 20 and round to an integer the range will be 0..20 but
worse yet,  you will only have half the number of 0's and 20's
compared to the other numbers. You should truncate NOT round.

My apologies,
Clif



Wed, 23 Oct 2002 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Please help me write this pascal program!

2. Please help me write this pascal program!

3. Please help me write this pascal program!

4. Please help me write this pascal program!

5. Please help me write this pascal program!

6. need help writing large pascal program

7. Please help me write this pascal program!

8. pascal help, can anyone help me to learn pascal

9. Help : Anyone know how to read/write from/into Excel files

10. Anyone encounter a certain turbo pascal program?

11. Anyone know 3d Pascal programming?

12. Anyone have a pascal program similar to this?

 

 
Powered by phpBB® Forum Software