Restored from backup.
This commit is contained in:
commit
59bdaca8e7
86
.vscode/settings.json
vendored
Normal file
86
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"deque": "cpp",
|
||||
"list": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"string": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"limits": "cpp",
|
||||
"new": "cpp",
|
||||
"ostream": "cpp",
|
||||
"ranges": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeinfo": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"chrono": "cpp",
|
||||
"ctime": "cpp",
|
||||
"ratio": "cpp",
|
||||
"sstream": "cpp",
|
||||
"map": "cpp",
|
||||
"fstream": "cpp",
|
||||
"csetjmp": "cpp",
|
||||
"csignal": "cpp",
|
||||
"cstring": "cpp",
|
||||
"any": "cpp",
|
||||
"strstream": "cpp",
|
||||
"bitset": "cpp",
|
||||
"cfenv": "cpp",
|
||||
"charconv": "cpp",
|
||||
"codecvt": "cpp",
|
||||
"complex": "cpp",
|
||||
"condition_variable": "cpp",
|
||||
"coroutine": "cpp",
|
||||
"cuchar": "cpp",
|
||||
"forward_list": "cpp",
|
||||
"set": "cpp",
|
||||
"unordered_set": "cpp",
|
||||
"regex": "cpp",
|
||||
"future": "cpp",
|
||||
"iomanip": "cpp",
|
||||
"mutex": "cpp",
|
||||
"numbers": "cpp",
|
||||
"scoped_allocator": "cpp",
|
||||
"shared_mutex": "cpp",
|
||||
"span": "cpp",
|
||||
"stop_token": "cpp",
|
||||
"thread": "cpp",
|
||||
"typeindex": "cpp",
|
||||
"valarray": "cpp",
|
||||
"variant": "cpp"
|
||||
}
|
||||
}
|
8
Makefile
Normal file
8
Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
all: build run
|
||||
|
||||
build:
|
||||
g++ main.cpp -o pokerc -std=c++11
|
||||
cd apps && ./build.py
|
||||
run:
|
||||
chmod +x pokerc
|
||||
./pokerc
|
57
apps/.vscode/settings.json
vendored
Normal file
57
apps/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
{
|
||||
"files.associations": {
|
||||
"cctype": "cpp",
|
||||
"clocale": "cpp",
|
||||
"cmath": "cpp",
|
||||
"cstdarg": "cpp",
|
||||
"cstddef": "cpp",
|
||||
"cstdio": "cpp",
|
||||
"cstdlib": "cpp",
|
||||
"ctime": "cpp",
|
||||
"cwchar": "cpp",
|
||||
"cwctype": "cpp",
|
||||
"array": "cpp",
|
||||
"atomic": "cpp",
|
||||
"bit": "cpp",
|
||||
"*.tcc": "cpp",
|
||||
"chrono": "cpp",
|
||||
"compare": "cpp",
|
||||
"concepts": "cpp",
|
||||
"cstdint": "cpp",
|
||||
"deque": "cpp",
|
||||
"list": "cpp",
|
||||
"map": "cpp",
|
||||
"unordered_map": "cpp",
|
||||
"vector": "cpp",
|
||||
"exception": "cpp",
|
||||
"algorithm": "cpp",
|
||||
"functional": "cpp",
|
||||
"iterator": "cpp",
|
||||
"memory": "cpp",
|
||||
"memory_resource": "cpp",
|
||||
"numeric": "cpp",
|
||||
"optional": "cpp",
|
||||
"random": "cpp",
|
||||
"ratio": "cpp",
|
||||
"string": "cpp",
|
||||
"string_view": "cpp",
|
||||
"system_error": "cpp",
|
||||
"tuple": "cpp",
|
||||
"type_traits": "cpp",
|
||||
"utility": "cpp",
|
||||
"fstream": "cpp",
|
||||
"initializer_list": "cpp",
|
||||
"iosfwd": "cpp",
|
||||
"iostream": "cpp",
|
||||
"istream": "cpp",
|
||||
"limits": "cpp",
|
||||
"new": "cpp",
|
||||
"ostream": "cpp",
|
||||
"ranges": "cpp",
|
||||
"sstream": "cpp",
|
||||
"stdexcept": "cpp",
|
||||
"streambuf": "cpp",
|
||||
"cinttypes": "cpp",
|
||||
"typeinfo": "cpp"
|
||||
}
|
||||
}
|
4
apps/Makefile
Normal file
4
apps/Makefile
Normal file
@ -0,0 +1,4 @@
|
||||
all: build
|
||||
|
||||
build:
|
||||
./build.py
|
9
apps/README.md
Normal file
9
apps/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Game documentation
|
||||
|
||||
## bet
|
||||
This is a bet semulator what ends every first bet. This will speed up your learning progres and how confident you can be.
|
||||
|
||||
### bet_flipflop
|
||||
This is the same as bet but already three cards open.
|
||||
|
||||
|
7
apps/all.py
Executable file
7
apps/all.py
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
executables = [name for name in os.listdir() if len(name.split(".")) == 1]
|
||||
print(executables)
|
||||
for executable in executables:
|
||||
os.system("./" + executable)
|
BIN
apps/bet_flop
Executable file
BIN
apps/bet_flop
Executable file
Binary file not shown.
59
apps/bet_flop.cpp
Normal file
59
apps/bet_flop.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
#include <iostream>
|
||||
#include "../game.hpp"
|
||||
#include "../gui.hpp"
|
||||
#include "../player.hpp"
|
||||
|
||||
void cls() {
|
||||
for(int i = 0; i < 100; i++){
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
int playerCount = 3;
|
||||
|
||||
Game game(playerCount);
|
||||
|
||||
CardGui gui;
|
||||
|
||||
while(true){
|
||||
cls();
|
||||
game.playTheFlop();
|
||||
int blind = 20;
|
||||
Player player = game.players[playerCount-1];
|
||||
std::cout << game.players[playerCount-1].name;
|
||||
std::cout << " Chips: " << player.chips;
|
||||
std::cout << " Wins: " << player.wins;
|
||||
|
||||
std::cout << gui.renderCards(game.communityCards);
|
||||
std::cout << gui.renderCards(player.cards) << std::endl;
|
||||
|
||||
int raiseAmount = 0.05 * player.chips;
|
||||
|
||||
std::cout << "Raise amount: ";
|
||||
std::cin >> raiseAmount;
|
||||
if(raiseAmount == 0)
|
||||
raiseAmount = 20;
|
||||
if(game.bestPlayer.name == player.name){
|
||||
game.players[playerCount-1].chips += raiseAmount;
|
||||
}else{
|
||||
game.players[playerCount-1].chips -= raiseAmount;
|
||||
}
|
||||
cls();
|
||||
|
||||
std::cout << game.players[playerCount-1].name;
|
||||
std::cout << " Chips: " << game.players[playerCount-1].chips;
|
||||
std::cout << " Wins: " << game.players[playerCount-1].wins;
|
||||
std::cout << gui.renderCards(game.communityCards);
|
||||
std::cout << gui.renderCards(game.bestPlayer.cards) << std::endl;
|
||||
std::cout << game.bestPlayer.name << ": " << game.bestPlayer.score.name << std::endl;
|
||||
std::string buff;
|
||||
std::getline(std::cin, buff, '\n');
|
||||
std::getline(std::cin, buff, '\n');
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
BIN
apps/bet_preflop
Executable file
BIN
apps/bet_preflop
Executable file
Binary file not shown.
57
apps/bet_preflop.cpp
Normal file
57
apps/bet_preflop.cpp
Normal file
@ -0,0 +1,57 @@
|
||||
#include <iostream>
|
||||
#include "../game.hpp"
|
||||
#include "../gui.hpp"
|
||||
#include "../player.hpp"
|
||||
|
||||
void cls() {
|
||||
for(int i = 0; i < 100; i++){
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
int playerCount = 3;
|
||||
|
||||
Game game(playerCount);
|
||||
|
||||
CardGui gui;
|
||||
|
||||
while(true){
|
||||
cls();
|
||||
game.playTheFlop();
|
||||
int blind = 20;
|
||||
Player player = game.players[playerCount-1];
|
||||
std::cout << game.players[playerCount-1].name;
|
||||
std::cout << " Chips: " << player.chips;
|
||||
std::cout << " Wins: " << player.wins;
|
||||
std::cout << gui.renderCards(player.cards) << std::endl;
|
||||
|
||||
int raiseAmount = 0.05 * player.chips;
|
||||
|
||||
std::cout << "Raise amount: ";
|
||||
std::cin >> raiseAmount;
|
||||
if(raiseAmount == 0)
|
||||
raiseAmount = 20;
|
||||
if(game.bestPlayer.name == player.name){
|
||||
game.players[playerCount-1].chips += raiseAmount;
|
||||
}else{
|
||||
game.players[playerCount-1].chips -= raiseAmount;
|
||||
}
|
||||
cls();
|
||||
|
||||
std::cout << game.players[playerCount-1].name;
|
||||
std::cout << " Chips: " << game.players[playerCount-1].chips;
|
||||
std::cout << " Wins: " << game.players[playerCount-1].wins;
|
||||
std::cout << gui.renderCards(game.communityCards);
|
||||
std::cout << gui.renderCards(game.bestPlayer.cards) << std::endl;
|
||||
std::cout << game.bestPlayer.name << ": " << game.bestPlayer.score.name << std::endl << std::endl;
|
||||
std::string buff;
|
||||
std::getline(std::cin, buff, '\n');
|
||||
std::getline(std::cin, buff, '\n');
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
13
apps/build.py
Executable file
13
apps/build.py
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
import time
|
||||
import os
|
||||
source_files = [name for name in os.listdir() if name[-4:] == ".cpp"]
|
||||
print(source_files)
|
||||
for executable in source_files:
|
||||
cmd = f"g++ {executable} -o {executable[:-4]}"
|
||||
print(f"Executing {cmd}", end="",flush=True)
|
||||
tstart = time.time()
|
||||
os.system(cmd)
|
||||
tend = time.time()
|
||||
duration = tend - tstart
|
||||
print(f" took {duration} seconds")
|
BIN
apps/pair_chance
Executable file
BIN
apps/pair_chance
Executable file
Binary file not shown.
69
apps/pair_chance.cpp
Normal file
69
apps/pair_chance.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
#include "../card.hpp"
|
||||
#include "../deck.hpp"
|
||||
|
||||
double getPairPercentage(double minWorth=0) {
|
||||
double count = 0;
|
||||
while(true){
|
||||
count++;
|
||||
Deck deck;
|
||||
auto card1 = deck.getCard();
|
||||
auto card2 = deck.getCard();
|
||||
if(card1.worth == card2.worth && card1.worth >= minWorth)
|
||||
break;
|
||||
}
|
||||
return 1 / count * 100;
|
||||
}
|
||||
double getPairBatchPercentage(double times=10, double minWorth=0)
|
||||
{
|
||||
double total = 0;
|
||||
double count = 0;
|
||||
|
||||
while(times > count) {
|
||||
count++;
|
||||
total += getPairPercentage(minWorth);
|
||||
}
|
||||
|
||||
return total / count;
|
||||
}
|
||||
double getPairTurns(double minWorth=0) {
|
||||
double count = 0;
|
||||
while(true){
|
||||
count++;
|
||||
Deck deck;
|
||||
auto card1 = deck.getCard();
|
||||
auto card2 = deck.getCard();
|
||||
if(card1.worth == card2.worth && card1.worth >= minWorth)
|
||||
break;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
double getPairBatchTurns(double minWorth=0)
|
||||
{
|
||||
double times = 1000;
|
||||
double total = 0;
|
||||
double count = 0;
|
||||
|
||||
while(times > count) {
|
||||
count++;
|
||||
total += getPairTurns(minWorth);
|
||||
}
|
||||
|
||||
return total / count;
|
||||
}
|
||||
int main() {
|
||||
|
||||
std::cout << "Receiving pair as first hand statistics." << std::endl;
|
||||
|
||||
double pairGeneral = getPairBatchPercentage(1000, 0);
|
||||
std::cout << pairGeneral << "% chance of getting a random pair." << std::endl;
|
||||
|
||||
double pairHigh = getPairBatchPercentage(1000, 0.11);
|
||||
std::cout << pairHigh << "% chance of getting a (J,Q,K,A) pair." << std::endl;
|
||||
|
||||
std::cout << pairGeneral - pairHigh << "% difference." << std::endl;
|
||||
|
||||
double pairAce = getPairBatchPercentage(1000, 0.14);
|
||||
std::cout << pairAce << "% chance of getting an Ace pair (or any specific pair)" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
apps/pair_game
Executable file
BIN
apps/pair_game
Executable file
Binary file not shown.
29
apps/pair_game.cpp
Normal file
29
apps/pair_game.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include "../game.hpp"
|
||||
#include "../simulate.hpp"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "../gui.hpp"
|
||||
|
||||
int main() {
|
||||
CardGui cg;
|
||||
Game game(2);
|
||||
while(true)
|
||||
{
|
||||
game.play();
|
||||
|
||||
std::cout<< cg.renderCards(game.players[0].cards);
|
||||
std::string cardString = game.players[0].cards[0].key + "," + game.players[0].cards[1].key;
|
||||
std::cout << std::endl;
|
||||
double score = simulate(cardString,2000, 2);
|
||||
std::string line;
|
||||
std::cout << "Bet? (y/n) ";
|
||||
std::getline(std::cin, line);
|
||||
if((line[0] == 'y' and score > 50) or (line[0] == 'n' and score < 50) ){
|
||||
std::cout << "Correct: " << score << "%" << std::endl;
|
||||
}else{
|
||||
std::cout << "Wrong: " << score << "%" << std::endl;;
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
BIN
apps/pair_stats
Executable file
BIN
apps/pair_stats
Executable file
Binary file not shown.
44
apps/pair_stats.cpp
Normal file
44
apps/pair_stats.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include "../deck.hpp"
|
||||
#include "../simulate.hpp"
|
||||
#include <iostream>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
//32.4272
|
||||
//32.4241
|
||||
//32.4287
|
||||
//32.425
|
||||
//HA,DA 73.7738
|
||||
//DA,HA 72.5726
|
||||
|
||||
int main() {
|
||||
std::ofstream myfile;
|
||||
myfile.open ("pair_stats.txt");
|
||||
Deck deckA("", false);
|
||||
Deck deckB;
|
||||
int setsCreated = 0;
|
||||
double successTotal = 0;
|
||||
while(deckA.length){
|
||||
auto cardA = deckA.getCard();
|
||||
// Want only half of cards in set
|
||||
if(cardA.kind == "D" || cardA.kind == "H")
|
||||
continue;
|
||||
deckB = Deck("", false);
|
||||
while(deckB.length){
|
||||
auto cardB = deckB.getCard();
|
||||
// Want only half of cards in set to prevent dupplication
|
||||
if(cardB.kind == "S" || cardB.kind == "C")
|
||||
continue;
|
||||
std::string cardString = cardA.key + "," + cardB.key;
|
||||
double success = simulate(cardString,1000, 2);
|
||||
successTotal += success;
|
||||
setsCreated++;
|
||||
std::cout << cardString << " " << success << "%" << std::endl;
|
||||
myfile << cardString << " " << success << "%" << std::endl;
|
||||
}
|
||||
}
|
||||
double successAverage = successTotal / setsCreated;
|
||||
std::cout << "Combinations: " << setsCreated << " Average score: " << successAverage << "%" << std::endl;
|
||||
myfile << "Combinations: " << setsCreated << " Average score: " << successAverage << "%" << std::endl;
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
5
apps/pair_stats.txt
Normal file
5
apps/pair_stats.txt
Normal file
@ -0,0 +1,5 @@
|
||||
C2,D2 68.0681%
|
||||
C2,D3 21.1211%
|
||||
C2,D4 23.3233%
|
||||
C2,D5 21.9219%
|
||||
C2,D6 25.4254%
|
BIN
apps/pair_stats_only_winning
Executable file
BIN
apps/pair_stats_only_winning
Executable file
Binary file not shown.
46
apps/pair_stats_only_winning.cpp
Normal file
46
apps/pair_stats_only_winning.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
#include "../deck.hpp"
|
||||
#include "../simulate.hpp"
|
||||
#include <iostream>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
//32.4272
|
||||
//32.4241
|
||||
//32.4287
|
||||
//32.425
|
||||
//HA,DA 73.7738
|
||||
//DA,HA 72.5726
|
||||
|
||||
int main() {
|
||||
std::ofstream myfile;
|
||||
myfile.open ("pair_stats_only_winning.txt");
|
||||
Deck deckA;
|
||||
Deck deckB;
|
||||
int setsCreated = 0;
|
||||
double successTotal = 0;
|
||||
while(deckA.length){
|
||||
auto cardA = deckA.getCard();
|
||||
// Want only half of cards in set
|
||||
if(cardA.kind == "D" || cardA.kind == "H")
|
||||
continue;
|
||||
deckB = Deck();
|
||||
while(deckB.length){
|
||||
auto cardB = deckB.getCard();
|
||||
// Want only half of cards in set to prevent dupplication
|
||||
if(cardB.kind == "S" || cardB.kind == "C")
|
||||
continue;
|
||||
std::string cardString = cardA.key + "," + cardB.key;
|
||||
double success = simulate(cardString,1000, 2);
|
||||
successTotal += success;
|
||||
setsCreated++;
|
||||
if(success > 50){
|
||||
std::cout << cardString << " " << success << "%" << std::endl;
|
||||
myfile << cardString << " " << success << "%" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
double successAverage = successTotal / setsCreated;
|
||||
std::cout << "Combinations: " << setsCreated << " Average score: " << successAverage << "%" << std::endl;
|
||||
myfile << "Combinations: " << setsCreated << " Average score: " << successAverage << "%" << std::endl;
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
325
apps/pair_stats_only_winning.txt
Normal file
325
apps/pair_stats_only_winning.txt
Normal file
@ -0,0 +1,325 @@
|
||||
S5,D5 68.8689%
|
||||
S5,DK 54.955%
|
||||
S5,H5 68.969%
|
||||
S5,HQ 51.2513%
|
||||
S5,HK 54.955%
|
||||
S5,HA 59.1592%
|
||||
S5,DA 60.2603%
|
||||
S6,HQ 54.5546%
|
||||
S6,H6 73.7738%
|
||||
S6,D6 70.5706%
|
||||
S6,HA 62.0621%
|
||||
S6,DQ 50.951%
|
||||
S6,DA 64.0641%
|
||||
S6,HJ 51.952%
|
||||
S6,HK 58.8589%
|
||||
S6,DK 56.5566%
|
||||
S10,DA 67.4675%
|
||||
S10,DK 69.2693%
|
||||
S10,D9 53.2533%
|
||||
S10,H9 54.7548%
|
||||
S10,HK 72.3724%
|
||||
S10,HQ 64.3644%
|
||||
S10,DQ 64.4645%
|
||||
S10,D10 87.4875%
|
||||
S10,HA 71.5716%
|
||||
S10,DJ 63.964%
|
||||
S10,H10 87.0871%
|
||||
S10,D8 51.1512%
|
||||
S10,H8 51.2513%
|
||||
S10,HJ 62.4625%
|
||||
SQ,H6 51.4515%
|
||||
SQ,H10 64.2643%
|
||||
SQ,D9 61.4615%
|
||||
SQ,H5 52.4525%
|
||||
SQ,HQ 92.4925%
|
||||
SQ,D6 53.6537%
|
||||
SQ,D8 58.8589%
|
||||
SQ,DA 68.8689%
|
||||
SQ,H9 63.0631%
|
||||
SQ,H8 57.5576%
|
||||
SQ,H7 56.3564%
|
||||
SQ,HK 70.6707%
|
||||
SQ,DQ 92.2923%
|
||||
SQ,D7 58.5586%
|
||||
SQ,DK 71.2713%
|
||||
SQ,DJ 68.3684%
|
||||
SQ,HJ 69.7698%
|
||||
SQ,D10 64.1642%
|
||||
SQ,HA 68.0681%
|
||||
C9,HA 68.2683%
|
||||
C9,D9 82.3824%
|
||||
C9,HQ 59.7598%
|
||||
C9,DK 66.3664%
|
||||
C9,H10 52.6527%
|
||||
C9,DJ 56.8569%
|
||||
C9,DA 67.2673%
|
||||
C9,HJ 59.2593%
|
||||
C9,H9 86.8869%
|
||||
C9,D10 52.8529%
|
||||
C9,DQ 61.1612%
|
||||
C9,HK 64.7648%
|
||||
C3,DK 50.951%
|
||||
C3,HK 50.7508%
|
||||
C3,D3 66.967%
|
||||
C3,H3 65.8659%
|
||||
C3,DA 53.6537%
|
||||
C3,HA 54.955%
|
||||
CJ,H10 63.5636%
|
||||
CJ,HK 68.5686%
|
||||
CJ,D10 62.1622%
|
||||
CJ,DA 72.1722%
|
||||
CJ,D9 57.958%
|
||||
CJ,D7 52.7528%
|
||||
CJ,HJ 92.7928%
|
||||
CJ,H7 50.4505%
|
||||
CJ,HA 72.5726%
|
||||
CJ,DJ 91.3914%
|
||||
CJ,H9 56.8569%
|
||||
CJ,H8 56.7568%
|
||||
CJ,DK 68.2683%
|
||||
CJ,DQ 64.4645%
|
||||
CJ,HQ 65.8659%
|
||||
CJ,D8 57.5576%
|
||||
CQ,DA 73.5736%
|
||||
CQ,H9 63.0631%
|
||||
CQ,H8 58.8589%
|
||||
CQ,H6 55.5556%
|
||||
CQ,D5 52.5526%
|
||||
CQ,HQ 94.1942%
|
||||
CQ,DQ 93.5936%
|
||||
CQ,DJ 66.0661%
|
||||
CQ,DK 73.7738%
|
||||
CQ,H7 57.8579%
|
||||
CQ,H5 51.1512%
|
||||
CQ,D10 66.5666%
|
||||
CQ,H10 63.4635%
|
||||
CQ,HJ 63.4635%
|
||||
CQ,HA 73.974%
|
||||
CQ,D7 55.4555%
|
||||
CQ,D9 62.8629%
|
||||
CQ,D8 57.7578%
|
||||
CQ,D6 53.3534%
|
||||
CQ,HK 69.2693%
|
||||
CK,HQ 71.4715%
|
||||
CK,H9 64.965%
|
||||
CK,HA 75.6757%
|
||||
CK,D4 53.954%
|
||||
CK,DJ 68.5686%
|
||||
CK,D5 56.7568%
|
||||
CK,D9 66.1662%
|
||||
CK,D7 61.0611%
|
||||
CK,H4 52.2523%
|
||||
CK,H7 59.2593%
|
||||
CK,D8 62.8629%
|
||||
CK,H8 61.7618%
|
||||
CK,HK 95.2953%
|
||||
CK,DK 95.4955%
|
||||
CK,DA 70.6707%
|
||||
CK,H6 59.5596%
|
||||
CK,H5 56.0561%
|
||||
CK,D6 58.7588%
|
||||
CK,H10 68.5686%
|
||||
CK,D10 70.0701%
|
||||
CK,DQ 70.8709%
|
||||
CK,HJ 67.3674%
|
||||
SJ,HK 70.0701%
|
||||
SJ,HQ 65.1652%
|
||||
SJ,H8 56.5566%
|
||||
SJ,DK 67.4675%
|
||||
SJ,D7 52.1522%
|
||||
SJ,DQ 66.4665%
|
||||
SJ,HJ 91.3914%
|
||||
SJ,DJ 90.991%
|
||||
SJ,D6 50.2503%
|
||||
SJ,D8 55.6557%
|
||||
SJ,DA 70.6707%
|
||||
SJ,D9 60.3604%
|
||||
SJ,H7 50.7508%
|
||||
SJ,D10 63.4635%
|
||||
SJ,HA 68.5686%
|
||||
SJ,H9 61.3614%
|
||||
SJ,H10 64.3644%
|
||||
S9,DJ 58.0581%
|
||||
S9,D9 85.2853%
|
||||
S9,HA 70.2703%
|
||||
S9,HJ 57.0571%
|
||||
S9,H10 55.956%
|
||||
S9,HK 65.1652%
|
||||
S9,D10 53.7538%
|
||||
S9,DA 64.1642%
|
||||
S9,HQ 62.1622%
|
||||
S9,DK 62.8629%
|
||||
S9,H9 81.982%
|
||||
S9,DQ 58.6587%
|
||||
SK,H10 69.3694%
|
||||
SK,DQ 67.968%
|
||||
SK,D6 59.4595%
|
||||
SK,HK 93.8939%
|
||||
SK,D7 56.957%
|
||||
SK,D4 50.7508%
|
||||
SK,H7 61.2613%
|
||||
SK,H3 50.1502%
|
||||
SK,H9 65.2653%
|
||||
SK,H5 53.2533%
|
||||
SK,DJ 67.968%
|
||||
SK,H6 59.5596%
|
||||
SK,D5 53.5536%
|
||||
SK,HQ 69.6697%
|
||||
SK,D10 67.6677%
|
||||
SK,D8 64.3644%
|
||||
SK,H8 63.6637%
|
||||
SK,H4 52.7528%
|
||||
SK,DK 95.2953%
|
||||
SK,HJ 68.0681%
|
||||
SK,DA 73.4735%
|
||||
SK,D9 63.8639%
|
||||
SK,HA 74.1742%
|
||||
CA,D6 62.3624%
|
||||
CA,H3 55.0551%
|
||||
CA,HQ 70.0701%
|
||||
CA,D9 66.8669%
|
||||
CA,H4 56.4565%
|
||||
CA,DA 96.4965%
|
||||
CA,H9 66.5666%
|
||||
CA,D7 66.4665%
|
||||
CA,D4 57.4575%
|
||||
CA,H8 66.5666%
|
||||
CA,HA 96.3964%
|
||||
CA,DK 73.4735%
|
||||
CA,HJ 69.8699%
|
||||
CA,DJ 69.7698%
|
||||
CA,D10 71.0711%
|
||||
CA,D8 63.964%
|
||||
CA,D5 60.2603%
|
||||
CA,D3 55.4555%
|
||||
CA,H10 67.8679%
|
||||
CA,H2 50.3504%
|
||||
CA,H6 61.3614%
|
||||
CA,HK 72.5726%
|
||||
CA,H7 62.4625%
|
||||
CA,H5 59.4595%
|
||||
CA,DQ 70.5706%
|
||||
C10,HA 68.5686%
|
||||
C10,D9 52.7528%
|
||||
C10,H10 87.4875%
|
||||
C10,DJ 60.6607%
|
||||
C10,DA 67.968%
|
||||
C10,HQ 61.2613%
|
||||
C10,D10 87.0871%
|
||||
C10,HK 66.7668%
|
||||
C10,H9 51.1512%
|
||||
C10,DK 67.8679%
|
||||
C10,D8 50.8509%
|
||||
C10,HJ 62.4625%
|
||||
C10,DQ 62.5626%
|
||||
C10,H8 52.7528%
|
||||
S3,HA 55.7558%
|
||||
S3,H3 68.1682%
|
||||
S3,DA 52.7528%
|
||||
S3,D3 69.0691%
|
||||
C2,H2 66.0661%
|
||||
C2,DA 50.8509%
|
||||
C2,D2 65.5656%
|
||||
S7,HQ 56.0561%
|
||||
S7,D7 73.7738%
|
||||
S7,DK 57.1572%
|
||||
S7,DJ 51.3514%
|
||||
S7,DA 65.8659%
|
||||
S7,HJ 52.0521%
|
||||
S7,DQ 55.956%
|
||||
S7,HA 65.966%
|
||||
S7,HK 61.1612%
|
||||
S7,H7 76.1762%
|
||||
S4,D4 69.3694%
|
||||
S4,DA 54.5546%
|
||||
S4,HK 50.4505%
|
||||
S4,HA 56.5566%
|
||||
S4,DK 51.5516%
|
||||
S4,H4 69.6697%
|
||||
C6,DK 55.8559%
|
||||
C6,H6 72.973%
|
||||
C6,HK 58.0581%
|
||||
C6,HA 60.0601%
|
||||
C6,HJ 51.3514%
|
||||
C6,DA 60.2603%
|
||||
C6,D6 73.0731%
|
||||
C6,HQ 54.0541%
|
||||
C6,DQ 52.7528%
|
||||
S8,HK 62.8629%
|
||||
S8,H8 79.6797%
|
||||
S8,HJ 56.2563%
|
||||
S8,DK 62.963%
|
||||
S8,DQ 57.6577%
|
||||
S8,D8 79.98%
|
||||
S8,HQ 60.7608%
|
||||
S8,HA 65.5656%
|
||||
S8,D10 53.954%
|
||||
S8,DJ 59.8599%
|
||||
S8,DA 65.2653%
|
||||
S2,H2 67.8679%
|
||||
S2,HA 53.0531%
|
||||
S2,DA 50.8509%
|
||||
S2,D2 66.1662%
|
||||
C8,DJ 56.4565%
|
||||
C8,HA 64.5646%
|
||||
C8,DK 64.3644%
|
||||
C8,H8 82.5826%
|
||||
C8,D8 79.1792%
|
||||
C8,DQ 62.8629%
|
||||
C8,H10 51.0511%
|
||||
C8,DA 69.4695%
|
||||
C8,HQ 62.0621%
|
||||
C8,HJ 57.8579%
|
||||
C8,D10 53.2533%
|
||||
C8,HK 63.4635%
|
||||
SA,DJ 69.1692%
|
||||
SA,D10 67.968%
|
||||
SA,D2 50.2503%
|
||||
SA,H9 65.966%
|
||||
SA,H4 57.8579%
|
||||
SA,HJ 71.0711%
|
||||
SA,DQ 72.7728%
|
||||
SA,HA 95.6957%
|
||||
SA,D4 58.959%
|
||||
SA,H7 66.1662%
|
||||
SA,D5 59.8599%
|
||||
SA,DA 94.4945%
|
||||
SA,HQ 72.6727%
|
||||
SA,H6 62.2623%
|
||||
SA,H3 53.4535%
|
||||
SA,H8 65.3654%
|
||||
SA,D7 64.6647%
|
||||
SA,D8 64.8649%
|
||||
SA,DK 74.0741%
|
||||
SA,H10 71.0711%
|
||||
SA,D3 51.2513%
|
||||
SA,D9 69.6697%
|
||||
SA,D6 64.2643%
|
||||
SA,HK 71.4715%
|
||||
SA,H5 58.3584%
|
||||
C7,HA 63.2633%
|
||||
C7,H10 50.5506%
|
||||
C7,D7 73.2733%
|
||||
C7,HQ 57.6577%
|
||||
C7,HJ 55.1552%
|
||||
C7,H7 75.8759%
|
||||
C7,DA 64.8649%
|
||||
C7,DQ 54.1542%
|
||||
C7,DK 63.4635%
|
||||
C7,DJ 51.6517%
|
||||
C7,HK 59.0591%
|
||||
C5,DA 61.5616%
|
||||
C5,H5 69.6697%
|
||||
C5,DK 53.5536%
|
||||
C5,HQ 52.953%
|
||||
C5,DQ 50.1502%
|
||||
C5,HK 57.6577%
|
||||
C5,D5 69.3694%
|
||||
C5,HA 61.7618%
|
||||
C4,H4 67.4675%
|
||||
C4,D4 66.5666%
|
||||
C4,DA 58.7588%
|
||||
C4,DK 51.6517%
|
||||
C4,HA 58.2583%
|
||||
Combinations: 676 Average score: 49.4598%
|
BIN
apps/pair_stats_value
Executable file
BIN
apps/pair_stats_value
Executable file
Binary file not shown.
55
apps/pair_stats_value.cpp
Normal file
55
apps/pair_stats_value.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
#include "../deck.hpp"
|
||||
#include "../simulate.hpp"
|
||||
#include <iostream>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "../card.hpp"
|
||||
//32.4272
|
||||
//32.4241
|
||||
//32.4287
|
||||
//32.425
|
||||
//HA,DA 73.7738
|
||||
//DA,HA 72.5726
|
||||
|
||||
int main() {
|
||||
std::ofstream myfile;
|
||||
myfile.open ("pair_stats_value.txt");
|
||||
Deck deckA;
|
||||
Deck deckB;
|
||||
int setsCreated = 0;
|
||||
double successTotal = 0;
|
||||
double correct = 0;
|
||||
double incorrect = 0;
|
||||
while(deckA.length){
|
||||
auto cardA = deckA.getCard();
|
||||
// Want only half of cards in set
|
||||
deckB = Deck();
|
||||
while(deckB.length){
|
||||
auto cardB = deckB.getCard();
|
||||
// Want only half of cards in set to prevent dupplication
|
||||
if(cardA.kind == cardB.kind && cardA.value == cardB.value)
|
||||
continue;
|
||||
std::string cardString = cardA.key + "," + cardB.key;
|
||||
double success = simulate(cardString,1000, 2);
|
||||
bool shouldWin = cardA.worth >= 7 && cardB.worth >= 7;
|
||||
if(shouldWin && success > 50){
|
||||
correct++;
|
||||
}else{
|
||||
incorrect++;
|
||||
}
|
||||
successTotal += success;
|
||||
setsCreated++;
|
||||
std::cout << cardString << " " << (cardA.worth + cardB.worth * 100) << " " << success << "%" << std::endl;
|
||||
myfile << cardString << " " << (cardA.worth + cardB.worth * 100) << " " << success << " %" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
double successAverage = successTotal / setsCreated;
|
||||
std::cout << "Combinations: " << setsCreated << " Average score: " << successAverage << "%" << std::endl;
|
||||
myfile << "Combinations: " << setsCreated << " Average score: " << successAverage << "%" << std::endl;
|
||||
std::cout << "Correct: " << correct << " Incorrect: : " << incorrect << std::endl;
|
||||
myfile << "Correct: " << correct << " Incorrect: : " << incorrect << std::endl;
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
2
apps/pair_stats_value.txt
Normal file
2
apps/pair_stats_value.txt
Normal file
@ -0,0 +1,2 @@
|
||||
H6,D3 3.06 26.2262 %
|
||||
H6,DK 13.06 60.3604 %
|
BIN
apps/score_game
Executable file
BIN
apps/score_game
Executable file
Binary file not shown.
28
apps/score_game.cpp
Normal file
28
apps/score_game.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include "../game.hpp"
|
||||
#include "../gui.hpp"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
int main() {
|
||||
Game game(1);
|
||||
CardGui cg;
|
||||
|
||||
while(true){
|
||||
game.play();
|
||||
std::cout << cg.renderCards(game.communityCards);
|
||||
std::cout << cg.renderCards(game.players[0].cards);
|
||||
std::cout << std::endl;
|
||||
std::string line;
|
||||
std::getline(std::cin, line);
|
||||
if(line == game.players[0].score.name)
|
||||
std::cout << "Correct: ";
|
||||
std::cout << game.players[0].score.name << " (" << game.players[0].score.score << ")" << std::endl;
|
||||
std::getline(std::cin, line);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
BIN
apps/score_stats
Executable file
BIN
apps/score_stats
Executable file
Binary file not shown.
114
apps/score_stats.cpp
Normal file
114
apps/score_stats.cpp
Normal file
@ -0,0 +1,114 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "../deck.hpp"
|
||||
#include "../simulate.hpp"
|
||||
#include "../game.hpp"
|
||||
#include <iostream>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
//32.4272
|
||||
//32.4241
|
||||
//32.4287
|
||||
//HA,DA 73.7738
|
||||
//DA,HA 72.5726
|
||||
|
||||
int main() {
|
||||
|
||||
int times = 100000;
|
||||
|
||||
std::cout << "Statistics on how big the chance is you'll end up winning with certain score" << std::endl;
|
||||
std::cout << "Lower percentage is better to bet on. High percentage is chance you'll win with this score" << std::endl << std::endl;
|
||||
std::map<std::string, double> stats = std::map<std::string, double>();
|
||||
Game game(2);
|
||||
|
||||
std::ofstream myfile;
|
||||
myfile.open ("score_stats.txt");
|
||||
|
||||
for(int i = 0; i < times; i++){
|
||||
game.play();
|
||||
auto player = game.bestPlayer;
|
||||
if(stats.find(player.score.name)==stats.end()){
|
||||
stats[player.score.name] = 0;
|
||||
}
|
||||
stats[player.score.name]++;
|
||||
|
||||
}
|
||||
|
||||
for(auto &kv : stats){
|
||||
std::cout<< kv.first << " " << kv.second / times * 100 << "% in the showdown" << std::endl;
|
||||
myfile << kv.first << " " << kv.second / times * 100 << "% in the showdown" << std::endl;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
stats.clear();
|
||||
game = Game(2);
|
||||
for(int i = 0; i < times; i++){
|
||||
game.playTheFlop();
|
||||
auto player = game.bestPlayer;
|
||||
if(stats.find(player.score.name)==stats.end()){
|
||||
stats[player.score.name] = 0;
|
||||
}
|
||||
stats[player.score.name]++;
|
||||
|
||||
}
|
||||
|
||||
for(auto &kv : stats){
|
||||
std::cout<< kv.first << " " << kv.second / times * 100 << "% in the flop" << std::endl;
|
||||
myfile << kv.first << " " << kv.second / times * 100 << "% in the flop" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
0
apps/score_stats.txt
Normal file
0
apps/score_stats.txt
Normal file
BIN
apps/score_stats_occurences
Executable file
BIN
apps/score_stats_occurences
Executable file
Binary file not shown.
91
apps/score_stats_occurences.cpp
Normal file
91
apps/score_stats_occurences.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
#include "../deck.hpp"
|
||||
#include "../simulate.hpp"
|
||||
#include "../game.hpp"
|
||||
#include <iostream>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
//32.4272
|
||||
//32.4241
|
||||
//32.4287
|
||||
//HA,DA 73.7738
|
||||
//DA,HA 72.5726
|
||||
|
||||
int main() {
|
||||
|
||||
int times = 100000;
|
||||
std::map<std::string, double> stats = std::map<std::string, double>();
|
||||
Game game(2);
|
||||
|
||||
std::cout << "This statistics shows the score occurence of every player, not only winners." << std::endl;
|
||||
std::cout << "HighCard is around 17%. It means that 1/5 cards dealt is worthless because highcard is arround 2% win rate." << std::endl;
|
||||
std::cout << "Winning statistics are in score_stats." << std::endl;
|
||||
std::ofstream myfile;
|
||||
myfile.open ("score_stats_occurences.txt");
|
||||
|
||||
for(int i = 0; i < times; i++){
|
||||
game.play();
|
||||
for(auto & player : game.players){
|
||||
if(stats.find(player.score.name)==stats.end()){
|
||||
stats[player.score.name] = 0;
|
||||
}
|
||||
stats[player.score.name]++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for(auto &kv : stats){
|
||||
std::cout<< kv.first << " " << kv.second / times / game.players.size() * 100 << "%" << std::endl;
|
||||
myfile << kv.first << " " << kv.second / times / game.players.size() * 100 << "%" << std::endl;
|
||||
}
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
0
apps/score_stats_occurences.txt
Normal file
0
apps/score_stats_occurences.txt
Normal file
60
card.hpp
Normal file
60
card.hpp
Normal file
@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
class Card
|
||||
{
|
||||
|
||||
public:
|
||||
std::string key;
|
||||
std::string kind;
|
||||
std::string value;
|
||||
int number = 0;
|
||||
double worth = 0;
|
||||
Card()
|
||||
{
|
||||
// NULL
|
||||
}
|
||||
|
||||
Card(const Card &card)
|
||||
{
|
||||
this->key = card.key;
|
||||
this->kind = card.kind;
|
||||
this->value = card.value;
|
||||
this->number = card.number;
|
||||
this->worth = card.worth;
|
||||
}
|
||||
|
||||
Card(std::string key)
|
||||
{
|
||||
this->key = key;
|
||||
this->kind = key.substr(0, 1);
|
||||
this->value = key.substr(1, key.length() - 1);
|
||||
this->number = valueToNumber(this->value);
|
||||
this->worth = this->number * 0.01;
|
||||
}
|
||||
|
||||
int valueToNumber(std::string alue)
|
||||
{
|
||||
if (value == "K")
|
||||
{
|
||||
return 13;
|
||||
}
|
||||
else if (value == "Q")
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
else if (value == "J")
|
||||
{
|
||||
return 11;
|
||||
}
|
||||
else if (value == "A")
|
||||
{
|
||||
return 14;
|
||||
}
|
||||
else
|
||||
{
|
||||
return stoi(value);
|
||||
}
|
||||
}
|
||||
};
|
10
cli.cpp
Normal file
10
cli.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "players/cli.hpp"
|
||||
#include "game.hpp"
|
||||
|
||||
int main() {
|
||||
Game game(2);
|
||||
CLIPlayer cliPlayer;
|
||||
game.players[1] = (Player)cliPlayer;
|
||||
game.play();
|
||||
return 0;
|
||||
}
|
84
deck.hpp
Normal file
84
deck.hpp
Normal file
@ -0,0 +1,84 @@
|
||||
#pragma once
|
||||
#include "card.hpp"
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <random>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
class Deck
|
||||
{
|
||||
|
||||
public:
|
||||
std::list<std::string> kinds = {"C", "D", "S", "H"};
|
||||
std::list<std::string> values = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
|
||||
|
||||
std::vector<Card> cards;
|
||||
size_t length = 0;
|
||||
Deck(std::string cardString = "", bool shuffle=true)
|
||||
{
|
||||
for (auto &kind : kinds)
|
||||
{
|
||||
for (auto &value : values)
|
||||
{
|
||||
std::string key = kind + value;
|
||||
Card card(key);
|
||||
this->cards.push_back(card);
|
||||
}
|
||||
}
|
||||
|
||||
if(shuffle == true)
|
||||
{
|
||||
std::random_device rd;
|
||||
std::mt19937 g(rd());
|
||||
std::shuffle(this->cards.begin(), this->cards.end(), g);
|
||||
}
|
||||
|
||||
std::string key;
|
||||
std::stringstream ss(cardString);
|
||||
while (std::getline(ss, key, ','))
|
||||
{
|
||||
if (this->deleteCard(key))
|
||||
{
|
||||
this->putCard(key);
|
||||
}
|
||||
}
|
||||
|
||||
this->length = this->cards.size();
|
||||
}
|
||||
bool deleteCard(std::string key)
|
||||
{
|
||||
for (int i = 0; i < this->cards.size(); i++)
|
||||
{
|
||||
if (this->cards[i].key == key)
|
||||
{
|
||||
this->cards.erase(this->cards.begin() + i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void putCard(std::string key)
|
||||
{
|
||||
this->deleteCard(key);
|
||||
Card card = Card(key);
|
||||
this->cards.insert(this->cards.begin(), card);
|
||||
}
|
||||
Card getCard()
|
||||
{
|
||||
Card card = this->cards[0];
|
||||
this->cards.erase(this->cards.begin(), this->cards.begin() + 1);
|
||||
this->length = this->cards.size();
|
||||
return card;
|
||||
}
|
||||
void print()
|
||||
{
|
||||
for (auto &card : this->cards)
|
||||
{
|
||||
std::cout << card.key << std::endl;
|
||||
}
|
||||
}
|
||||
};
|
172
game.hpp
Normal file
172
game.hpp
Normal file
@ -0,0 +1,172 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include "card.hpp"
|
||||
#include "deck.hpp"
|
||||
#include "player.hpp"
|
||||
#include "sort.hpp"
|
||||
#include "game_details.hpp"
|
||||
#define GAME_HPP
|
||||
|
||||
class Game
|
||||
{
|
||||
public:
|
||||
std::vector<Player> players;
|
||||
std::vector<Card> communityCards;
|
||||
int playerCount = 0;
|
||||
Deck deck;
|
||||
Player bestPlayer;
|
||||
Game(int playerCount)
|
||||
{
|
||||
this->playerCount = playerCount;
|
||||
for (int i = 0; i < playerCount; i++)
|
||||
{
|
||||
std::string name = std::string("Player ") + std::to_string(i + 1);
|
||||
this->players.push_back(Player(name));
|
||||
}
|
||||
|
||||
}
|
||||
GameDetails getGameDetails(){
|
||||
// TODO
|
||||
GameDetails gameDetails;
|
||||
//gameDetails
|
||||
return gameDetails;
|
||||
}
|
||||
void addCommunityCards(int amount)
|
||||
{
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
this->communityCards.push_back(this->deck.getCard());
|
||||
}
|
||||
sort_card_vector_ascending(this->communityCards);
|
||||
for(auto & player : this->players){
|
||||
player.setCommunityCards(this->communityCards);
|
||||
}
|
||||
}
|
||||
void thePreFlop()
|
||||
{
|
||||
for(auto & player : this->players){
|
||||
player.thePreFlop();
|
||||
}
|
||||
}
|
||||
void theFlop()
|
||||
{
|
||||
this->addCommunityCards(3);
|
||||
|
||||
|
||||
for(auto & player : this->players){
|
||||
player.theFlop();
|
||||
}
|
||||
}
|
||||
void theTurn()
|
||||
{
|
||||
this->addCommunityCards(1);
|
||||
for(auto & player : this->players){
|
||||
|
||||
player.theTurn();
|
||||
|
||||
}
|
||||
}
|
||||
void theRiver()
|
||||
{
|
||||
this->addCommunityCards(1);
|
||||
for (auto &player : this->players)
|
||||
{
|
||||
player.theRiver();
|
||||
}
|
||||
}
|
||||
void showdown()
|
||||
{
|
||||
for (auto &player : this->players)
|
||||
{
|
||||
player.showDown();
|
||||
}
|
||||
}
|
||||
|
||||
void updatePlayerStatistics() {
|
||||
for (auto &player : this->players)
|
||||
{
|
||||
player.update();
|
||||
player.score.calculate();
|
||||
}
|
||||
this->bestPlayer = this->players[0];
|
||||
for (auto &player : this->players)
|
||||
{
|
||||
if (player.score.score >= this->bestPlayer.score.score)
|
||||
this->bestPlayer = player;
|
||||
}
|
||||
for (auto &player : this->players)
|
||||
{
|
||||
if (player.score.score == this->bestPlayer.score.score)
|
||||
{
|
||||
if (player.name != this->bestPlayer.name)
|
||||
{
|
||||
// tie
|
||||
player.ties++;
|
||||
this->bestPlayer.ties++;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.wins++;
|
||||
// win
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.losses++;
|
||||
// loss
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void playTheFlop(std::string cardString = ""){
|
||||
this->start(cardString);
|
||||
this->thePreFlop();
|
||||
this->theFlop();
|
||||
this->updatePlayerStatistics();
|
||||
}
|
||||
|
||||
void start(std::string cardString = ""){
|
||||
this->deck = Deck(cardString);
|
||||
this->communityCards.clear();
|
||||
for (auto &player : this->players)
|
||||
{
|
||||
player.reset();
|
||||
Card card1 = this->deck.getCard();
|
||||
Card card2 = this->deck.getCard();
|
||||
player.setCards(card1, card2);
|
||||
}
|
||||
}
|
||||
|
||||
void play(std::string cardString = "")
|
||||
{
|
||||
this->start(cardString);
|
||||
this->thePreFlop();
|
||||
this->theFlop();
|
||||
this->theTurn();
|
||||
this->theRiver();
|
||||
this->showdown();
|
||||
this->updatePlayerStatistics();
|
||||
}
|
||||
void print()
|
||||
{
|
||||
std::cout << "Cards in deck: " << this->deck.length << std::endl;
|
||||
for (auto &player : this->players)
|
||||
{
|
||||
std::cout << player.name << ": ";
|
||||
for (auto &card : player.cards)
|
||||
{
|
||||
std::cout << card.key << ",";
|
||||
}
|
||||
std::cout << player.score.score << " ";
|
||||
std::cout << player.score.name << std::endl;
|
||||
}
|
||||
for (auto &card : this->communityCards)
|
||||
{
|
||||
std::cout << card.key << ",";
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
};
|
16
game_details.hpp
Normal file
16
game_details.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "card.hpp"
|
||||
#include "player.hpp"
|
||||
|
||||
class GameDetails {
|
||||
|
||||
public:
|
||||
std::vector<Card> playerCards;
|
||||
std::vector<Card> communityCards;
|
||||
double highestBed;
|
||||
std::vector<Player> players;
|
||||
|
||||
|
||||
|
||||
};
|
65
gui.hpp
Normal file
65
gui.hpp
Normal file
@ -0,0 +1,65 @@
|
||||
#include <vector>
|
||||
#include "card.hpp"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
class CardGui
|
||||
{
|
||||
public:
|
||||
std::string renderCard(std::string key)
|
||||
{
|
||||
Card card(key);
|
||||
std::string card_template;
|
||||
std::stringstream ss;
|
||||
std::string extra_top = " ";
|
||||
std::string extra_bottom = "_";
|
||||
if(card.value == "10"){
|
||||
extra_top = "";
|
||||
extra_bottom = "";
|
||||
}
|
||||
ss << "________ \n";
|
||||
ss << "|" << card.value << extra_top << " |\n";
|
||||
ss << "| " << card.kind << " |\n";
|
||||
ss << "| " << card.kind << " |\n";
|
||||
ss << "| " << card.kind << " |\n";
|
||||
ss << "|_____" << extra_bottom << card.value << "|\n";
|
||||
card_template = ss.str();
|
||||
return card_template;
|
||||
}
|
||||
|
||||
std::string getLine(std::string card_template, int n)
|
||||
{
|
||||
std::stringstream ss(card_template);
|
||||
std::string line;
|
||||
for (int i = 0; i < n; i++)
|
||||
std::getline(ss, line, '\n');
|
||||
return line;
|
||||
}
|
||||
|
||||
std::string renderCards(Card card1, Card card2){
|
||||
std::vector<Card> cards = std::vector<Card>();
|
||||
cards.push_back(card1);
|
||||
cards.push_back(card2);
|
||||
return this->renderCards(cards);
|
||||
}
|
||||
std::string renderCards(std::vector<Card> cards)
|
||||
{
|
||||
int lineHeight = 6;
|
||||
std::stringstream ss;
|
||||
std::vector<std::string> templates;
|
||||
for (auto &card : cards)
|
||||
{
|
||||
templates.push_back(this->renderCard(card.key));
|
||||
}
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
for (auto &tpl : templates)
|
||||
{
|
||||
ss << this->getLine(tpl, i) << " ";
|
||||
}
|
||||
ss << std::endl;
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
};
|
22
main.cpp
Normal file
22
main.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
#include "deck.hpp"
|
||||
#include "game.hpp"
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include "card.hpp"
|
||||
#include "simulate.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
std::string cardString="CA,DA";
|
||||
while(true) {
|
||||
std::cout << "Write cards. E.g. S6,DA: ";
|
||||
std::getline(std::cin, cardString);
|
||||
int times = 3000;
|
||||
bool silent = false;
|
||||
std::cout << simulate(cardString,times,2, silent) << "%" << " with two players in the flop." << std::endl << std::endl;
|
||||
std::cout << simulate(cardString,times,3, silent) << "%" << " with three players in the flop." << std::endl << std::endl;
|
||||
std::cout << simulate(cardString,times,5, silent) << "%" << " with five players in the flop." << std::endl << std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
105
player.hpp
Normal file
105
player.hpp
Normal file
@ -0,0 +1,105 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <iterator>
|
||||
#include "card.hpp"
|
||||
#include "score.hpp"
|
||||
#ifdef GAME_HPP
|
||||
#include "game.hpp"
|
||||
#endif
|
||||
|
||||
class Player
|
||||
{
|
||||
|
||||
public:
|
||||
int wins = 0;
|
||||
int losses = 0;
|
||||
int ties = 0;
|
||||
int chips = 1000;
|
||||
double winRate;
|
||||
double lossRate;
|
||||
double tieRate;
|
||||
std::string name;
|
||||
std::vector<Card> cards = {};
|
||||
std::vector<Card> communityCards;
|
||||
Score score;
|
||||
/*
|
||||
Player(const Player & player){
|
||||
this->name = player.name;
|
||||
//this->cards.assign(player.cards.begin(), player.cards.end());
|
||||
//this->cards.push_back(Card("SA"));
|
||||
//std::copy(player.cards.begin(), player.cards.end(), back_inserter(cards)); //std::vector(player.cards.begin(),player.cards.end());
|
||||
|
||||
//std::cout << "COPYP" << std::endl;
|
||||
// this->cardz = player.cardz;
|
||||
}*/
|
||||
|
||||
Player(std::string name = "John Doe")
|
||||
{
|
||||
this->name = name;
|
||||
}
|
||||
|
||||
int askUser() {
|
||||
std::cout << "Choose your option:" << std::endl;
|
||||
std::cout << "\t\t1) Check" << std::endl;
|
||||
std::cout << "\t\t2) Call" << std::endl;
|
||||
std::cout << "\t\t3) Raise" << std::endl;
|
||||
std::cout << "\t\t4) Fold" << std::endl;
|
||||
std::cout << "\t\t5) All-in" << std::endl;
|
||||
int answer = 0;
|
||||
std::cin >> answer;
|
||||
return answer;
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
this->cards.clear();
|
||||
this->communityCards.clear();
|
||||
this->cards.erase(this->cards.begin(), this->cards.end());
|
||||
this->communityCards.erase(this->communityCards.begin(), this->communityCards.end());
|
||||
this->score = Score();
|
||||
}
|
||||
void update()
|
||||
{
|
||||
double total = this->wins + this->losses + this->ties;
|
||||
this->winRate = this->wins / total * 100;
|
||||
this->lossRate = this->losses / total * 100;
|
||||
this->tieRate = this->ties / total * 100;
|
||||
|
||||
}
|
||||
void setCards(const Card card1, const Card card2)
|
||||
{
|
||||
this->cards.push_back(card1);
|
||||
this->cards.push_back(card2);
|
||||
this->score.setPlayerCards(this->cards);
|
||||
}
|
||||
void setCommunityCards(std::vector<Card> cards)
|
||||
{
|
||||
this->communityCards = cards;
|
||||
this->score.setCommunityCards(this->communityCards);
|
||||
}
|
||||
|
||||
void thePreFlop()
|
||||
|
||||
{
|
||||
}
|
||||
void theFlop()
|
||||
{
|
||||
|
||||
}
|
||||
void theTurn()
|
||||
{
|
||||
|
||||
}
|
||||
void theRiver()
|
||||
{
|
||||
|
||||
}
|
||||
void showDown()
|
||||
{
|
||||
this->update();
|
||||
}
|
||||
|
||||
};
|
10
players/cli.hpp
Normal file
10
players/cli.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#include "../player.hpp"
|
||||
|
||||
class CLIPlayer : public Player {
|
||||
|
||||
public:
|
||||
void thePreFlop(){
|
||||
std:: cout << " Preflop" << std::endl;
|
||||
}
|
||||
|
||||
};
|
BIN
poker-hand-cheat-sheet.pdf
Normal file
BIN
poker-hand-cheat-sheet.pdf
Normal file
Binary file not shown.
68
readme.md
Normal file
68
readme.md
Normal file
@ -0,0 +1,68 @@
|
||||
# Poker
|
||||
|
||||
## Todo
|
||||
- Sort cards on key everywhere in the game (Player hand / Community cards) to gain performance. E.g. with a string function converting SA,C2 to C2,S2.
|
||||
- Add parameter to card deck if to shuffle or not. Shuffled deck is not convenient for statistics
|
||||
- Uitzoeken hoe groot kansen tussenkaart
|
||||
- Uitzoeken kans op pair before turn
|
||||
according to ChatGPT: Calculating these values, the probability of being dealt a pair as your starting hand in Texas Hold'em is approximately 42.26% or about 1 in 2.37.
|
||||
- Uitzoeken kaarten met opeenlopende voordelen?
|
||||
- Uitzoeken hoeveel kans hoger paar / lager paar
|
||||
|
||||
|
||||
|
||||
## Observations
|
||||
|
||||
### Overal
|
||||
676 (52*0.5*52*0.5) combinations of pairs are possible.
|
||||
42% kans op pair in een pot????
|
||||
The probability of being dealt a pair as your starting hand in Texas Hold'em is approximately 5.88% or about 1 in 17.
|
||||
Pictures are high cards
|
||||
The probability of a high pair is approximately 0.45% or about 1 in 220.
|
||||
17% waardeloos EN 17% een pair (3 player setup)?
|
||||
|
||||
### Flop statistics
|
||||
There is 30% chance that you'll win with a high card.
|
||||
There is 56% chance that you'll win with a pair.
|
||||
|
||||
Flush 0.361%
|
||||
FourOfAKind 0.042%
|
||||
FullHouse 0.289%
|
||||
HighCard 30.077%
|
||||
OnePair 56.101%
|
||||
Straight 0.713%
|
||||
ThreeOfAKind 3.851%
|
||||
TwoPair 8.566%
|
||||
|
||||
### Worth of a pair
|
||||
There is 44% chance that you'll get a pair in combination with the community cards. A pair gives you a winning percentage of 30% when playing with three players.
|
||||
There is 17% chance that you'll get a pair as first hand.
|
||||
There is 7% chance that you'll get a high pair (J,Q,K,A) as first hand.
|
||||
There is 2% chance that you'll get an Ace or any specific pair as first hand.
|
||||
|
||||
### Recognize a full house scenario
|
||||
If three card kinds on table you won't have a full house but there is a posibility of 4 of a kind.
|
||||
|
||||
### One out of five dealings is worthless
|
||||
With 17% of the hands given you'll have a succesrate of 2% what equals the amount of winnings with a high card.
|
||||
|
||||
### Worth of a value 2 card.
|
||||
Only worth while in a pair and literal 50% survival score.
|
||||
|
||||
### Worth of a value 3 card.
|
||||
A value three card is worth more than 50% if played in combination with minimal a ace or as pair
|
||||
|
||||
### Worth of a value 4 card.
|
||||
A value four card is worth more than 50% if played in combination with minimal a king or as pair
|
||||
|
||||
### Worth of a value 5 card.
|
||||
A value five card is worth more than 50% if played in combination with minimal a queen or as pair
|
||||
|
||||
### Worth of a value 6 card.
|
||||
A value five card is worth more than 50% if played in combination with minimal a farmer or as pair
|
||||
|
||||
### Worth of a value 7 card.
|
||||
A value seven card is worth more than 50% if played in combination with minimal a 10 or in rare a 9
|
||||
|
||||
### Worth of a value 8 card.
|
||||
A value eight card is worth more than 50% if played in combination with minimal a 9 or as pair
|
267
score.hpp
Normal file
267
score.hpp
Normal file
@ -0,0 +1,267 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include "card.hpp"
|
||||
#include "sort.hpp"
|
||||
|
||||
class Score
|
||||
{
|
||||
|
||||
int countByNumber(int number)
|
||||
{
|
||||
int result = 0;
|
||||
for (auto &card : this->cards)
|
||||
{
|
||||
if (card.number == number)
|
||||
result++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
bool hasCard(int number)
|
||||
{
|
||||
for (auto &card : this->cards)
|
||||
if (card.number == number)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
bool hasCard(std::string kind, std::string value)
|
||||
{
|
||||
for (auto &card : this->cards)
|
||||
{
|
||||
if (card.kind == kind && card.value == value)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool hasCard(std::string kind, int number)
|
||||
{
|
||||
for (auto &card : this->cards)
|
||||
if (card.number == number && card.kind == kind)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
std::vector<Card> getCardsByKind(std::string kind)
|
||||
{
|
||||
std::vector<Card> result;
|
||||
for (auto &card : this->cards)
|
||||
{
|
||||
if (card.kind == kind)
|
||||
result.push_back(card);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public:
|
||||
std::vector<Card> playerCards;
|
||||
std::vector<Card> communityCards;
|
||||
std::vector<Card> cards;
|
||||
std::string name;
|
||||
double score = 0;
|
||||
Score()
|
||||
{
|
||||
}
|
||||
void calculate()
|
||||
{
|
||||
this->score = this->playerCards[0].worth;
|
||||
this->score += this->playerCards[1].worth;
|
||||
if (this->isRoyalFlush())
|
||||
{
|
||||
this->name = "RoyalFlush";
|
||||
this->score += 10;
|
||||
}
|
||||
else if (this->isStraightFlush())
|
||||
{
|
||||
this->name = "StraightFlush";
|
||||
this->score += 9;
|
||||
}
|
||||
else if (this->isFourOfAKind())
|
||||
{
|
||||
this->name = "FourOfAKind";
|
||||
this->score += 8;
|
||||
}
|
||||
else if (this->isFullHouse())
|
||||
{
|
||||
this->name = "FullHouse";
|
||||
this->score += 7;
|
||||
}
|
||||
else if (this->isFlush())
|
||||
{
|
||||
this->name = "Flush";
|
||||
this->score += 6;
|
||||
}
|
||||
else if (this->isStraight())
|
||||
{
|
||||
this->name = "Straight";
|
||||
this->score += 5;
|
||||
}
|
||||
else if (this->isThreeOfAKind())
|
||||
{
|
||||
this->name = "ThreeOfAKind";
|
||||
this->score += 4;
|
||||
}
|
||||
else if (this->isTwoPair())
|
||||
{
|
||||
this->name = "TwoPair";
|
||||
this->score += 3;
|
||||
}
|
||||
else if (this->isOnePair())
|
||||
{
|
||||
this->name = "OnePair";
|
||||
this->score += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->name = "HighCard";
|
||||
this->score += 1;
|
||||
Card highCart = this->playerCards[0].worth > this->playerCards[1].worth ? this->playerCards[0] : this->playerCards[1];
|
||||
this->score += highCart.worth;
|
||||
}
|
||||
}
|
||||
void setPlayerCards(std::vector<Card> cards)
|
||||
{
|
||||
for (auto &card : cards)
|
||||
{
|
||||
this->playerCards.push_back(card);
|
||||
sort_card_vector_ascending(this->playerCards);
|
||||
this->cards.push_back(card);
|
||||
sort_card_vector_ascending(this->cards);
|
||||
}
|
||||
}
|
||||
void setCommunityCards(std::vector<Card> cards)
|
||||
{
|
||||
for (auto &card : cards)
|
||||
{
|
||||
if(!this->hasCard(card.kind, card.number)){
|
||||
this->communityCards.push_back(card);
|
||||
sort_card_vector_ascending(this->communityCards);
|
||||
this->cards.push_back(card);
|
||||
sort_card_vector_ascending(this->cards);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool isRoyalFlush()
|
||||
{
|
||||
for (auto &card : this->cards)
|
||||
{
|
||||
bool isMatch = this->hasCard(card.kind, "A") && this->hasCard(card.kind, "K") && this->hasCard(card.kind, "Q") && this->hasCard(card.kind, "J") && this->hasCard(card.kind, "10");
|
||||
if (isMatch)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool isStraightFlush()
|
||||
{
|
||||
// Straight Flush: Five cards in sequence, all of the same suit.
|
||||
for (auto &card : this->cards)
|
||||
{
|
||||
bool valid = true;
|
||||
for (auto &card2 : this->getCardsByKind(card.kind))
|
||||
{
|
||||
for (int i = 1; i < 5; i++)
|
||||
{
|
||||
int number = card2.number + i;
|
||||
if (!this->hasCard(card2.kind, number))
|
||||
valid = false;
|
||||
}
|
||||
if (valid)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool isFourOfAKind()
|
||||
{
|
||||
// Four of a Kind: Four cards of the same rank.
|
||||
for (auto &card : this->cards)
|
||||
{
|
||||
if (this->countByNumber(card.number) >= 4)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool isFullHouse()
|
||||
{
|
||||
// Full House: Three cards of one rank and two cards of another rank.
|
||||
int previousNumber = 0;
|
||||
bool foundTwo = false;
|
||||
bool foundThree = false;
|
||||
for (auto &card : this->cards)
|
||||
{
|
||||
if (this->countByNumber(card.number) >= 3 && previousNumber != card.number)
|
||||
{
|
||||
previousNumber = card.number;
|
||||
foundThree = true;
|
||||
}
|
||||
else if (this->countByNumber(card.number) >= 2 && previousNumber != card.number)
|
||||
{
|
||||
previousNumber = card.number;
|
||||
foundTwo = true;
|
||||
}
|
||||
}
|
||||
return foundTwo && foundThree;
|
||||
}
|
||||
bool isFlush()
|
||||
{
|
||||
// Flush: Five cards of the same suit, not in sequence.
|
||||
for (auto &card : this->cards)
|
||||
{
|
||||
int count = 0;
|
||||
for (auto &card2 : this->cards)
|
||||
if (card.kind == card2.kind)
|
||||
count++;
|
||||
if (count == 5)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool isStraight()
|
||||
{
|
||||
for (auto &card : this->cards)
|
||||
{
|
||||
bool valid = true;
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
int number = card.number + i;
|
||||
if (!this->hasCard(number))
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
if (valid)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool isThreeOfAKind()
|
||||
{
|
||||
for (auto &card : this->cards)
|
||||
{
|
||||
if (this->countByNumber(card.number) >= 3)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool isTwoPair()
|
||||
{
|
||||
int pairCount = 0;
|
||||
int lastPairNumber = 0;
|
||||
for (auto &card : this->cards)
|
||||
{
|
||||
if (this->countByNumber(card.number) >= 2 && card.number != lastPairNumber)
|
||||
{
|
||||
lastPairNumber = card.number;
|
||||
pairCount++;
|
||||
}
|
||||
}
|
||||
return pairCount >= 2;
|
||||
}
|
||||
bool isOnePair()
|
||||
{
|
||||
for (auto &card : this->cards)
|
||||
{
|
||||
if (this->countByNumber(card.number) >= 2)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
30
simulate.hpp
Normal file
30
simulate.hpp
Normal file
@ -0,0 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include "deck.hpp"
|
||||
#include "game.hpp"
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include "card.hpp"
|
||||
|
||||
double simulate(std::string cardString = "", int times = 1000, int playerCount = 3, bool silent = true)
|
||||
{
|
||||
auto t1 = std::chrono::high_resolution_clock::now();
|
||||
Game game = Game(playerCount);
|
||||
|
||||
for (int i = 0; i < times; i++)
|
||||
{
|
||||
game.playTheFlop(cardString);
|
||||
|
||||
}
|
||||
if(!silent)
|
||||
for (auto &player : game.players)
|
||||
std::cout << player.winRate << "% " << player.cards[0].key << " " << player.cards[1].key << std::endl;
|
||||
|
||||
|
||||
auto t2 = std::chrono::high_resolution_clock::now();
|
||||
auto ms_int = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1);
|
||||
auto ms = ms_int.count();
|
||||
if(!silent)
|
||||
std::cout << "Executed " << times << " simulations in " << ms << "Ms" << std::endl;
|
||||
return game.players[0].winRate;
|
||||
}
|
11
sort.hpp
Normal file
11
sort.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
bool compareCards(Card card1, Card card2){
|
||||
return card1.key < card2.key;
|
||||
}
|
||||
|
||||
void sort_card_vector_ascending(std::vector<Card> v){
|
||||
std::sort(v.begin(),v.end(), compareCards);
|
||||
}
|
40
test.cpp
Normal file
40
test.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include "gui.hpp"
|
||||
#include <vector>
|
||||
#include "card.hpp"
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <any>
|
||||
#include "player.hpp"
|
||||
class BaseType {
|
||||
public:
|
||||
std::string name;
|
||||
|
||||
};
|
||||
|
||||
class AI : public Player {
|
||||
|
||||
};
|
||||
|
||||
void accept(Player * cls) {
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
CardGui cg;
|
||||
std::cout << cg.renderCard("CQ");
|
||||
std::vector<Card> v = std::vector<Card>();
|
||||
v.push_back(Card("C2"));
|
||||
v.push_back(Card("D5"));
|
||||
v.push_back(Card("S3"));
|
||||
v.push_back(Card("H10"));
|
||||
v.push_back(Card("H3"));
|
||||
v.push_back(Card("D2"));
|
||||
v.push_back(Card("C3"));
|
||||
std::cout << cg.renderCards(v);
|
||||
return 0;
|
||||
|
||||
AI ai();
|
||||
|
||||
accept((Player *)ai);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user