seperate teststrat from main code
This commit is contained in:
parent
71bf5567aa
commit
661d542e79
80
main.py
80
main.py
@ -23,42 +23,54 @@ def take_turn():
|
|||||||
# TODO Implement your artificial intelligence here.
|
# TODO Implement your artificial intelligence here.
|
||||||
# TODO Take one action per turn until the game ends.
|
# TODO Take one action per turn until the game ends.
|
||||||
# TODO The following is a short example of how to use the StarterKit
|
# TODO The following is a short example of how to use the StarterKit
|
||||||
|
if not useTestStrategy:
|
||||||
|
state = game_layer.game_state
|
||||||
|
|
||||||
state = game_layer.game_state
|
# messages and errors for console log
|
||||||
if len(state.residences) < 1:
|
for message in game_layer.game_state.messages:
|
||||||
for i in range(len(state.map)):
|
print(message)
|
||||||
for j in range(len(state.map)):
|
for error in game_layer.game_state.errors:
|
||||||
if state.map[i][j] == 0:
|
print("Error: " + error)
|
||||||
x = i
|
|
||||||
y = j
|
# pre-made test strategy
|
||||||
break
|
# which came with
|
||||||
game_layer.place_foundation((x, y), game_layer.game_state.available_residence_buildings[0].building_name)
|
# starter kit
|
||||||
else:
|
if useTestStrategy:
|
||||||
the_only_residence = state.residences[0]
|
state = game_layer.game_state
|
||||||
if the_only_residence.build_progress < 100:
|
if len(state.residences) < 1:
|
||||||
game_layer.build((the_only_residence.X, the_only_residence.Y))
|
for i in range(len(state.map)):
|
||||||
elif the_only_residence.health < 50:
|
for j in range(len(state.map)):
|
||||||
game_layer.maintenance((the_only_residence.X, the_only_residence.Y))
|
if state.map[i][j] == 0:
|
||||||
elif the_only_residence.temperature < 18:
|
x = i
|
||||||
blueprint = game_layer.get_residence_blueprint(the_only_residence.building_name)
|
y = j
|
||||||
energy = blueprint.base_energy_need + 0.5 \
|
break
|
||||||
+ (the_only_residence.temperature - state.current_temp) * blueprint.emissivity / 1 \
|
game_layer.place_foundation((x, y), game_layer.game_state.available_residence_buildings[0].building_name)
|
||||||
- the_only_residence.current_pop * 0.04
|
|
||||||
game_layer.adjust_energy_level((the_only_residence.X, the_only_residence.Y), energy)
|
|
||||||
elif the_only_residence.temperature > 24:
|
|
||||||
blueprint = game_layer.get_residence_blueprint(the_only_residence.building_name)
|
|
||||||
energy = blueprint.base_energy_need - 0.5 \
|
|
||||||
+ (the_only_residence.temperature - state.current_temp) * blueprint.emissivity / 1 \
|
|
||||||
- the_only_residence.current_pop * 0.04
|
|
||||||
game_layer.adjust_energy_level((the_only_residence.X, the_only_residence.Y), energy)
|
|
||||||
elif state.available_upgrades[0].name not in the_only_residence.effects:
|
|
||||||
game_layer.buy_upgrade((the_only_residence.X, the_only_residence.Y), state.available_upgrades[0].name)
|
|
||||||
else:
|
else:
|
||||||
game_layer.wait()
|
the_only_residence = state.residences[0]
|
||||||
for message in game_layer.game_state.messages:
|
if the_only_residence.build_progress < 100:
|
||||||
print(message)
|
game_layer.build((the_only_residence.X, the_only_residence.Y))
|
||||||
for error in game_layer.game_state.errors:
|
elif the_only_residence.health < 50:
|
||||||
print("Error: " + error)
|
game_layer.maintenance((the_only_residence.X, the_only_residence.Y))
|
||||||
|
elif the_only_residence.temperature < 18:
|
||||||
|
blueprint = game_layer.get_residence_blueprint(the_only_residence.building_name)
|
||||||
|
energy = blueprint.base_energy_need + 0.5 \
|
||||||
|
+ (the_only_residence.temperature - state.current_temp) * blueprint.emissivity / 1 \
|
||||||
|
- the_only_residence.current_pop * 0.04
|
||||||
|
game_layer.adjust_energy_level((the_only_residence.X, the_only_residence.Y), energy)
|
||||||
|
elif the_only_residence.temperature > 24:
|
||||||
|
blueprint = game_layer.get_residence_blueprint(the_only_residence.building_name)
|
||||||
|
energy = blueprint.base_energy_need - 0.5 \
|
||||||
|
+ (the_only_residence.temperature - state.current_temp) * blueprint.emissivity / 1 \
|
||||||
|
- the_only_residence.current_pop * 0.04
|
||||||
|
game_layer.adjust_energy_level((the_only_residence.X, the_only_residence.Y), energy)
|
||||||
|
elif state.available_upgrades[0].name not in the_only_residence.effects:
|
||||||
|
game_layer.buy_upgrade((the_only_residence.X, the_only_residence.Y), state.available_upgrades[0].name)
|
||||||
|
else:
|
||||||
|
game_layer.wait()
|
||||||
|
for message in game_layer.game_state.messages:
|
||||||
|
print(message)
|
||||||
|
for error in game_layer.game_state.errors:
|
||||||
|
print("Error: " + error)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Reference in New Issue
Block a user