-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tournament.m
43 lines (32 loc) · 913 Bytes
/
run_tournament.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
function run_tournament(players, rows, columns, how_many_to_connect, games_to_play)
global difficulty
difficulty=0;
if ~exist('players','var')
players{1} = @greedy_player;
players{2} = @not_so_greedy_player;
end
if ~exist('rows','var')
rows = 6;
end
if ~exist('columns','var')
columns = 7;
end
if ~exist('how_many_to_connect','var')
how_many_to_connect = 4;
end
if ~exist('games_to_play','var')
games_to_play = 1000;
end
wins = zeros(1,length(players));
for game_index = 1:games_to_play
perm = randperm(length(players));
permuted_players = players(perm);
[permuted_winner_index, grid] = run_game(permuted_players, rows, columns, how_many_to_connect);
permuted_winner = zeros(1,length(players));
if permuted_winner_index > 0
permuted_winner(permuted_winner_index) = 1;
end
winner(perm) = permuted_winner;
wins = wins + winner;
end
wins