xanaxEnjoyer
Gold Üye
- Katılım
- 1 Ağu 2020
- Mesajlar
- 105
- Beğeniler
- 23
basic bi oyun geliştirebilirisinz kasaya daima kazandırmaya dayalidir
C++:
#include <iostream>
#include <random>
#include <string>
#include <vector>
#include <Windows.h>
using namespace std;
struct Game {
int betAmount;
bool won;
};
// Function to calculate the user's winning ratio
double calculateWinningRatio(const vector<Game>& games) {
int totalGames = static_cast<int>(games.size());
int totalBetAmount = 0;
int wonCount = 0;
int lostCount = 0;
for (const auto& game : games) {
totalBetAmount += game.betAmount;
if (game.won) {
wonCount++;
}
else {
lostCount++;
}
}
double winningProbability = static_cast<double>(wonCount) / totalGames;
double losingProbability = static_cast<double>(lostCount) / totalGames;
if (losingProbability == 0) losingProbability = 1; // Avoid division by zero
return (static_cast<double>(totalGames) / totalBetAmount) * (winningProbability / losingProbability) * 2;
}
// Function to simulate winning probability
int getWinningColor() {
int randomValue = rand() % 100 + 1; // Random number between 1 and 100
// Assuming the desired win rate for the player is 67%
if (randomValue <= 67) {
// Player wins 67% of the time
return rand() % 3 + 7; // Return a random color (7, 8, or 9)
}
else {
// Casino wins 33% of the time
return 7 + (rand() % 3); // Return a random color, favoring casino win
}
}
int main()
{
srand(static_cast<unsigned int>(time(0))); // Seed for random numbers
double balance = 1000; // Balance as double
int gameCount = 1;
int userChoice;
vector<Game> games;
while (true)
{
int betColor{};
int betAmount{};
int confirmBet;
int winningColor;
cout << "Welcome to Denizbet!" << endl;
cout << "Current available bet balance: " << balance << endl;
cout << "Currently active number of games: " << gameCount << endl;
cout << "Would you like to join the game table?" << endl;
cout << "Enter 1 to join or 0 to exit: ";
cin >> userChoice;
if (userChoice == 1)
{
cout << "Transferring to the game table..." << endl;
}
else
{
cout << "Exiting the system..." << endl;
break;
}
cout << "Which color would you like to bet on? Black, Green, Red" << endl;
cout << "Black = 7, Green = 8, Red = 9" << endl;
cin >> betColor;
if (betColor == 7)
{
cout << "You have bet on Black." << endl;
}
else if (betColor == 8)
{
cout << "You have bet on Green." << endl;
}
else if (betColor == 9)
{
cout << "You have bet on Red." << endl;
}
else
{
cout << "Invalid color selection!" << endl;
continue;
}
cout << "Please enter the amount you want to bet: ";
cin >> betAmount;
if (betAmount > balance)
{
cout << "Insufficient balance!" << endl;
continue;
}
cout << "You have placed a bet of " << betAmount << "!" << endl;
cout << "Press 1 to confirm the bet or 0 to cancel: ";
cin >> confirmBet;
if (confirmBet == 1)
{
cout << "Starting the game..." << endl;
}
else
{
cout << "Exiting..." << endl;
continue;
}
// Determine the winning color
winningColor = getWinningColor(); // Adjusted to include probability control
string winningColorStr;
if (winningColor == 7)
winningColorStr = "Black";
else if (winningColor == 8)
winningColorStr = "Green";
else if (winningColor == 9)
winningColorStr = "Red";
cout << "Winning color: " << winningColorStr << endl;
// Check the result of the bet
bool won = (betColor == winningColor);
games.push_back({ betAmount, won });
if (won)
{
double winnings = 0;
if (betColor == 7)
winnings = betAmount * 22.0; // Adjusted payout
else if (betColor == 8)
winnings = betAmount * 15.0; // Adjusted payout
else if (betColor == 9)
winnings = betAmount * 20.0; // Adjusted payout
balance += winnings;
cout << "Congratulations! You won. Your new balance is: " << balance << endl;
}
else
{
balance -= betAmount;
cout << "Sorry, you lost. Your new balance is: " << balance << endl;
}
// Calculate the user's winning ratio
double dynamicWinningRatio = calculateWinningRatio(games);
cout << "Your Dynamic Winning Ratio: " << dynamicWinningRatio << endl;
// Pause before restarting the game
cout << "Starting a new game..." << endl;
system("pause");
gameCount++;
system("cls"); // Clears the console
}
return 0;
}
Son düzenleme: