Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear all; close all; clc
- %This script determines which players are most likely to win in the 2016
- %Blizzcon tournament
- %Deck lineups is a binary list with players as the columns
- deck_lineups=[1,1,1,1,0,1,1,0,1,1,1,1,0,1,1,1;0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0;1,1,0,1,1,0,1,0,0,0,0,1,0,1,0,0;0,0,0,0,0,1,0,0,1,1,1,0,0,0,0,1;0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0;0,1,0,0,1,1,0,0,1,0,1,1,1,1,1,1;0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0;0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0;1,0,1,1,0,0,0,0,0,0,0,0,0,0,1,0;1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1;0,0,1,1,1,0,1,0,0,0,0,1,1,0,0,0;1,0,1,0,0,1,0,0,1,1,1,0,0,1,1,1;0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0;0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0];
- players={'Handsomeguy','Cydonia','Jasonzhou','ThijsNL','BBgungun','Naiman','Che0nsu','Hamster','DrHippi','Breath','Amnesiacsc','Yulsic','OmegaZero','DdaHyoni','Pavel','HotMEOWTH'};
- decks={'Malygos Druid';'Ramp Druid';'Midrange Hunter';'Face Secret Hunter';'Freeze Mage';'Tempo Mage';'Anyfin Paladin';'Nzoth Priest';'Miracle Rogue';'Midrange Shaman';'Warlock Zoo';'Control Warrior';'Cthun Warrior';'Dragon Warrior'};
- %Deck matchups from vS Data Reaper Report
- deck_matchups=[0.500000000000,0.491071428571,0.509314794620,0.489650446956,0.700251874550,0.536059259259,0.534085769500,0.553534956795,0.558823059725,0.421712057563,0.372612470403,0.530384528476,0.488961488961,0.477513355998;0.508928571429,0.500000000000,0.458193979933,0.506591337100,0.726666666667,0.584750566893,0.440098661029,0.657575757576,0.487476434150,0.430501316865,0.477370689655,0.543793793794,0.375000000000,0.446428571429;0.490685205380,0.541806020067,0.500000000000,0.419484702093,0.693760459001,0.536483253589,0.688164893617,0.600775193798,0.478070175439,0.369210561173,0.407144902635,0.749700956938,0.694444444444,0.517850637523;0.510349553044,0.493408662900,0.580515297907,0.500000000000,0.688616251006,0.537187063635,0.528293010753,0.603772785078,0.633607701175,0.455229962477,0.431682721869,0.579533217511,0.541832219614,0.473299039227;0.299748125450,0.273333333333,0.306239540999,0.311383748994,0.500000000000,0.332898608882,0.602373231132,0.536637931034,0.595478723404,0.576345242854,0.534060113328,0.199220338983,0.083139534884,0.311940298507;0.463940740741,0.415249433107,0.463516746411,0.462812936365,0.667101391118,0.500000000000,0.546376811594,0.600411522634,0.497895231319,0.471326528819,0.442114188807,0.540508580493,0.480357142857,0.470456972841;0.465914230500,0.559901338971,0.311835106383,0.471706989247,0.397626768868,0.453623188406,0.500000000000,0.579623287671,0.379508556384,0.427387133412,0.548300536673,0.615283459965,0.665526315789,0.437500000000;0.446465043205,0.342424242424,0.399224806202,0.396227214922,0.463362068966,0.399588477366,0.420376712329,0.500000000000,0.355827236555,0.394338526976,0.497181113460,0.593264982440,0.515625000000,0.422669349430;0.441176940275,0.512523565850,0.521929824561,0.366392298825,0.404521276596,0.502104768681,0.620491443616,0.644172763445,0.500000000000,0.434904131758,0.480406955682,0.561468502295,0.567521729913,0.479344490934;0.578287942437,0.569498683135,0.630789438827,0.544770037523,0.423654757146,0.528673471181,0.572612866588,0.605661473024,0.565095868242,0.500000000000,0.551901714562,0.521635993652,0.598542873155,0.589920087657;0.627387529597,0.522629310345,0.592855097365,0.568317278131,0.465939886672,0.557885811193,0.451699463327,0.502818886540,0.519593044318,0.448098285438,0.500000000000,0.417985281548,0.488011988012,0.436013986014;0.469615471524,0.456206206206,0.250299043062,0.420466782489,0.800779661017,0.459491419507,0.384716540035,0.406735017560,0.438531497705,0.478364006348,0.582014718452,0.500000000000,0.351976450799,0.446584315927;0.511038511039,0.625000000000,0.305555555556,0.458167780386,0.916860465116,0.519642857143,0.334473684211,0.484375000000,0.432478270087,0.401457126845,0.511988011988,0.648023549201,0.500000000000,0.525869291998;0.522486644002,0.553571428571,0.482149362477,0.526700960773,0.688059701493,0.529543027159,0.562500000000,0.577330650570,0.520655509066,0.410079912343,0.563986013986,0.553415684073,0.474130708002,0.500000000000];
- gosu=[1111,1099,1081,1218,1052,1153,1058,1042,1198,1054,1079,983,1055,1040,1282,1121];
- player_count=size(players,2);
- %Track bans for post-ban deck populations
- bans=zeros(size(decks));
- %%Generate a player vs player matchup chart
- player_matchups=zeros(player_count);
- for player1=1:player_count
- for player2=1:player_count
- %Simulate the match
- %Determine the best ban
- %Find the best deck in player's lineup against opponent's lineup
- [junk,first_ban_1]=max((deck_matchups*deck_lineups(:,player2)).*deck_lineups(:,player1));
- [junk,first_ban_2]=max((deck_matchups*deck_lineups(:,player1)).*deck_lineups(:,player2));
- temp_lineup_1=deck_lineups(:,player1);
- temp_lineup_1(first_ban_1)=0;
- temp_lineup_2=deck_lineups(:,player2);
- temp_lineup_2(first_ban_2)=0;
- %Find best deck in opponent's lineup after their ban, ban that
- [junk,ban_1]=max((deck_matchups*temp_lineup_1).*deck_lineups(:,player2));
- [junk,ban_2]=max((deck_matchups*temp_lineup_2).*deck_lineups(:,player1));
- lineup_1=deck_lineups(:,player1);
- lineup_1(ban_2)=0;
- lineup_2=deck_lineups(:,player2);
- lineup_2(ban_1)=0;
- %keep track of bans
- if player1>player2
- bans(ban_1)=bans(ban_1)+1;
- bans(ban_2)=bans(ban_2)+1;
- end
- %Playout each match configuration
- %Find the probability that player 1 wins
- %For player 1 to win, he must win with each deck, assume both players choose decks randomly
- %from their remaining decks
- player_matchups(player1,player2)=match_round(lineup_1,lineup_2,deck_matchups,[0,0],4);%
- %Uncomment this line for Gosu-gamers skill correction
- %player_matchups(player1,player2)=player_matchups(player1,player2)*(gosu(player1)/gosu(player2))^(1/3);
- end
- end
- %%Double Elimination rounds
- %Go through each group
- advance_first=zeros(player_count,1);
- advance_second=zeros(player_count,1);
- for group=1:4
- group_set=((group-1)*4+1):(group*4);
- %Commenting first match, all others the same
- %Consider making this a function
- %Round 1
- %top and bottom represent the probability that each player fills that slot
- top=zeros(player_count,1);
- top(group_set(1))=1;
- bottom=zeros(player_count,1);
- bottom(group_set(2))=1;
- %Probabiity that each player wins, alternate matrix product with matchup matrix
- %and Hadamard product with opposing deck.
- round_1=(player_matchups*bottom).*top+(player_matchups*top).*bottom;
- %This is probability to lose (needed for double elimination)
- round_1_l=(player_matchups'*bottom).*top+(player_matchups'*top).*bottom;
- %Round 2
- top=zeros(player_count,1);
- top(group_set(3))=1;
- bottom=zeros(player_count,1);
- bottom(group_set(4))=1;
- round_2=(player_matchups*bottom).*top+(player_matchups*top).*bottom;
- round_2_l=(player_matchups'*bottom).*top+(player_matchups'*top).*bottom;
- %Winners
- top=round_1;
- bottom=round_2;
- advance_first=advance_first+(player_matchups*bottom).*top+(player_matchups*top).*bottom;
- winners_l=(player_matchups'*bottom).*top+(player_matchups'*top).*bottom;
- %Elimination
- top=round_1_l;
- bottom=round_2_l;
- elim=(player_matchups*bottom).*top+(player_matchups*top).*bottom;
- %Decider
- top=elim;
- bottom=winners_l;
- advance_second=advance_second+(player_matchups*bottom).*top+(player_matchups*top).*bottom;
- end
- %%Single Elimination rounds
- %From here I have to take a guess on how they split it up
- %Assume they put players from the same bracket on opposite sides
- %Assume they match up first and second advancers
- A_window=[1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0]';
- B_window=[0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0]';
- C_window=[0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0]';
- D_window=[0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1]';
- %Round 1
- %A1 B2
- top=A_window.*advance_first;
- bottom=B_window.*advance_second;
- round_1_1=(player_matchups*bottom).*top+(player_matchups*top).*bottom;
- %C1 D2
- top=C_window.*advance_first;
- bottom=D_window.*advance_second;
- round_1_2=(player_matchups*bottom).*top+(player_matchups*top).*bottom;
- %B1 A2
- top=B_window.*advance_first;
- bottom=A_window.*advance_second;
- round_1_3=(player_matchups*bottom).*top+(player_matchups*top).*bottom;
- %D1 C2
- top=D_window.*advance_first;
- bottom=C_window.*advance_second;
- round_1_4=(player_matchups*bottom).*top+(player_matchups*top).*bottom;
- %Semifinals
- top=round_1_1;
- bottom=round_1_2;
- round_2_1=(player_matchups*bottom).*top+(player_matchups*top).*bottom;
- top=round_1_3;
- bottom=round_1_4;
- round_2_2=(player_matchups*bottom).*top+(player_matchups*top).*bottom;
- %Finals
- top=round_2_1;
- bottom=round_2_2;
- final_odds=(player_matchups*bottom).*top+(player_matchups*top).*bottom;
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%LOCAL FUNCTIONS%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %This recursive function determines the probability of a game, then calls the
- %next game.
- %Output is the winrate for lineup_1 in a Last-Hero-Standing match.
- function [win_prob] = match_round (lineup_1, lineup_2, deck_matchups, wins_losses, max_wins)
- %check if match is over
- if wins_losses(1)==max_wins
- win_prob=1;
- return
- elseif wins_losses(2)==max_wins
- win_prob=0;
- return
- end
- %Find chances of winning with each deck
- win_1=(deck_matchups*lineup_2).*lineup_1/(sum(lineup_2)*sum(lineup_1));
- win_2=(deck_matchups*lineup_1).*lineup_2/(sum(lineup_2)*sum(lineup_1));
- %If you win
- win_prob=sum(win_1)*match_round(lineup_1-win_1/sum(win_1),lineup_2, deck_matchups,[wins_losses(1)+1 wins_losses(2)],max_wins);
- %if you lose
- win_prob=win_prob+sum(win_2)*match_round(lineup_1,lineup_2-win_2/sum(win_2),deck_matchups,[wins_losses(1) wins_losses(2)+1],max_wins);
- endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement