Page 2 of 2

Posted: Fri Feb 08, 2008 5:29 pm
by Zacariaz
Well thanks, but it is nothing really, also i see now that i have made a few abious mistakes.

Posted: Mon Feb 11, 2008 12:27 am
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).

Posted: Mon Feb 11, 2008 12:50 pm
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

Posted: Mon Feb 11, 2008 9:41 pm
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";

}

Posted: Mon Feb 11, 2008 10:15 pm
by Zacariaz
wow, thats a bit more advanced than mine, sad to say i dont quite understand it (% 48?)

Posted: Tue Feb 12, 2008 7:16 am
by AndrewAPrice
oops! That should say 38, thanks!

It'd be cool to see a roulette simulator that simulates actual ball physics.

Posted: Fri Feb 22, 2008 1:31 am
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.