-
Notifications
You must be signed in to change notification settings - Fork 1
/
poker_parse.m
73 lines (62 loc) · 1.83 KB
/
poker_parse.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
dirname = '/Users/Zach/Desktop/MasterChef1/';
file_list = ls(dirname);
white_space = find(file_list == char(10));
file_names = cell(length(white_space),1);
for i = 1:length(white_space)
if i == 1
file_names{i} = file_list(1:white_space(i)-1);
else
file_names{i} = file_list(white_space(i-1)+1:white_space(i)-1);
end
end
nonzero_names = cell(0,1);
for i = 1:size(file_names,1)
if size(file_names{i},2) > 0
nonzero_names = [nonzero_names; file_names(i)];
end
end
file_names = nonzero_names;
file_names = sort(file_names);
used_files = cell(size(file_names,1)/2,1);
for i = 1:size(file_names,1)/2
used_files(i) = file_names(2*i);
end
file_names = used_files;
winner_array = zeros(length(file_names),1);
num_hands = zeros(length(file_names),1);
for i = 1:length(file_names)
the_file = [dirname file_names{i}];
fid = fopen(the_file);
score = zeros(0,2);
while 1
s = fgetl(fid);
if ~ischar(s)
break
elseif findstr(s,'Seat 1:')
par_open = findstr(s,'(');
par_close = findstr(s,')');
score1 = str2double(s(par_open(end)+1:par_close(end)-1));
t = fgetl(fid);
par_open = findstr(t,'(');
par_close = findstr(t,')');
score2 = str2double(t(par_open(end)+1:par_close(end)-1));
score = [score; score1 score2];
end
end
fclose(fid);
figure(1);
clf;
hold on;
plot(score(:,1),'b');
plot(score(:,2),'r');
legend('n00b','Master Chef',2);
xlabel('Hands');
if score(end,2) > score(end,1)
winner_array(i) = 1;
end
num_hands(i) = size(score,1);
pause(0.01);
end
avg_win = 100*mean(winner_array)
std_win = 100*sqrt(mean(winner_array)*(1-mean(winner_array))/length(winner_array))
avg_hands = mean(num_hands)