Welcome
Welcome to the forums of AntiRTFM's Absolute N00b Spoonfeed C++ Tutorials!

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>!

Cee-lo point system

Ask ALL your questions here

Cee-lo point system

Postby Fatrabit on Wed Oct 28, 2009 6:01 pm

Hey guys I'm making a cee-lo game (http://en.wikipedia.org/wiki/Cee-lo) and I was wondering if anyone could see a better way to establish each rolls value than using many if/else statements?

These are the rules I'm using:

In this version of the game, each round involves two or more players of equal status. A bet amount is agreed upon and each player puts that amount in the pile or pot. Each player then has to roll all three dice at once and must continue until a recognized combination is rolled. Whichever player rolls the best combination wins the entire pot, and a new round begins. In cases where two or more players tie for the best combination, they must have a shoot out to determine a single winner.

The combinations are similar to those described above, and can be ranked from best to worst as:

4-5-6
The highest possible roll.
"Trips"
Rolling three of the same number is known as rolling "trips". Higher trips beat lower trips, so 4-4-4 is better than 3-3-3.
"Point"
Rolling a pair, and another number, establishes the singleton as a "point." A higher point beats a lower point, so 1-1-3 is better than 6-6-2.
1-2-3
The lowest possible roll.
Any other roll is a meaningless combination and must be rerolled until one of the above combinations occurs.

In most cases there will be a single winner with the best roll.

- Wikipedia

Except triple 1's is in between a point of 1 and 1-2-3.

Right now I just create three variables r1, r2, r3 = getrand(1,6); and right now all I can think of is making alot of if/else statements. Is there a better way?
Fatrabit
 
Posts: 11
Joined: Sun Sep 20, 2009 10:04 pm

Re: Cee-lo point system

Postby noobgrammer on Thu Oct 29, 2009 7:06 am

The game is foreign to me so I would have to study it just to get a good grip on the idea and rule and you have basiclly came up with the same idea I have as a first impresion

Code: Select all
die1 = rand() % 6 + 1
die2 = rand() % 6 + 1
die3 = rand() % 6 + 1

int checkDie(die1,die2,die3)


then just have a bunch of if statements

I would recommend you sit down and brainstorm ideas before you start writing code. If I wasn't busy with other things I would probably give it a shot it looks like some good practice in using logic.

I know that wasn't much help :mrgreen:
I need a compiler with a can of RAID built into it

I added a msn messenger just for programming feel free to email or add yourself to it
User avatar
noobgrammer
 
Posts: 198
Joined: Tue Aug 25, 2009 10:44 am
Location: Orlando

Re: Cee-lo point system

Postby vEjEsE on Thu Oct 29, 2009 8:36 am

Just curious about something. When you start the game you roll 3 dices, so, you would give each of them a random number.
I think they would end up with the same number. the computer will alocate a random number in the same second for all 3 of them when you roll, even if you put time(0) in srand().

Is there another way around? If the random number generator sucks ... there's no way you could do this game.
Does a universe exist if there is no life to acknowledge it's existence?
User avatar
vEjEsE
 
Posts: 48
Joined: Mon Aug 03, 2009 12:48 am

Re: Cee-lo point system

Postby noobgrammer on Thu Oct 29, 2009 8:45 am

That is a very good point vEjEsE. I don't know if its mine only but I just did a test and all three are random

Code: Select all
#include <iostream>
#include <ctime>

int main()
{
   srand((unsigned)time(0));

   int a,b,c;

   a = rand() % 6 + 1;
   b = rand() % 6 + 1;
   c = rand() % 6 + 1;

   std::cout<< a << "\n" << b << "\n" << c << "\n";
}



maybe somebody could explain that one. why it isn't the same
I need a compiler with a can of RAID built into it

I added a msn messenger just for programming feel free to email or add yourself to it
User avatar
noobgrammer
 
Posts: 198
Joined: Tue Aug 25, 2009 10:44 am
Location: Orlando

Re: Cee-lo point system

Postby Fatrabit on Thu Oct 29, 2009 6:50 pm

I was worried about that to vEjEsE but It works for me. I don't really understand the inner workings of the random number generator Ive just been using the one posted by antiRTFM.
Fatrabit
 
Posts: 11
Joined: Sun Sep 20, 2009 10:04 pm

Re: Cee-lo point system

Postby vEjEsE on Fri Oct 30, 2009 6:30 am

Hah, looks like it works. Never tested it, just thought that's the way it would happen ...

So now that we know that the rand) function works fine, we should continue with it.

I have no ideas.
Does a universe exist if there is no life to acknowledge it's existence?
User avatar
vEjEsE
 
Posts: 48
Joined: Mon Aug 03, 2009 12:48 am

Re: Cee-lo point system

Postby Fatrabit on Sat Oct 31, 2009 12:09 am

Here it is:

http://www.filefront.com/14856807/ceelo.zip

What do you think?
Fatrabit
 
Posts: 11
Joined: Sun Sep 20, 2009 10:04 pm


Return to QA

Who is online

Users browsing this forum: No registered users and 0 guests