Skip to content

Instantly share code, notes, and snippets.

@zheplusplus
Last active August 29, 2015 13:56
Show Gist options
  • Save zheplusplus/9241779 to your computer and use it in GitHub Desktop.
Save zheplusplus/9241779 to your computer and use it in GitHub Desktop.
# encoding=utf-8
# from http://bbs.eve-china.com/thread-583164-1-1.html
SHIP_REPROCESSING = {
'Incursus': {
u'三钛合金': 11528,
u'类晶体胶矿': 9882,
u'类银超金属': 3656,
u'同位聚合体': 7,
},
}
#PE:生产效率理论
PE_EFFECT = 0.05
#EVE,生产固定损耗值
EVE_LOSSVALUE = 1.25
#蓝图的材料研究等级(减少设计上造成的浪费)
EVE_BLUEPRINT_ME = 0.1
def calculate_ship(pe_level, me_level, ship_info):
result_data = {}
for mineral, number in ship_info.items():
#算出每种矿物的需求
neednumber = (EVE_LOSSVALUE - PE_EFFECT * pe_level) * (
1 + EVE_BLUEPRINT_ME / (1 + me_level)) * number
neednumber = int(round(neednumber, 0))
result_data[mineral] = neednumber
return result_data
def statistics(ship_reprocessing, max_me):
max_level = max_me + 1
material_data = {}
for ship_info in ship_reprocessing.values():
for me_level in range(0, max_level):
material_data[me_level] = calculate_ship(5, me_level, ship_info)
#比较
this_loop_data = {}
last_loop_data = {}
ratio_number = 0
for level, data in material_data.items():
this_loop_data = data
if not last_loop_data:
last_loop_data = data
continue
if this_loop_data != last_loop_data:
level_calculate_data = {}
for name, number in last_loop_data.items():
if name in this_loop_data:
calculate_value = number - this_loop_data[name]
#计算百分比
ratio_number = 1.0 - (float(this_loop_data[name]) / number)
ratio_number = round(ratio_number, 8) * 100
level_calculate_data[name] = {
'number': calculate_value,
'Ratio': ratio_number
}
print u"等级%s比等级%s,较少的数据为:" % (level, level-1)
for name, loop_data in level_calculate_data.iteritems():
print u"矿物:%s, 数量:%s,优化比率为:%s%%" % (
name, loop_data['number'], loop_data['Ratio'])
print u"==========================="
else:
print u'蓝图已经完全没有必要继续下去了。因为无法在减少材料数量!'
print u'目前的优化等级为%s' % level
for name, number in last_loop_data.items():
print u"矿物:%s, 数量:%s" % (name, number)
break
last_loop_data = data
if __name__ == '__main__':
#准备研究蓝图的最大等级
max_level = 50
statistics(SHIP_REPROCESSING, max_level)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment