Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %% Anvil Comparisons
- % Edoweiss
- % 2018-04-12
- % In this script we perform a monte carlo simulations to estimate the cost
- % of making a brand new weapon versus attempting over and over on an
- % existing weapon using golden anvils
- close all; clear all; clc
- %% Simulations Targets/Parameters
- trials = 10000;
- available_potential = 8;
- targetLevel_List = [11 12 13 14 15 16 17 18 19 20 21];
- Level_List = [6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26];
- initial_level = 6; % initial level for the gold anvil case
- % costs in millions
- remakeCost_List = [8];
- goldenCost_List = [2.5 5 7.5 10];
- %% Upgrade Costs
- cTable = [ 52469
- 75104
- 97739
- 120374
- 143009
- 165643
- 188278
- 210913
- 233548
- 256183
- 348522
- 452179
- 567153
- 693445
- 831054
- 979980
- 1140224
- 1311785
- 1494664
- 1688860
- 1894373
- 2111204
- 2339353
- 2578819
- 2829602
- 3091702
- 3365120
- 3649856
- 3945909
- 4253279
- 4571967
- 4901972
- 5243294
- 5595934
- 5959892
- 6335166];
- %% Setup
- pTable = [ 1
- 1
- 1
- 1
- 1
- 0.88
- 0.78
- 0.68
- 0.59
- 0.51
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50
- 0.50 ];
- %% Perform Simulations across many different target levels
- attempt_Array_1 = [];
- diamond_Array = [];
- silver_Array_1 = [];
- %% Normal Anvils, Remaking Weapon
- for target_level = targetLevel_List
- attempt_List_1 = []; % number of new weapons made
- silver_List_1 = []; % amount of silver expended
- diamond_List = []; % number of diamond anvils expended
- for i = 1:trials
- % initiate trial
- pot = available_potential; % potential of the weapon
- lvl = 5; % current enhancement level
- silver = sum(cTable(1:5));
- attempts = 1; % total attempts using a new weapon
- dmd = 0;
- while lvl < target_level % keep trying until we make the target
- if pot > 0
- check = pTable(lvl+1);
- dmd = dmd + 1;
- silver = silver + 3*cTable(lvl+1);
- if rand < check % success
- lvl = lvl + 1; % increase the level
- else % failure
- lvl = lvl;
- pot = pot - 1;
- end
- end
- if pot == 0 % weapon broke
- attempts = attempts + 1; % make a new weapon
- pot = available_potential;
- end
- end
- attempt_List_1 = [attempt_List_1; attempts];
- diamond_List = [diamond_List; dmd];
- silver_List_1 = [silver_List_1; silver];
- end
- diamond_Array = [diamond_Array diamond_List];
- attempt_Array_1 = [attempt_Array_1 attempt_List_1];
- silver_Array_1 = [silver_Array_1 silver_List_1];
- end
- %% Diamond Anvils, One Weapon
- level_results = [];
- attempt_List = []; % number of new weapons made
- silver_List = []; % amount of silver expended
- for i = 1:trials
- % initiate trial
- pot = available_potential; % potential of the weapon
- lvl = 5; % current enhancement level
- silver = sum(cTable(1:5));
- attempts = 0; % total diamond anvils consumed
- while pot > 0 % keep trying until we make the target
- check = pTable(lvl+1);
- attempts = attempts + 1;
- silver = silver + 3*cTable(lvl+1);
- if rand < check % success
- lvl = lvl + 1; % increase the level
- else % failure
- pot = pot - 1;
- end
- if lvl == 35
- break
- end
- end
- level_results = [level_results; lvl];
- attempt_List = [attempt_List; attempts];
- silver_List = [silver_List; silver];
- end
- %%
- silver_Array_1 = silver_Array_1/10^6;
- %% Plot Results - attempts and enhancement cost
- % remaking weapons
- fig1 = figure; hold on
- xlabel('target enhancement')
- yyaxis left
- errorbar(targetLevel_List, mean(attempt_Array_1,1), std(attempt_Array_1,1))
- ylabel('weapons made')
- yyaxis right
- errorbar(targetLevel_List, mean(silver_Array_1,1), std(silver_Array_1,1))
- ylabel('cost of enhancements (million silver)')
- grid on
- hold off
- saveas(fig1,'remaking_diamond_01.png')
- % remaking weapons
- fig3 = figure; hold on
- xlabel('target enhancement')
- yyaxis left
- errorbar(targetLevel_List, mean(attempt_Array_1,1), std(attempt_Array_1,1))
- ylabel('weapons made')
- yyaxis right
- errorbar(targetLevel_List, mean(diamond_Array,1), std(diamond_Array,1))
- ylabel('diamond anvils used')
- grid on
- hold off
- saveas(fig3,'remaking_diamond_02.png')
- % trying until you run out
- fig2 = figure; hold on
- xlabel('enhancement level')
- ylabel('cumulative probability')
- histogram(level_results,'Normalization','cdf')
- saveas(fig2,'dia_cdf.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement