Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patrice #12

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
53 changes: 35 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,61 @@
# MATLAB Fall 2014 – Research Plan (Template)
(text between brackets to be removed)

> * Group Name: (be creative!)
> * Group participants names: (alphabetically sorted by last name)
> * Project Title: (can be changed later)
> * Group Name: Royal Flush
> * Group participants names: Weber Tim, Lionel Gulich, Jan Speckien
> * Project Title: Active and passive strategies in Texas hold'em

## General Introduction
Texas hold’em is a variation of the card game of poker. The game is played with a 52-card deck that includes four suits: hearts, diamonds, clubs and spades with each 13 ranks. The ranking from the top down is: A, K, Q, J, 10, 9, 8, 7, 6, 5, 4, 3, and 2. All the players start with the same amount of money. When a player has no more money, he is eliminated. The goal is to be the last man standing with all the cash of the opponents. The game is played in rounds and every round is divided into four phases:
1) Every player gets handed two cards called the hold cards, these are used for one’s own benefit and kept secret for the others
2) Three cards are dealt on the table called “the flop”, from now on every player can make use of the cards on table
3) Then one more is dealt called “the turn”
4) A last card called “the river” is dealt

The rules are straight forward, in every phase one either:
- “folds” that means you don’t want to play anymore in this round
- “raises” that is when a player puts in more money on the table to play for
- “calls” which means you put in as much money as there is on the table
- “checks” that is when a player doesn’t want to do any of the above which is only possible when nobody has raised the pot.
As soon as somebody has raised the amount of money to play for the others have to call to get into the next phase or they drop out.

A player wins a round when all his opponents have folded their cards or at the end when comes to a “showdown” and every party has come to an agreement on how much money to play for, they show each other their cards and the player with the best combination of cards wins the round.

Texas hold’em is a game of strategy, psychology and probability and gamble. It often doesn’t even come to the showdown because a player makes another believe that he has the strongest hand through his way of raising the pot. Of course it is also possible to lure opponents into a trap or to just gamble, luck is involved after all.

Our goal is to research what style of play prevails in a heads-up in Texas hold’em. Even further, if time alouds it, how beneficiary learning the other’s pattern is to winning the game.
Our program is going to include a dealer whom is dealing a random numbers with a certain value, with that abstraction we avoid programming the complexity of all the combinations of cards. Players are going to make decisions based on the card’s value. Later on we want to include the height of a raise of the opponent into the decision making. A last step would be to give one of the players a learning effect with which he studies the pattern of the other player and plays accordingly.

(States your motivation clearly: why is it important / interesting to solve this problem?)
(Add real-world examples, if any)
(Put the problem into a historical context, from what does it originate? Are there already some proposed solutions?)

## The Model
There are a couple of variables that would be interesting to study, depending how far we come with our model.
- The first being the thresholds which decide how conservative/aggressive the players are and because of that what play style prevails
- The second one is the quality of the cards that are dealt and which impact that has on the outcome
- Further interesting are things like learning the opponents play style: can player A capitalise on a too aggressive player B after A has learnt B’s pattern to play. Or the other way around, that B starts to bluff A out of the game because A is too timid.

(Define dependent and independent variables you want to study. Say how you want to measure them.) (Why is your model a good abtraction of the problem you want to study?) (Are you capturing all the relevant aspects of the problem?)


## Fundamental Questions

(At the end of the project you want to find the answer to these questions)
(Formulate a few, clear questions. Articulate them in sub-questions, from the more general to the more specific. )
- Is an aggressive or a passive style of play the most successful in a heads-up in Texas hold'em?
- What influence does the quality of the cards have?
- What changes if a player can decide how much he wants to raise the pot?
- Will studying the opponent's pattern lead to a more successful outcome?


## Expected Results

(What are the answers to the above questions that you expect to find before starting your research?)
From personal experience we think the more aggressive player will be more successful over a long period of time.
But it all depends on how the risk-thresholds are set.


## References

(Add the bibliographic references you intend to use)
(Explain possible extension to the above models)
(Code / Projects Reports of the previous year)

-

## Research Methods

(Cellular Automata, Agent-Based Model, Continuous Modeling...) (If you are not sure here: 1. Consult your colleagues, 2. ask the teachers, 3. remember that you can change it afterwards)
We don't know yet what kind of model we are going to use but we guess cellular atomata might be interesting to show a learning effect.


## Other

(mention datasets you are going to use)

2 changes: 2 additions & 0 deletions code/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Code Folder

Your code goes here. You could also replace the content of this file with something more meaningful

The main executable file currently is "runheadsup.m"
9 changes: 9 additions & 0 deletions code/adjustRandValue.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function [ newRandValue ] = adjustRandValue( randValue, sigma )

newRandValue=-1;

while newRandValue<0 || newRandValue>1
newRandValue=sigma*randn+randValue;
end
end

182 changes: 182 additions & 0 deletions code/headsup.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@


function[EndCreditP1, EndCreditP2,x,Pot] = headsup(CP1,CP2,RiskP1,RiskP2) %Funktionsaufruf



%% S T A R T V A R I A B L E
Player_1 = RiskP1; %Risikobereitschaft P1
Player_2 = RiskP2; %Risikobereitschaft P2

BetValue = 1; %Einsatz
Blind = 1; %Blind-einsatz

CreditP1 = CP1;
CreditP2 = CP2;

PlayP1 = [0 0]; % [ Wert Karte P1 | Wert Bet P1 ]
PlayP2 = [0 0]; % [ Wert Karte P2 | Wert Bet P2 ]

%% S P I E L V A R I A B L E N


PlayP1(1) = rand; %Einstigskarte P1
PlayP2(1) = rand; %Einstigskarte P2

Pot = 0; % Geld im Pot
x = 0; % Anzahl Runden



%% Blind

PlayP1(2) = Blind;
PlayP2(2) = Blind;


%% P R E F L O P
% 1. W E T T R U N D E

if PlayP1(1) >= Player_1 % Raise bzw. Call P1
if CreditP1-PlayP1(2)>0
PlayP1(2) = PlayP1(2)+BetValue; % Gewetteter Betrag P1
end
end;
if PlayP2(1) >= Player_2 % Raise bzw. Call P2
if CreditP2-PlayP2(2)>0
PlayP2(2) = PlayP2(2)+BetValue; % Gewetteter Betrag P2
end
end;


%% F L O P
% 2. W E T T R U N D E

% 3 neue Karten
if PlayP1(2) > 0 && PlayP2(2) > 0 %Beide wollen Spielen

PlayP1(1) = adjustRandValue(PlayP1(1),.4); %Handkarten aktualisiert nach altem Kartenwert
PlayP2(1) = adjustRandValue(PlayP2(1),.4); %Handkarten aktualisiert nach altem Kartenwert


x= x +1; % Anzahl Runden

% E I N S A T Z A U F F L O P

% Obwohl schon Geld investiert wurde Gilt die Gleiche Grenze!

if PlayP1(1) >= Player_1 %Raise bzw. Call P1
if CreditP1-PlayP1(2)>0
PlayP1(2) = PlayP1(2)+1; %Achtung Bet ist immernoch 1
end
end;
if PlayP2(1) >= Player_2 % Raise bzw. Call P2
if CreditP2-PlayP2(2)>0
PlayP2(2) = PlayP2(2)+1;
end
end;
end;
%% T U R N
% 3. W E T T R U N D E
% 1 neue Karte
%if PlayP1(2) == 2 && PlayP2(2) == 2 %%%%%!!!!!!!!

if PlayP1(2) == PlayP2(2) %Beide wollen Spielen

PlayP1(1) = adjustRandValue(PlayP1(1),0.2); %Handkarten aktualisiert nach altem Kartenwert
PlayP2(1) = adjustRandValue(PlayP2(1),0.2); %Handkarten aktualisiert nach altem Kartenwert


x= x +1; % Anzahl Runden

% E I N S A T Z A U F T U R N


if PlayP1(1) >= Player_1 % Raise bzw. Call P1
if CreditP1-PlayP1(2)>0
PlayP1(2) = PlayP1(2)+1;
end
end;
if PlayP2(1) >= Player_2 % Raise bzw. Call P2
if CreditP2-PlayP2(2)>0
PlayP2(2) = PlayP2(2)+1;
end
end;

end;
%% R I V E R
% 4. W E T T R U N D E ------------------%
% 1 neue Karte

if PlayP1(2) == PlayP2(2) %Beide wollen Speilen
PlayP1(1) = adjustRandValue(PlayP1(1),0.1); %Handkarten aktualisiert nach altem Kartenwert
PlayP2(1) = adjustRandValue(PlayP2(1),0.1); %Handkarten aktualisiert nach altem Kartenwert


x= x +1; % Anzahl Runden

% E I N S A T Z A U F R I V E R


if PlayP1(1) >= Player_1 %Raise bzw. Call P1
if CreditP1-PlayP1(2)>0
PlayP1(2) = PlayP1(2)+1;
end
end;
if PlayP2(1) >= Player_2 % Raise bzw. Call P2
if CreditP2-PlayP2(2)>0
PlayP2(2) = PlayP2(2)+1;
end
end;
end;
%% R A N D O M

Pot = PlayP1(2) + PlayP2(2); %Pot
EndCreditP1 = CreditP1-PlayP1(2); %EndCreditP1
EndCreditP2 = CreditP2-PlayP2(2); %EndCreditP2
%% S H O W D O W N

if PlayP1(2) == Blind && PlayP2(2) == Blind %Kein Spiel
%disp('Draw: ');
%disp(Pot - PlayP1(2));
end;

if PlayP1(2) > PlayP2(2) %P2 Bietet nicht mehr
%disp('Player 1 Wins: ');
%disp(Pot - PlayP1(2));
EndCreditP1 = EndCreditP1+Pot;
end;

if PlayP1(2) < PlayP2(2) %P1 Bietet nicht mehr
%disp('Player 2 Wins:');
%disp(Pot - PlayP2(2));
EndCreditP2 = EndCreditP2+Pot;
end;

if PlayP1(2) == PlayP2(2) %beide Spielen ALLE Runden
%disp('SHOWDOWN')
if PlayP1(1) > PlayP2(1)
%disp('Player 1 Wins: ');
%disp(Pot - PlayP1(2));
EndCreditP1 = EndCreditP1+Pot;
elseif PlayP1(1) == PlayP2(1)
%disp('Draw');
EndCreditP1 = EndCreditP1+PlayP1(2);
EndCreditP2 = EndCreditP2+PlayP2(2);
elseif PlayP2(1) > PlayP1(1)
%disp('Player 2 Wins:');
%disp(Pot - PlayP2(2));
EndCreditP2 = EndCreditP2+Pot;
end;
end;





%% B I L A N Z

%% Bilanz = ['gespielte Runden ' num2str(x) ' EndCredit P1: ' num2str(EndCreditP1) '|' 'EndCredit P2: ' num2str(EndCreditP2)];
%%disp(Bilanz);

end %End of the Function
46 changes: 46 additions & 0 deletions code/main.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
%% Startvariablen


n = 1000 % Anzahl simulierter Spiele
RiskP1 = 0.3
RiskP2 = 0.4
Startkapital = 20


%% Auswertungsvariablen

WinsP1=0; % Anzahl Siege Player 1
WinsP2=0; % Anzahl Siege Player 2
Rounds=0;


%% Schleife f?r Pokerrunden

for i=1:n
ResultOfGame=runPokerGame(RiskP1,RiskP2,Startkapital);
Rounds = Rounds + ResultOfGame(3);
if ResultOfGame(4)==1
WinsP1=WinsP1+1;
elseif ResultOfGame(4)==2
WinsP2=WinsP2+1;
else
disp(ResultOfGame(4))
disp('Error with Result of Game')
end
end







%% Statistik und Auswertung

WinsP1=WinsP1/n*100;
WinsP2=WinsP2/n*100;
Rounds=Rounds/n;

sprintf('Wins Player 1: %d %', WinsP1)
sprintf('Wins Player 2: %d %', WinsP2)
sprintf('Average Rounds played: %d', Rounds)
Loading