Premium domains

All off topic discussions go here. Everything from the funny thing your cat did to your favorite tv shows. Non-programming computer questions are ok too.
User avatar
Zacariaz
Member
Member
Posts: 1069
Joined: Tue May 22, 2007 2:36 pm
Contact:

Post by Zacariaz »

Well thanks, but it is nothing really, also i see now that i have made a few abious mistakes.
This was supposed to be a cool signature...
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

Erm... guys? You are aware of the 0, which is neither red nor black... (and the reason why, even in Roulette, in the long run the bank always wins).
Every good solution is obvious once you've found it.
User avatar
Zacariaz
Member
Member
Posts: 1069
Joined: Tue May 22, 2007 2:36 pm
Contact:

Post by Zacariaz »

As you will allso see by my code example: % 37 and not % 36.
Some places they even have double or triple 0's
This was supposed to be a cool signature...
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

I wrote a matingale simulator in C++ that takes into account 0 and 00.

Code: Select all

#include <iostream>

#include <time.h>



// play a game of roulette - returns true if game won

bool PlayRoulette()

{

	int number = rand() % 38; // 0 and 00

	if(number == 0)

	{

		std::cout << "Rolled 00 (lost).\n";

		return false;

	}

	else if(number < 2 || number % 2)

	{

		std::cout << "Rolled " << number - 1 << " (lost).\n";

		return false;

	}



	std::cout << "Rolled " << number - 1 << " (won)!.\n";



	return true;

}



void main()

{

	int money, minimumbet, numberofrounds = 0;

	std::cout << "Enter starting amount: $";

	std::cin >> money;

	std::cout << "Enter minimum bet: $";

	std::cin >> minimumbet;

	std::cout << "Enter number of rounds to play: ";

	std::cin >> numberofrounds;



	int mostmoneyeverhad = money;

	int biggestbet = minimumbet;



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



	int currentbet = minimumbet;



	while(numberofrounds-- && (money - currentbet) > 0)

	{

		money -= currentbet;

		std::cout << "Betting $" << currentbet << ": ($" << money << " )";

		if(PlayRoulette())

		{

			money += currentbet * 2;

			currentbet = minimumbet;

			if(money > mostmoneyeverhad)

				mostmoneyeverhad = money;

		}

		else

		{

			currentbet *= 2;

			if(currentbet > biggestbet)

				biggestbet = currentbet;

		}

	}

	std::cout << "\n------------\nEnded playing spree.";

	std::cout << "Most money ever: $" << mostmoneyeverhad << "\n";

	std::cout << "Largest bet made: $" << biggestbet << "\n"; 

	std::cout << "Current money: $" << money;



	if(money <= 0)

		std::cout << "(BANKRUPT!)\n";

	else if(money - currentbet <= 0)

		std::cout << " (Not enough money to make bet.)\n";

	else

		std::cout << "\n";

}
Last edited by AndrewAPrice on Tue Feb 12, 2008 7:17 am, edited 1 time in total.
My OS is Perception.
User avatar
Zacariaz
Member
Member
Posts: 1069
Joined: Tue May 22, 2007 2:36 pm
Contact:

Post by Zacariaz »

wow, thats a bit more advanced than mine, sad to say i dont quite understand it (% 48?)
This was supposed to be a cool signature...
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

oops! That should say 38, thanks!

It'd be cool to see a roulette simulator that simulates actual ball physics.
My OS is Perception.
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

You could do this betting system but change the multiplier. e.g. 2.5x or 3x instead of the standard 2x.

Or even a variable multiplier which starts out at 4x and slowly lowers to 2x when it reaches $50.
My OS is Perception.
Post Reply