Compare commits

..

3 Commits

View File

@ -38,21 +38,96 @@ def evaluate_values(fuel, water, feritizer, seeds, fields_with_plants, k):
ans += water - fields_to_water ans += water - fields_to_water
ans += feritizer - fields_to_feritize - fields_to_water ans += feritizer - fields_to_feritize - fields_to_water
ans += seeds - fields_to_harvest - fields_to_sow ans += seeds - fields_to_harvest - fields_to_sow
fuel = fuel - 1500
water = water - fields_to_water
feritizer = feritizer - fields_to_feritize - fields_to_water
seeds = seeds - fields_to_harvest - fields_to_sow
if water < 0:
return 10
if feritizer < 0:
return 10
if seeds < 0:
return 10
if fuel < 0:
return 10
if k == 1: if k == 1:
ans += water - fields_to_water ans += water - fields_to_water
ans += feritizer - fields_to_water - fields_to_feritize ans += feritizer - fields_to_water - fields_to_feritize
ans += seeds - fields_to_sow ans += seeds - fields_to_sow
ans += (fuel - 1100) / 30 - fields_to_harvest ans += (fuel - 1100) / 30 - fields_to_harvest
fuel = fuel - 1500
water = water - fields_to_water
feritizer = feritizer - fields_to_water - fields_to_feritize
seeds = seeds - fields_to_sow
if water < 0:
return 10
if feritizer < 0:
return 10
if seeds < 0:
return 10
if fuel < 0:
return 10
if k == 2: if k == 2:
ans += feritizer - fields_to_feritize ans += feritizer - fields_to_feritize
ans += seeds - fields_to_sow ans += seeds - fields_to_sow
ans += (fuel - 800) / 15 - fields_to_feritize - fields_to_harvest ans += (fuel - 800) / 15 - fields_to_feritize - fields_to_harvest
ans += water - fields_to_water - fields_to_sow ans += water - fields_to_water - fields_to_sow
feritizer = feritizer - fields_to_feritize
seeds = seeds - fields_to_sow
fuel -= 1500
water = water - fields_to_water - fields_to_sow
if water < 0:
return 10
if feritizer < 0:
return 10
if seeds < 0:
return 10
if fuel < 0:
return 10
if k == 3: if k == 3:
ans += seeds - fields_to_sow ans += seeds - fields_to_sow
ans += (fuel - 400) / 30 - fields_to_harvest ans += (fuel - 400) / 30 - fields_to_harvest
ans += water - fields_to_water - fields_to_sow ans += water - fields_to_water - fields_to_sow
ans += feritizer - fields_to_feritize - fields_to_water - fields_to_sow ans += feritizer - fields_to_feritize - fields_to_water - fields_to_sow
fuel -= 1500
seeds = seeds - fields_to_sow
water = water - fields_to_water - fields_to_sow
feritizer = feritizer - fields_to_feritize - fields_to_water - fields_to_sow
if water < 0:
return 10
if feritizer < 0:
return 10
if seeds < 0:
return 10
if fuel < 0:
return 10
if tree.make_decision(t, fuel, water, feritizer, 15, 15, 15, 10, 10, seeds):
return 15
if k == 0:
fuel = fuel-500
if tree.make_decision(t, fuel, water, feritizer, 15, 15, 15, 10, 10, seeds):
return ans
else:
ans += 50
water = water - fields_to_harvest - fields_to_sow-10
if k == 1:
water = water - fields_to_harvest - fields_to_sow-10
if tree.make_decision(t, fuel - 400, water, feritizer, 15, 15, 15, 10, 10, seeds):
return ans
else:
ans += 50
if k == 2:
feritizer = feritizer - fields_to_sow - fields_to_water-10
if tree.make_decision(t, fuel - 400, water, feritizer, 15, 15, 15, 10, 10, seeds):
return ans
else:
ans += 50
if k == 3:
seeds = seeds - fields_to_water - fields_to_feritize-10
if tree.make_decision(t, fuel - 400, water, feritizer, 15, 15, 15, 10, 10, seeds):
return ans
else:
ans += 50
return ans return ans
def fitness(solution, fields_plants, k): def fitness(solution, fields_plants, k):