Created
August 26, 2013 21:17
-
-
Save yanmhlv/6346764 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
field = [ | |
{'cost': 10, 'prod': 2, 'time': 3}, | |
{'cost': 20, 'prod': 3, 'time': 4} | |
] | |
total_resource, base_production, total_time = 0, 1, 0 | |
lvl = 0 | |
required_lvl = len(field) | |
while True: | |
if total_resource - field[lvl]['cost'] < 0: | |
total_time, total_resource = total_time + 1, total_resource + base_production | |
print 'continue tic', total_resource, total_time, base_production | |
continue | |
total_resource -= field[lvl]['cost'] # вычитаем стоймость постройки | |
total_time += field[lvl]['time'] # время строительства | |
total_resource += field[lvl]['prod'] * field[lvl]['time'] # ресурсы, которые набегут за время строительства | |
base_production += field[lvl]['prod'] | |
lvl += 1 | |
print 'build tic', total_resource, total_time, base_production | |
if lvl == required_lvl: | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment