473,789 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

i need help writing a program to roll dice

1 New Member
I need help writing a program....

You are to write a python program to accomplish the following:



a.. Play a dice game of Craps using a random number generator to simulate
the roll of the dice, the code for the rolling of the dice should take place
in a user written module named rolldice.
b.. The rules of the game are as follows:
a.. 1st roll, a score of 7 or 11 wins.
b.. 1st roll, a score of 2, 3, or 12 loses.
c.. 1st roll, any number other than those listed above becomes the goal
number, you must keep rolling until you roll the goal number again. If a 7
is rolled before you goal number, you lose.


Make the game continuous, until you tell it to stop. You can bet the same
amount, or change you bet after each win or loss. Print the results of each
roll and the running total of winnings or loses.



plz help!!!
Mar 29 '07 #1
1 6224
ilikepython
844 Recognized Expert Contributor
I need help writing a program....

You are to write a python program to accomplish the following:



a.. Play a dice game of Craps using a random number generator to simulate
the roll of the dice, the code for the rolling of the dice should take place
in a user written module named rolldice.
b.. The rules of the game are as follows:
a.. 1st roll, a score of 7 or 11 wins.
b.. 1st roll, a score of 2, 3, or 12 loses.
c.. 1st roll, any number other than those listed above becomes the goal
number, you must keep rolling until you roll the goal number again. If a 7
is rolled before you goal number, you lose.


Make the game continuous, until you tell it to stop. You can bet the same
amount, or change you bet after each win or loss. Print the results of each
roll and the running total of winnings or loses.



plz help!!!
We cannot write the whole thing for you but for the dice use something like:
Expand|Select|Wrap|Line Numbers
  1. import random
  2.  
  3. dice1 = random.randint(1, 6)
  4. dice2 = random.randint(1, 6)
  5. print dice1, dice2
  6.  
Mar 29 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1546
by: Alexander Ross | last post by:
PHP/POSTGRESQL Here's the cliff's notes version of my situation: I'm makeing a simple role playing game where users gain points by answering trivia question. They can then use their points (like skiball tickets) to attepmt certain actions. Success ot failure is based on a roll of the dice. If successfull, the users personal stats (i.e. knowledge (kn), charisma (ch) .... basically think back to the hayday of Dungens & Dragons) increase...
1
1822
by: Jia Sun | last post by:
hello , everybody , i need a similar program , just like fancyimport.com if possible, pls contact me ,thank you very much . inchina@gmail.com
12
3129
by: googlegroups | last post by:
Hi, I'm making a javascript program for rolling dice for a roleplaying game that's played in a forum. The die roll gets generated, gets stored as text in a hidden form field, and then gets written to the mySQL database upon form submission. What I want to do is prevent cheaters from being able to create their own die roll, and the best way I've come up with to do this is to encrypt what gets stored in the hidden form field. However,...
20
2646
by: ramasubramanian.rahul | last post by:
hi folks i have a peculiar problem. i have to allocate more than size_t consequtive bytes on a system . after i do a malloc .. i am unable to do a realloc because it takes size_t as a new size and not as an incremental size.. can you tell me which library/system call to use.. Plz consider that all the physical hardware req for such an operation is available... i know this sounds crazy... but just help me out here .... Thanks in Advance
6
1390
by: IRCHICKEN | last post by:
There's something strange about it. In my InitGui() methode he thinks my game object still has null values but in my actionperformed method I can use the game object. public class FightJPanel extends javax.swing.JPanel { private TestFrame main; private HeroQuest game; private JLabel jLabelHero; private JButton jButtonDice; public FightJPanel(TestFrame frame, HeroQuest hero) { super();
89
3869
by: Skybuck Flying | last post by:
Hello, This morning I had an idea how to write Scalable Software in general. Unfortunately with Delphi 2007 it can't be done because it does not support operating overloading for classes, or record inheritance (records do have operator overloading) The idea is to write a generic integer class with derived integer classess for 8 bit, 16 bit, 32 bit, 64 bit and 64 bit emulated.
2
3397
by: sunnydude | last post by:
Anybody know how to write a 3 dice rolling program like this Sample output Welcome to the dice roller! First of all, please enter a seed for the random number generator. This should be a positive integer: 3 How many times would you like me to roll the 3 dice?
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5418
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.