Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stars_in_rank = [5 5 5 5 5 5 5 5 5 5 ...
- 4 4 4 4 4 ...
- 3 3 3 3 3 ...
- 2 2 2 2 2];
- win_rate = 0.50:0.025:1.0;
- win_streak_limit = 5;
- no_lose_limit = 20;
- start_rank = 25;
- start_stars = 0;
- iters = 5000;
- game_recorder = zeros(length(win_rate), iters);
- % Loop over the different win rates
- wr_iter = 0;
- for wr = 1:length(win_rate)
- for i = 1:iters
- win_streak = 0;
- rank = start_rank;
- stars = start_stars;
- games_played = 0;
- while rank > 0
- % Play a game
- games_played = games_played + 1;
- % Win
- if rand() < win_rate(wr)
- win_streak = win_streak + 1;
- % Check win streak
- if win_streak >= 3 && rank > win_streak_limit
- stars = stars + 2;
- else
- stars = stars + 1;
- end
- % Check rank up
- if stars > stars_in_rank(rank)
- stars = stars - stars_in_rank(rank);
- rank = rank - 1;
- end
- %disp('win')
- %disp(['rank ' num2str(rank) ' stars ' num2str(stars)])
- % Lose
- else
- win_streak = 0;
- % Only lose stars if low enough rank
- if rank < no_lose_limit
- stars = stars - 1;
- end
- if stars < 0
- stars = stars_in_rank(rank) - 1;
- rank = rank + 1;
- end
- %disp('lose')
- %disp(['rank ' num2str(rank) ' stars ' num2str(stars) ' iter ' num2str(i)])
- end
- end
- game_recorder(wr, i) = games_played;
- end
- end
- plot(win_rate,mean(game_recorder,2),'o-')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement