This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
dom6:fearbattleenchantmentssimulationcode [2024/12/18 18:35] isitaris created |
dom6:fearbattleenchantmentssimulationcode [2024/12/18 18:40] (current) isitaris |
||
|---|---|---|---|
| Line 138: | Line 138: | ||
| print(moraleMalus) | print(moraleMalus) | ||
| roundCountCurrent = tickCount // 7500 | roundCountCurrent = tickCount // 7500 | ||
| + | | ||
| # end of battle, unit hasn't routed yet (this is dom5 number, gotta check new dom6 end of turn stuff) | # end of battle, unit hasn't routed yet (this is dom5 number, gotta check new dom6 end of turn stuff) | ||
| if roundCountCurrent > 100: # turn 100: battle enchantents end | if roundCountCurrent > 100: # turn 100: battle enchantents end | ||
| Line 335: | Line 335: | ||
| unitHasRouted = True | unitHasRouted = True | ||
| moraleCheckCount = 1 | moraleCheckCount = 1 | ||
| + | | ||
| # new round, chance of morale malus to decay, and wailing winds will be able to try a rout one more time | # new round, chance of morale malus to decay, and wailing winds will be able to try a rout one more time | ||
| if roundCountNew > roundCountCurrent: | if roundCountNew > roundCountCurrent: | ||
| Line 343: | Line 343: | ||
| print(moraleMalus) | print(moraleMalus) | ||
| roundCountCurrent = tickCount // 7500 | roundCountCurrent = tickCount // 7500 | ||
| + | | ||
| # end of battle, unit hasn't routed yet (this is dom5 number, gotta check new dom6 end of turn stuff) | # end of battle, unit hasn't routed yet (this is dom5 number, gotta check new dom6 end of turn stuff) | ||
| if roundCountCurrent > 100: # turn 100: battle enchantents end | if roundCountCurrent > 100: # turn 100: battle enchantents end | ||
| unitHasRouted = True | unitHasRouted = True | ||
| + | | ||
| roundCountCurrent = 130 #debug value | roundCountCurrent = 130 #debug value | ||
| return roundCountCurrent | return roundCountCurrent | ||
| + | | ||
| # did I actually finish those DOM5 versions? to be checked | # did I actually finish those DOM5 versions? to be checked | ||
| def DOM5_wailingBattleSim_squad(unitMorale = 10, bloodRainActive = 0, squadSize = 1, unitDensity = 1, debug = 0): | def DOM5_wailingBattleSim_squad(unitMorale = 10, bloodRainActive = 0, squadSize = 1, unitDensity = 1, debug = 0): | ||
| Line 366: | Line 366: | ||
| tickCount += 320 | tickCount += 320 | ||
| roundCountNew = tickCount // 7500 | roundCountNew = tickCount // 7500 | ||
| + | | ||
| for squadSquare_i in range(squadSquareSize): | for squadSquare_i in range(squadSquareSize): | ||
| # Wailing Winds effect | # Wailing Winds effect | ||
| Line 376: | Line 376: | ||
| if moraleMalus[unitID] < frightenMalusLimit: | if moraleMalus[unitID] < frightenMalusLimit: | ||
| moraleMalus[unitID] += 1 | moraleMalus[unitID] += 1 | ||
| + | | ||
| # in DOM5 there is no individual rout | # in DOM5 there is no individual rout | ||
| # if moraleCheckCount_easier[unitID] == 0 and unitHasRouted[unitID] == False and moraleCheckFailureIndividual(unitMorale, | # if moraleCheckCount_easier[unitID] == 0 and unitHasRouted[unitID] == False and moraleCheckFailureIndividual(unitMorale, | ||
| Line 383: | Line 383: | ||
| # if debug == 1: | # if debug == 1: | ||
| # | # | ||
| + | | ||
| moraleCheckCount_easier[unitID] = 1 | moraleCheckCount_easier[unitID] = 1 | ||
| + | | ||
| unitMoraleProblems[: | unitMoraleProblems[: | ||
| unitMoraleProblems[unitID] += 1000 | unitMoraleProblems[unitID] += 1000 | ||
| + | | ||
| if np.max(unitMoraleProblems) >= 10000: # or 5 cases depending on surviving number of squad members; issue is those cases look at whether the unit is alive, not routed. So it's hard to check in a sim without fighting; maybe ignore for now | if np.max(unitMoraleProblems) >= 10000: # or 5 cases depending on surviving number of squad members; issue is those cases look at whether the unit is alive, not routed. So it's hard to check in a sim without fighting; maybe ignore for now | ||
| if moraleCheckCount == 0 and unitHasRouted[unitID] == False and moraleCheckFailureStandard_squad(moraleDomAverage(squadSize, | if moraleCheckCount == 0 and unitHasRouted[unitID] == False and moraleCheckFailureStandard_squad(moraleDomAverage(squadSize, | ||
| Line 396: | Line 396: | ||
| print(" | print(" | ||
| moraleCheckCount = 1 | moraleCheckCount = 1 | ||
| + | | ||
| # new round, chance of morale malus to decay, and wailing winds will be able to try a rout one more time | # new round, chance of morale malus to decay, and wailing winds will be able to try a rout one more time | ||
| if roundCountNew > roundCountCurrent: | if roundCountNew > roundCountCurrent: | ||
| Line 418: | Line 418: | ||
| print(" | print(" | ||
| return unitRoutRound | return unitRoutRound | ||
| - | + | | |
| - | + | ||
| + | |||
| ######################################################################################################################## | ######################################################################################################################## | ||
| ########################### | ########################### | ||
| ######################################################################################################################## | ######################################################################################################################## | ||
| - | + | | |
| + | |||
| def wailingExpectedRout_commanders(unitMorale = 10, bloodRainActive = 0, wailingWindsActive = 1, nIteration = 1000): | def wailingExpectedRout_commanders(unitMorale = 10, bloodRainActive = 0, wailingWindsActive = 1, nIteration = 1000): | ||
| roundExpectedRout = 0 | roundExpectedRout = 0 | ||
| Line 434: | Line 434: | ||
| roundExpectedRout+=routRound | roundExpectedRout+=routRound | ||
| return 1./ | return 1./ | ||
| + | | ||
| def makeWailingRoutDistrib_commanders(unitMorale = 10, bloodRainActive = 0, wailingWindsActive = 1, nIteration = 1000, isDOM5 = 0): | def makeWailingRoutDistrib_commanders(unitMorale = 10, bloodRainActive = 0, wailingWindsActive = 1, nIteration = 1000, isDOM5 = 0): | ||
| routingTime = [] | routingTime = [] | ||
| Line 446: | Line 446: | ||
| routingTime = np.array(routingTime) | routingTime = np.array(routingTime) | ||
| return routingTime | return routingTime | ||
| + | | ||
| def makeWailingRoutDistrib_squad(unitMorale = 10, bloodRainActive = 0, wailingWindsActive = 1, squadSize = 1, unitDensity = 1, nIteration = 1000, isDOM5 = 0): | def makeWailingRoutDistrib_squad(unitMorale = 10, bloodRainActive = 0, wailingWindsActive = 1, squadSize = 1, unitDensity = 1, nIteration = 1000, isDOM5 = 0): | ||
| nRounds = 100 | nRounds = 100 | ||
| Line 461: | Line 461: | ||
| routedRatio = routedRatio * 1./ | routedRatio = routedRatio * 1./ | ||
| return routedRatio | return routedRatio | ||
| + | | ||
| def makeFearMoraleMalusAverageDistrib(unitMorale = 10, bloodRainActive = 0, wailingWindsActive = 1, nIteration = 1000): | def makeFearMoraleMalusAverageDistrib(unitMorale = 10, bloodRainActive = 0, wailingWindsActive = 1, nIteration = 1000): | ||
| nRounds = 100 | nRounds = 100 | ||
| Line 472: | Line 472: | ||
| return moraleMalusAverage | return moraleMalusAverage | ||
| # makeFearMoraleMalusAverageDistrib(10, | # makeFearMoraleMalusAverageDistrib(10, | ||
| - | + | | |
| - | + | ||
| + | |||
| ################################################################################################################ | ################################################################################################################ | ||
| ########################### | ########################### | ||
| ################################################################################################################ | ################################################################################################################ | ||
| + | | ||
| def plotHistograms_commanders(nDistribs, | def plotHistograms_commanders(nDistribs, | ||
| + | | ||
| nBins = 140 | nBins = 140 | ||
| fig, ax = plt.subplots() | fig, ax = plt.subplots() | ||
| Line 486: | Line 486: | ||
| ax.set_xlabel(' | ax.set_xlabel(' | ||
| ax.set_ylabel(' | ax.set_ylabel(' | ||
| + | | ||
| if option == " | if option == " | ||
| colourMap = plt.get_cmap(" | colourMap = plt.get_cmap(" | ||
| else: | else: | ||
| colourMap = plt.get_cmap(" | colourMap = plt.get_cmap(" | ||
| + | | ||
| for i in range(nDistribs): | for i in range(nDistribs): | ||
| if option == " | if option == " | ||
| Line 497: | Line 497: | ||
| else: | else: | ||
| ax.hist(routingTimeDistrib_collection[i], | ax.hist(routingTimeDistrib_collection[i], | ||
| - | + | | |
| + | |||
| # Create new legend handles but use the colors from the existing ones | # Create new legend handles but use the colors from the existing ones | ||
| handles, labels = ax.get_legend_handles_labels() | handles, labels = ax.get_legend_handles_labels() | ||
| Line 507: | Line 507: | ||
| else: | else: | ||
| new_handles = [Line2D([], [], c=handles[i].get_edgecolor()) for i in range(nDistribs)] | new_handles = [Line2D([], [], c=handles[i].get_edgecolor()) for i in range(nDistribs)] | ||
| + | | ||
| # plt.legend(handles=new_handles, | # plt.legend(handles=new_handles, | ||
| + | | ||
| ax.legend(handles=new_handles, | ax.legend(handles=new_handles, | ||
| ax.label_outer() | ax.label_outer() | ||
| + | | ||
| plt.xlim(xmin=0, | plt.xlim(xmin=0, | ||
| plt.ylim(ymin=0, | plt.ylim(ymin=0, | ||
| plt.gca().yaxis.set_major_formatter(mtick.PercentFormatter(xmax=1.0)) # transforms y-axis in % format | plt.gca().yaxis.set_major_formatter(mtick.PercentFormatter(xmax=1.0)) # transforms y-axis in % format | ||
| + | | ||
| plt.title(pltTitle) | plt.title(pltTitle) | ||
| + | | ||
| fig.tight_layout() # otherwise the right y-label is slightly clipped | fig.tight_layout() # otherwise the right y-label is slightly clipped | ||
| fig.tight_layout() # for some reason gotta call it twice for the top title to not be cropped | fig.tight_layout() # for some reason gotta call it twice for the top title to not be cropped | ||
| - | + | | |
| + | |||
| # x-axis: major ticks every 20, minor ticks every 5 | # x-axis: major ticks every 20, minor ticks every 5 | ||
| major_ticks_x = np.arange(0, | major_ticks_x = np.arange(0, | ||
| Line 529: | Line 529: | ||
| major_ticks_y = np.arange(0, | major_ticks_y = np.arange(0, | ||
| minor_ticks_y = np.arange(0, | minor_ticks_y = np.arange(0, | ||
| + | | ||
| ax.set_xticks(major_ticks_x) | ax.set_xticks(major_ticks_x) | ||
| ax.set_xticks(minor_ticks_x, | ax.set_xticks(minor_ticks_x, | ||
| ax.set_yticks(major_ticks_y) | ax.set_yticks(major_ticks_y) | ||
| ax.set_yticks(minor_ticks_y, | ax.set_yticks(minor_ticks_y, | ||
| + | | ||
| ax.grid(which=' | ax.grid(which=' | ||
| + | | ||
| ax.grid(which=' | ax.grid(which=' | ||
| ax.grid(which=' | ax.grid(which=' | ||
| + | | ||
| # save figure in ./ | # save figure in ./ | ||
| script_dir = os.path.dirname(__file__) | script_dir = os.path.dirname(__file__) | ||
| results_dir = os.path.join(script_dir, | results_dir = os.path.join(script_dir, | ||
| results_dir_png = os.path.join(script_dir, | results_dir_png = os.path.join(script_dir, | ||
| + | | ||
| if not os.path.isdir(results_dir): | if not os.path.isdir(results_dir): | ||
| os.makedirs(results_dir) | os.makedirs(results_dir) | ||
| if not os.path.isdir(results_dir_png): | if not os.path.isdir(results_dir_png): | ||
| os.makedirs(results_dir_png) | os.makedirs(results_dir_png) | ||
| + | | ||
| if option == " | if option == " | ||
| plt.show() | plt.show() | ||
| Line 555: | Line 555: | ||
| plt.savefig(results_dir_png+pdfName+' | plt.savefig(results_dir_png+pdfName+' | ||
| | | ||
| + | | ||
| def plotHistograms_squad(nDistribs, | def plotHistograms_squad(nDistribs, | ||
| + | | ||
| fig, ax = plt.subplots() | fig, ax = plt.subplots() | ||
| color1 = ' | color1 = ' | ||
| ax.set_xlabel(' | ax.set_xlabel(' | ||
| ax.set_ylabel(' | ax.set_ylabel(' | ||
| + | | ||
| if option == " | if option == " | ||
| colourMap = plt.get_cmap(" | colourMap = plt.get_cmap(" | ||
| else: | else: | ||
| colourMap = plt.get_cmap(" | colourMap = plt.get_cmap(" | ||
| + | | ||
| nRounds = 100 # x-axis bin size | nRounds = 100 # x-axis bin size | ||
| for i in range(nDistribs): | for i in range(nDistribs): | ||
| Line 574: | Line 574: | ||
| else: | else: | ||
| ax.plot(np.array(range(nRounds)), | ax.plot(np.array(range(nRounds)), | ||
| + | | ||
| # Create new legend handles but use the colors from the existing ones | # Create new legend handles but use the colors from the existing ones | ||
| handles, labels = ax.get_legend_handles_labels() | handles, labels = ax.get_legend_handles_labels() | ||
| Line 583: | Line 583: | ||
| else: | else: | ||
| new_handles = [Line2D([], [], c=handles[i].get_color()) for i in range(nDistribs)] | new_handles = [Line2D([], [], c=handles[i].get_color()) for i in range(nDistribs)] | ||
| + | | ||
| ax.legend(handles=new_handles, | ax.legend(handles=new_handles, | ||
| ax.label_outer() | ax.label_outer() | ||
| + | | ||
| plt.xlim(xmin=0, | plt.xlim(xmin=0, | ||
| plt.ylim(ymin=0, | plt.ylim(ymin=0, | ||
| plt.gca().yaxis.set_major_formatter(mtick.PercentFormatter(xmax=1.0)) # transforms y-axis in % format | plt.gca().yaxis.set_major_formatter(mtick.PercentFormatter(xmax=1.0)) # transforms y-axis in % format | ||
| + | | ||
| plt.title(pltTitle) | plt.title(pltTitle) | ||
| + | | ||
| fig.tight_layout() # otherwise the right y-label is slightly clipped | fig.tight_layout() # otherwise the right y-label is slightly clipped | ||
| fig.tight_layout() # for some reason gotta call it twice for the top title to not be cropped | fig.tight_layout() # for some reason gotta call it twice for the top title to not be cropped | ||
| - | + | | |
| + | |||
| # setting up the grid and the ticks on the axes: | # setting up the grid and the ticks on the axes: | ||
| + | | ||
| # x-axis: major ticks every 20, minor ticks every 5 | # x-axis: major ticks every 20, minor ticks every 5 | ||
| major_ticks_x = np.arange(0, | major_ticks_x = np.arange(0, | ||
| Line 605: | Line 605: | ||
| major_ticks_y = np.arange(0, | major_ticks_y = np.arange(0, | ||
| minor_ticks_y = np.arange(0, | minor_ticks_y = np.arange(0, | ||
| + | | ||
| ax.set_xticks(major_ticks_x) | ax.set_xticks(major_ticks_x) | ||
| ax.set_xticks(minor_ticks_x, | ax.set_xticks(minor_ticks_x, | ||
| ax.set_yticks(major_ticks_y) | ax.set_yticks(major_ticks_y) | ||
| ax.set_yticks(minor_ticks_y, | ax.set_yticks(minor_ticks_y, | ||
| + | | ||
| ax.grid(which=' | ax.grid(which=' | ||
| + | | ||
| ax.grid(which=' | ax.grid(which=' | ||
| ax.grid(which=' | ax.grid(which=' | ||
| + | | ||
| # save figure in ./ | # save figure in ./ | ||
| script_dir = os.path.dirname(__file__) | script_dir = os.path.dirname(__file__) | ||
| results_dir = os.path.join(script_dir, | results_dir = os.path.join(script_dir, | ||
| results_dir_png = os.path.join(script_dir, | results_dir_png = os.path.join(script_dir, | ||
| + | | ||
| if not os.path.isdir(results_dir): | if not os.path.isdir(results_dir): | ||
| os.makedirs(results_dir) | os.makedirs(results_dir) | ||
| if not os.path.isdir(results_dir_png): | if not os.path.isdir(results_dir_png): | ||
| os.makedirs(results_dir_png) | os.makedirs(results_dir_png) | ||
| + | | ||
| if option == " | if option == " | ||
| plt.show() | plt.show() | ||
| plt.savefig(results_dir+pdfName+' | plt.savefig(results_dir+pdfName+' | ||
| plt.savefig(results_dir_png+pdfName+' | plt.savefig(results_dir_png+pdfName+' | ||
| + | | ||
| def plotHistograms_fearMoraleMalus(nDistribs, | def plotHistograms_fearMoraleMalus(nDistribs, | ||
| + | | ||
| nBins = 140 | nBins = 140 | ||
| fig, ax = plt.subplots() | fig, ax = plt.subplots() | ||
| Line 638: | Line 638: | ||
| ax.set_xlabel(' | ax.set_xlabel(' | ||
| ax.set_ylabel(' | ax.set_ylabel(' | ||
| + | | ||
| if option == " | if option == " | ||
| colourMap = plt.get_cmap(" | colourMap = plt.get_cmap(" | ||
| else: | else: | ||
| colourMap = plt.get_cmap(" | colourMap = plt.get_cmap(" | ||
| + | | ||
| xRounds = np.arange(100) | xRounds = np.arange(100) | ||
| for i in range(nDistribs): | for i in range(nDistribs): | ||
| Line 652: | Line 652: | ||
| # ax.hist(fearMoraleMalusDistrib_collection[i], | # ax.hist(fearMoraleMalusDistrib_collection[i], | ||
| ax.plot(xRounds, | ax.plot(xRounds, | ||
| + | | ||
| # Create new legend handles but use the colors from the existing ones | # Create new legend handles but use the colors from the existing ones | ||
| handles, labels = ax.get_legend_handles_labels() | handles, labels = ax.get_legend_handles_labels() | ||
| Line 661: | Line 661: | ||
| else: | else: | ||
| new_handles = [Line2D([], [], c=handles[i].get_color()) for i in range(nDistribs)] | new_handles = [Line2D([], [], c=handles[i].get_color()) for i in range(nDistribs)] | ||
| + | | ||
| # plt.legend(handles=new_handles, | # plt.legend(handles=new_handles, | ||
| + | | ||
| ax.legend(handles=new_handles, | ax.legend(handles=new_handles, | ||
| ax.label_outer() | ax.label_outer() | ||
| + | | ||
| plt.xlim(xmin=0, | plt.xlim(xmin=0, | ||
| plt.ylim(ymin=0, | plt.ylim(ymin=0, | ||
| # plt.gca().yaxis.set_major_formatter(mtick.PercentFormatter(xmax=1.0)) # transforms y-axis in % format | # plt.gca().yaxis.set_major_formatter(mtick.PercentFormatter(xmax=1.0)) # transforms y-axis in % format | ||
| + | | ||
| plt.title(pltTitle) | plt.title(pltTitle) | ||
| + | | ||
| fig.tight_layout() # otherwise the right y-label is slightly clipped | fig.tight_layout() # otherwise the right y-label is slightly clipped | ||
| fig.tight_layout() # for some reason gotta call it twice for the top title to not be cropped | fig.tight_layout() # for some reason gotta call it twice for the top title to not be cropped | ||
| - | + | | |
| + | |||
| # x-axis: major ticks every 20, minor ticks every 5 | # x-axis: major ticks every 20, minor ticks every 5 | ||
| major_ticks_x = np.arange(0, | major_ticks_x = np.arange(0, | ||
| Line 686: | Line 686: | ||
| major_ticks_y = np.arange(0, | major_ticks_y = np.arange(0, | ||
| minor_ticks_y = np.arange(0, | minor_ticks_y = np.arange(0, | ||
| + | | ||
| ax.set_xticks(major_ticks_x) | ax.set_xticks(major_ticks_x) | ||
| ax.set_xticks(minor_ticks_x, | ax.set_xticks(minor_ticks_x, | ||
| ax.set_yticks(major_ticks_y) | ax.set_yticks(major_ticks_y) | ||
| ax.set_yticks(minor_ticks_y, | ax.set_yticks(minor_ticks_y, | ||
| + | | ||
| ax.grid(which=' | ax.grid(which=' | ||
| + | | ||
| ax.grid(which=' | ax.grid(which=' | ||
| ax.grid(which=' | ax.grid(which=' | ||
| + | | ||
| # save figure in ./ | # save figure in ./ | ||
| script_dir = os.path.dirname(__file__) | script_dir = os.path.dirname(__file__) | ||
| results_dir = os.path.join(script_dir, | results_dir = os.path.join(script_dir, | ||
| results_dir_png = os.path.join(script_dir, | results_dir_png = os.path.join(script_dir, | ||
| + | | ||
| if not os.path.isdir(results_dir): | if not os.path.isdir(results_dir): | ||
| os.makedirs(results_dir) | os.makedirs(results_dir) | ||
| if not os.path.isdir(results_dir_png): | if not os.path.isdir(results_dir_png): | ||
| os.makedirs(results_dir_png) | os.makedirs(results_dir_png) | ||
| + | | ||
| if option == " | if option == " | ||
| plt.show() | plt.show() | ||
| plt.savefig(results_dir+pdfName+' | plt.savefig(results_dir+pdfName+' | ||
| plt.savefig(results_dir_png+pdfName+' | plt.savefig(results_dir_png+pdfName+' | ||
| - | + | | |
| + | |||
| ################################################################################################################################ | ################################################################################################################################ | ||
| ########################### | ########################### | ||
| ################################################################################################################################ | ################################################################################################################################ | ||
| + | | ||
| def plot_varyingMorale_setEnchantments_commandersRout(): | def plot_varyingMorale_setEnchantments_commandersRout(): | ||
| unitMorale_collection = range(10, | unitMorale_collection = range(10, | ||
| nIteration=100000 | nIteration=100000 | ||
| + | | ||
| nDistribs = len(unitMorale_collection) | nDistribs = len(unitMorale_collection) | ||
| + | | ||
| for bloodRainActive in [0,1]: | for bloodRainActive in [0,1]: | ||
| for wailingWindsActive in [0,1]: | for wailingWindsActive in [0,1]: | ||
| Line 737: | Line 737: | ||
| if wailingWindsActive == 0: | if wailingWindsActive == 0: | ||
| wailingWinds = " | wailingWinds = " | ||
| + | | ||
| routingTimeDistrib_collection = [] | routingTimeDistrib_collection = [] | ||
| collectionLegend = [] | collectionLegend = [] | ||
| Line 744: | Line 744: | ||
| routingTimeDistrib_collection += [makeWailingRoutDistrib_commanders(unitMorale, | routingTimeDistrib_collection += [makeWailingRoutDistrib_commanders(unitMorale, | ||
| collectionLegend += [" | collectionLegend += [" | ||
| + | | ||
| wailingStatus = " | wailingStatus = " | ||
| rainStatus = " | rainStatus = " | ||
| + | | ||
| pltTitle = " | pltTitle = " | ||
| pdfName = " | pdfName = " | ||
| + | | ||
| plotHistograms_commanders(nDistribs, | plotHistograms_commanders(nDistribs, | ||
| + | | ||
| def plot_setMorale_varyingEnchantments_commandersRout(): | def plot_setMorale_varyingEnchantments_commandersRout(): | ||
| unitMorale_collection = range(10, | unitMorale_collection = range(10, | ||
| # unitMorale_collection = [15] | # unitMorale_collection = [15] | ||
| nIteration=100000 | nIteration=100000 | ||
| + | | ||
| for unitMorale in unitMorale_collection: | for unitMorale in unitMorale_collection: | ||
| print(" | print(" | ||
| # for wailingWindsActive in [0,1]: | # for wailingWindsActive in [0,1]: | ||
| # if (bloodRainActive, | # if (bloodRainActive, | ||
| + | | ||
| nDistribs = 3 # wailing, | nDistribs = 3 # wailing, | ||
| routingTimeDistrib_collection = [] | routingTimeDistrib_collection = [] | ||
| collectionLegend = [] | collectionLegend = [] | ||
| + | | ||
| for bloodRainActive in [0,1]: | for bloodRainActive in [0,1]: | ||
| for wailingWindsActive in [0,1]: | for wailingWindsActive in [0,1]: | ||
| Line 775: | Line 775: | ||
| rainStatus = " | rainStatus = " | ||
| collectionLegend += [" | collectionLegend += [" | ||
| - | + | | |
| + | |||
| pltTitle = " | pltTitle = " | ||
| pdfName = " | pdfName = " | ||
| + | | ||
| plotHistograms_commanders(nDistribs, | plotHistograms_commanders(nDistribs, | ||
| + | | ||
| def plot_setMorale_varyingEnchantments_squadRout(): | def plot_setMorale_varyingEnchantments_squadRout(): | ||
| unitMorale_collection = range(10, | unitMorale_collection = range(10, | ||
| # unitMorale_collection = range(16, | # unitMorale_collection = range(16, | ||
| nIteration=100000 | nIteration=100000 | ||
| + | | ||
| squadSize = 10 | squadSize = 10 | ||
| unitDensity = 2 | unitDensity = 2 | ||
| + | | ||
| for unitMorale in unitMorale_collection: | for unitMorale in unitMorale_collection: | ||
| print(" | print(" | ||
| + | | ||
| nDistribs = 2 # wailing, | nDistribs = 2 # wailing, | ||
| routedRatioDistrib_collection = [] | routedRatioDistrib_collection = [] | ||
| collectionLegend = [] | collectionLegend = [] | ||
| + | | ||
| for bloodRainActive in [0,1]: | for bloodRainActive in [0,1]: | ||
| for wailingWindsActive in [0,1]: | for wailingWindsActive in [0,1]: | ||
| Line 805: | Line 805: | ||
| rainStatus = " | rainStatus = " | ||
| collectionLegend += [" | collectionLegend += [" | ||
| - | + | | |
| + | |||
| pltTitle = "squad morale " + str(unitMorale) | pltTitle = "squad morale " + str(unitMorale) | ||
| pdfName = " | pdfName = " | ||
| + | | ||
| plotHistograms_squad(nDistribs, | plotHistograms_squad(nDistribs, | ||
| + | | ||
| def plot_varyingMorale_setEnchantments_squadRout(): | def plot_varyingMorale_setEnchantments_squadRout(): | ||
| unitMorale_collection = range(10, | unitMorale_collection = range(10, | ||
| nIteration=100000 | nIteration=100000 | ||
| + | | ||
| squadSize = 10 | squadSize = 10 | ||
| unitDensity = 2 | unitDensity = 2 | ||
| + | | ||
| nDistribs = len(unitMorale_collection) | nDistribs = len(unitMorale_collection) | ||
| + | | ||
| for bloodRainActive in [0,1]: | for bloodRainActive in [0,1]: | ||
| for wailingWindsActive in [0,1]: | for wailingWindsActive in [0,1]: | ||
| Line 835: | Line 835: | ||
| if wailingWindsActive == 0: | if wailingWindsActive == 0: | ||
| wailingWinds = " | wailingWinds = " | ||
| + | | ||
| routedRatioDistrib_collection = [] | routedRatioDistrib_collection = [] | ||
| collectionLegend = [] | collectionLegend = [] | ||
| + | | ||
| for unitMorale in unitMorale_collection: | for unitMorale in unitMorale_collection: | ||
| print(" | print(" | ||
| routedRatioDistrib_collection += [makeWailingRoutDistrib_squad(unitMorale, | routedRatioDistrib_collection += [makeWailingRoutDistrib_squad(unitMorale, | ||
| collectionLegend += [" | collectionLegend += [" | ||
| + | | ||
| wailingStatus = " | wailingStatus = " | ||
| rainStatus = " | rainStatus = " | ||
| + | | ||
| pltTitle = "squad - BloodRain" | pltTitle = "squad - BloodRain" | ||
| pdfName = " | pdfName = " | ||
| + | | ||
| plotHistograms_squad(nDistribs, | plotHistograms_squad(nDistribs, | ||
| + | | ||
| def plot_varyingMorale_setEnchantments_moraleMalus(): | def plot_varyingMorale_setEnchantments_moraleMalus(): | ||
| unitMorale_collection = range(10, | unitMorale_collection = range(10, | ||
| nIteration=10000 | nIteration=10000 | ||
| + | | ||
| nDistribs = len(unitMorale_collection) | nDistribs = len(unitMorale_collection) | ||
| + | | ||
| for bloodRainActive in [0,1]: | for bloodRainActive in [0,1]: | ||
| for wailingWindsActive in [0,1]: | for wailingWindsActive in [0,1]: | ||
| Line 872: | Line 872: | ||
| if wailingWindsActive == 0: | if wailingWindsActive == 0: | ||
| wailingWinds = " | wailingWinds = " | ||
| + | | ||
| fearMoraleMalusDistrib_collection = [] | fearMoraleMalusDistrib_collection = [] | ||
| collectionLegend = [] | collectionLegend = [] | ||
| Line 879: | Line 879: | ||
| fearMoraleMalusDistrib_collection += [makeFearMoraleMalusAverageDistrib(unitMorale, | fearMoraleMalusDistrib_collection += [makeFearMoraleMalusAverageDistrib(unitMorale, | ||
| collectionLegend += [" | collectionLegend += [" | ||
| + | | ||
| wailingStatus = " | wailingStatus = " | ||
| rainStatus = " | rainStatus = " | ||
| + | | ||
| pltTitle = " | pltTitle = " | ||
| pdfName = " | pdfName = " | ||
| + | | ||
| plotHistograms_fearMoraleMalus(nDistribs, | plotHistograms_fearMoraleMalus(nDistribs, | ||
| + | | ||
| def plot_setMorale_varyingEnchantments_moraleMalus(): | def plot_setMorale_varyingEnchantments_moraleMalus(): | ||
| unitMorale_collection = range(10, | unitMorale_collection = range(10, | ||
| # unitMorale_collection = [15] | # unitMorale_collection = [15] | ||
| nIteration=10000 | nIteration=10000 | ||
| + | | ||
| for unitMorale in unitMorale_collection: | for unitMorale in unitMorale_collection: | ||
| print(" | print(" | ||
| # for wailingWindsActive in [0,1]: | # for wailingWindsActive in [0,1]: | ||
| # if (bloodRainActive, | # if (bloodRainActive, | ||
| + | | ||
| nDistribs = 3 # wailing, | nDistribs = 3 # wailing, | ||
| fearMoraleMalusDistrib_collection = [] | fearMoraleMalusDistrib_collection = [] | ||
| collectionLegend = [] | collectionLegend = [] | ||
| + | | ||
| for bloodRainActive in [0,1]: | for bloodRainActive in [0,1]: | ||
| for wailingWindsActive in [0,1]: | for wailingWindsActive in [0,1]: | ||
| Line 910: | Line 910: | ||
| rainStatus = " | rainStatus = " | ||
| collectionLegend += [" | collectionLegend += [" | ||
| - | + | | |
| + | |||
| pltTitle = " | pltTitle = " | ||
| pdfName = " | pdfName = " | ||
| + | | ||
| plotHistograms_fearMoraleMalus(nDistribs, | plotHistograms_fearMoraleMalus(nDistribs, | ||
| - | + | | |
| - | + | ||
| - | + | ||
| + | |||
| def plot_all_commanders(): | def plot_all_commanders(): | ||
| plot_varyingMorale_setEnchantments_commandersRout() | plot_varyingMorale_setEnchantments_commandersRout() | ||
| plot_setMorale_varyingEnchantments_commandersRout() | plot_setMorale_varyingEnchantments_commandersRout() | ||
| - | + | | |
| - | + | ||
| + | |||
| def plot_test(): | def plot_test(): | ||
| unitMorale_collection = [10, | unitMorale_collection = [10, | ||
| nIteration=100000 | nIteration=100000 | ||
| + | | ||
| # # commanders | # # commanders | ||
| # for unitMorale in unitMorale_collection: | # for unitMorale in unitMorale_collection: | ||
| # # for wailingWindsActive in [0,1]: | # # for wailingWindsActive in [0,1]: | ||
| # # | # # | ||
| + | | ||
| # | # | ||
| # | # | ||
| # | # | ||
| + | | ||
| # for bloodRainActive in [0,1]: | # for bloodRainActive in [0,1]: | ||
| # for wailingWindsActive in [0,1]: | # for wailingWindsActive in [0,1]: | ||
| Line 946: | Line 946: | ||
| # | # | ||
| # | # | ||
| - | + | | |
| + | |||
| # | # | ||
| # | # | ||
| + | | ||
| # | # | ||
| - | + | | |
| + | |||
| # squad | # squad | ||
| for unitMorale in unitMorale_collection: | for unitMorale in unitMorale_collection: | ||
| Line 959: | Line 959: | ||
| # for wailingWindsActive in [0,1]: | # for wailingWindsActive in [0,1]: | ||
| # if (bloodRainActive, | # if (bloodRainActive, | ||
| + | | ||
| nDistribs = 2 # wailing, | nDistribs = 2 # wailing, | ||
| routedRatioDistrib_collection = [] | routedRatioDistrib_collection = [] | ||
| Line 965: | Line 965: | ||
| squadSize = 10 | squadSize = 10 | ||
| unitDensity = 2 | unitDensity = 2 | ||
| + | | ||
| for bloodRainActive in [0,1]: | for bloodRainActive in [0,1]: | ||
| for wailingWindsActive in [0,1]: | for wailingWindsActive in [0,1]: | ||
| Line 974: | Line 974: | ||
| rainStatus = " | rainStatus = " | ||
| collectionLegend += [" | collectionLegend += [" | ||
| - | + | | |
| + | |||
| pltTitle = "squad morale " + str(unitMorale) | pltTitle = "squad morale " + str(unitMorale) | ||
| pdfName = " | pdfName = " | ||
| + | | ||
| plotHistograms_squad(nDistribs, | plotHistograms_squad(nDistribs, | ||
| - | + | | |
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| - | + | ||
| + | |||
| # for units: | # for units: | ||
| # proba full squad gone | # proba full squad gone | ||
| # proba one unit gone | # proba one unit gone | ||
| # % of units in the squad gone | # % of units in the squad gone | ||
| - | + | | |
| + | |||
| # legacy error bars attempt | # legacy error bars attempt | ||
| + | | ||
| # SumSquareDev = 0 | # SumSquareDev = 0 | ||
| # E = wailingExpectedRout(unitMorale, | # E = wailingExpectedRout(unitMorale, | ||
| | | ||
| # n, bins, patches = plt.hist(RoutingTime, | # n, bins, patches = plt.hist(RoutingTime, | ||
| + | | ||
| # y,binEdges = np.histogram(RoutingTime, | # y,binEdges = np.histogram(RoutingTime, | ||
| # bincenters = 0.5*(binEdges[1: | # bincenters = 0.5*(binEdges[1: | ||