Ok so as some of you know i am working on a program that can calculate poker odds.
My programming skills are pretty bad... but i am an engineer so my professors dont care... i am just supposed to make it happen cuz i am engineer....
I am programming in Matlab but its rather similar to any other language.
So far i just found this code which works but is really complicated for me. Here is a link if you have Matlab and you wanna check it out.
http://www.mathworks.com/matlabcentral/ ... hange/6710
The only thing i realized after a day of studying this is that you have to use the "Monte Carlo" method. In other words you cant use equations to predict odds because it will be just too complicated.
If you have Matlab and have some free time feel free to help me out. I am struggling with analyzing this code. I would post the code but i am not sure how cuz its too big.
Cheers
I am working on this right now - Matlab -Poker
- isapiens
- Fame ! Where are the chicks?!
- Posts: 533
- Joined: 05 May 2006, 16:00
- 17
- Location: Turn around
I am working on this right now - Matlab -Poker
Fluoridation is the most monstrously conceived and dangerous communist plot we have ever had to face.
- isapiens
- Fame ! Where are the chicks?!
- Posts: 533
- Joined: 05 May 2006, 16:00
- 17
- Location: Turn around
screw that program, i have no idea how it works. So i decided to start writing on my own. Here is what i got so far:
I can hand out cards to up to 9 people + the flop. I have no idea how to start detecting hands and stuff....
I can hand out cards to up to 9 people + the flop. I have no idea how to start detecting hands and stuff....
Code: Select all
player_name = {'Jack', 'Smith', 'Dan', 'Rob', 'Gabe', 'Lucy', 'Lexi', 'Tom', 'Houl' }; %all player names
card_slots = {'0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' }; %all card slots
flop_slots = { '0' '0' '0' '0' '0' '0' '0' '0'};
player_num = input('how many players?'); %ask how many people are playing
player_name(player_num+1:end) = [] %Delete the players and show who plays
card_slots(player_num*2+1:end) = [] %Delete card slots and show the rest if slots
deck = {'2C', '2D', '2S', '2H',...
'3C', '3D', '3S', '3H',...
'4C', '4D', '4S', '4H',...
'5C', '5D', '5S', '5H',...
'6C', '6D', '6S', '6H',...
'7C', '7D', '7S', '7H',...
'8C', '8D', '8S', '8H',...
'9C', '9D', '9S', '9H',...
'TC', 'TD', 'TS', 'TH',...
'JC', 'JD', 'JS', 'JH',...
'QC', 'QD', 'QS', 'QH',...
'KC', 'KD', 'KS', 'KH',...
'AC', 'AD', 'AS', 'AH'};
a=52; %Deck of cards
n=size(card_slots,2)%how many cards to deal
%Deal Cards and Remove Cards from the Deck
for i=1:n
tmp = randint(1,1,a);
card_slots(i)=deck(tmp+1);
a=a-1;
deck(tmp+1)=[];
end
card_slots
%Deal the Flop
a=52-size(card_slots,2);
for j=1:8
tmp = randint(1,1,a);
flop_slots(j) = deck(tmp+1);
a=a-1;
deck(tmp+1)=[];
end
flop_slots
n=size(card_slots,2)%how many cards to deal;
n=n*2;
k=1;
hand = str2mat(card_slots) %converting strings for comparison;
%Check if anyone has a pair (no flop yet)
for i=1:n
if hand(k) == hand(k+1)
k=k+2;
pair = 1
else
pair=0;
end
end
Fluoridation is the most monstrously conceived and dangerous communist plot we have ever had to face.
- floodhound2
- ∑lectronic counselor
- Posts: 2117
- Joined: 03 Sep 2006, 16:00
- 17
- Location: 127.0.0.1
- Contact:
- Still_Learning
- Fame ! Where are the chicks?!
- Posts: 1040
- Joined: 11 Jun 2008, 16:00
- 15
- Location: Trigger City
- isapiens
- Fame ! Where are the chicks?!
- Posts: 533
- Joined: 05 May 2006, 16:00
- 17
- Location: Turn around
ye, its for a project. Its really stupid, because its a probability class, but this program does not really require any probaility skills. Its all for loops and such. whatever.
Ok,floodhound2, lol i hope you are right. Its due Monday. I will work on it today and tomorrow and post what i got.
Ok,floodhound2, lol i hope you are right. Its due Monday. I will work on it today and tomorrow and post what i got.
Fluoridation is the most monstrously conceived and dangerous communist plot we have ever had to face.
- isapiens
- Fame ! Where are the chicks?!
- Posts: 533
- Joined: 05 May 2006, 16:00
- 17
- Location: Turn around
ok i need help... i guess i am just retarded.
So far i managed to to write a program that deals you hands. so you got this for example
hand = [2AJ4A89] (first 2 is what you have and the rest is the flop)
suit = [DCHHDCS] (the suits)
i just cant see an easy way to look for pairs...
there is a command i found called findstr()
so you could do num= findstr('A')
a= length(num)
this will tell you how many Aces are out there. However, this will take me forever, i would have to do it for every single type of a card... is there an easier way i am missing?
So far i managed to to write a program that deals you hands. so you got this for example
hand = [2AJ4A89] (first 2 is what you have and the rest is the flop)
suit = [DCHHDCS] (the suits)
i just cant see an easy way to look for pairs...
there is a command i found called findstr()
so you could do num= findstr('A')
a= length(num)
this will tell you how many Aces are out there. However, this will take me forever, i would have to do it for every single type of a card... is there an easier way i am missing?
Fluoridation is the most monstrously conceived and dangerous communist plot we have ever had to face.
- floodhound2
- ∑lectronic counselor
- Posts: 2117
- Joined: 03 Sep 2006, 16:00
- 17
- Location: 127.0.0.1
- Contact:
take a look at this pdf
http://www.math.siu.edu/matlab/tutorial2.pdf
Also you may want to get some old paper and a pen out. This can save time by designing a flow chart.
Just got an idea.
What if you took all the cards and gave them a numerical value.
1-10 = 1-10
Jack = 11
queen = 12
king = 13
ace = 14
Then take your hands and add them up.
say i have a Ace[clubs], 4[clubs], 3[hearts], 2[diamonds], king[hearts]
my total would be 14+4+3+2+13 = 36.
Next would be a multiplier i.e. [clubs], [hearts], [diamonds], [spades]
I can imagine this would work. Ill need a bit more time on it but I can imagine you could even predict some statical values based on the hand.
http://www.math.siu.edu/matlab/tutorial2.pdf
Also you may want to get some old paper and a pen out. This can save time by designing a flow chart.
Just got an idea.
What if you took all the cards and gave them a numerical value.
1-10 = 1-10
Jack = 11
queen = 12
king = 13
ace = 14
Then take your hands and add them up.
say i have a Ace[clubs], 4[clubs], 3[hearts], 2[diamonds], king[hearts]
my total would be 14+4+3+2+13 = 36.
Next would be a multiplier i.e. [clubs], [hearts], [diamonds], [spades]
I can imagine this would work. Ill need a bit more time on it but I can imagine you could even predict some statical values based on the hand.
- isapiens
- Fame ! Where are the chicks?!
- Posts: 533
- Joined: 05 May 2006, 16:00
- 17
- Location: Turn around
woho got it anyways. very ugly code. just used bunch of if and for statements. its like 1500 lines of code. Thanks for the help though. I used the ranking idea and it worked.
Ye... i gota start planning before i get into coding.
thanks guys.
Ye... i gota start planning before i get into coding.
thanks guys.
Fluoridation is the most monstrously conceived and dangerous communist plot we have ever had to face.