Add decay for huntables
This commit is contained in:
@@ -186,6 +186,7 @@ class Gather():
|
||||
|
||||
def compute_next_gather_rate_decrease(self, task, villagers):
|
||||
rate = self.gather_rates[task]
|
||||
decay = self.decay_rates[task]
|
||||
|
||||
if task == Tasks.FARM:
|
||||
available = self.farms[0]
|
||||
@@ -193,14 +194,12 @@ class Gather():
|
||||
else:
|
||||
available = self.gatherable_amounts[task]
|
||||
|
||||
try:
|
||||
next_decrease = available/(villagers*rate)
|
||||
if rate == 0 or (villagers == 0 and decay == 0):
|
||||
next_decrease = None
|
||||
else:
|
||||
next_decrease = available/(villagers*rate + decay)
|
||||
# rounding error will give 1 extra second of gathering
|
||||
next_decrease = math.ceil(next_decrease)
|
||||
except ZeroDivisionError:
|
||||
# either villagers or rate was 0, so no next decrease should
|
||||
# be scheduled
|
||||
next_decrease = None
|
||||
|
||||
return next_decrease
|
||||
|
||||
@@ -300,6 +299,11 @@ class Gather():
|
||||
amount_gathered = count*rate*mult*duration
|
||||
self.resources[resource] += amount_gathered
|
||||
|
||||
for task in self.decay_rates.keys():
|
||||
self.gatherable_amounts[task] -= self.decay_rates[task]*duration
|
||||
if self.gatherable_amounts[task] < 0:
|
||||
self.gatherable_amounts[task] = 0
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.resources = [200, 200, 100, 200]
|
||||
@@ -329,6 +333,12 @@ class Gather():
|
||||
|
||||
self.original_gather_rates = copy.deepcopy(self.gather_rates)
|
||||
|
||||
self.decay_rates = defaultdict(int, {
|
||||
Tasks.SHEEP: 0.25,
|
||||
Tasks.BOAR: 0.4,
|
||||
Tasks.HUNT: 0.25,
|
||||
})
|
||||
|
||||
self.gathered_resources = {
|
||||
Tasks.BERRIES: {Resources.FOOD: 1},
|
||||
Tasks.SHEEP: {Resources.FOOD: 1},
|
||||
|
||||
Reference in New Issue
Block a user