Import current DEMON v0.19 source, assets and development handoff
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
extends SceneTree
|
||||
const E=preload("res://economy.gd")
|
||||
var results=[]
|
||||
func _initialize():call_deferred("run")
|
||||
func worker():return {"job":null,"tool":-1,"busy":0.0}
|
||||
func tool(kind):return {"kind":kind,"busy":0.0,"held":-1}
|
||||
func run_case(policy):
|
||||
var gold=E.START_GOLD-40;var essence=0;var xp=0;var points=0;var done=0;var uid=0
|
||||
var power=0;var speed=0;var lead=0;var haste=0;var diligence=0;var hires=0;var auto=false;var unlocked=0
|
||||
var tools=[tool(0)];var workers=[worker()];var jobs=[]
|
||||
var arrival=0.0;var pressure=0.0;var fee_clock=0.0;var full_seconds=0.0;var loss_gold=0;var loss_souls=0;var samples=[]
|
||||
var first_helper=-1.0;var third_helper=-1.0;var spent_gold=40;var spent_souls=0
|
||||
for tick in range(12000):
|
||||
var dt=.1;var now=tick*dt
|
||||
if policy!="hoard" and tick%10==0:
|
||||
while policy!="no_hero" and points>0 and power+speed+lead<9:
|
||||
if speed<1:speed+=1
|
||||
elif power<3:power+=1
|
||||
elif lead<3:lead+=1
|
||||
else:speed+=1
|
||||
points-=1
|
||||
var soul_cost=0
|
||||
if hires==0 and essence>=6 and policy!="no_helpers":hires=1;soul_cost=6;first_helper=now
|
||||
elif hires>0 and not auto and essence>=4:auto=true;soul_cost=4
|
||||
elif haste<1 and auto and essence>=E.HASTE_PRICES[haste]:soul_cost=E.HASTE_PRICES[haste];haste+=1
|
||||
elif diligence<1 and auto and essence>=E.DILIGENCE_PRICES[diligence]:soul_cost=E.DILIGENCE_PRICES[diligence];diligence+=1
|
||||
elif hires<3 and auto and essence>=E.HIRE_PRICES[hires]:
|
||||
soul_cost=E.HIRE_PRICES[hires];hires+=1
|
||||
if hires==3:third_helper=now
|
||||
elif haste<3 and auto and essence>=E.HASTE_PRICES[haste]:soul_cost=E.HASTE_PRICES[haste];haste+=1
|
||||
elif diligence<3 and auto and essence>=E.DILIGENCE_PRICES[diligence]:soul_cost=E.DILIGENCE_PRICES[diligence];diligence+=1
|
||||
essence-=soul_cost;spent_souls+=soul_cost
|
||||
while workers.size()<1+(hires if auto else 0):workers.append(worker())
|
||||
if policy=="no_tools":pass
|
||||
elif tools.size()<workers.size()+1 and gold>=40+50:tools.append(tool(0));gold-=40;spent_gold+=40
|
||||
elif unlocked<5 and E.level(xp)>=3+unlocked and gold>=E.BLUEPRINT_PRICES[unlocked+1]+E.TOOL_PRICES[unlocked+1]+60:
|
||||
unlocked+=1;var cost=E.BLUEPRINT_PRICES[unlocked]+E.TOOL_PRICES[unlocked];tools.append(tool(unlocked));gold-=cost;spent_gold+=cost
|
||||
for t in tools:t.busy=maxf(0,t.busy-dt)
|
||||
for wi in range(workers.size()):
|
||||
var w=workers[wi]
|
||||
if w.job==null:continue
|
||||
w.busy-=dt
|
||||
if w.busy>0:continue
|
||||
var job=w.job;job.step+=1
|
||||
if job.step>=job.required.size():
|
||||
var reward=E.reward(job.required,xp);gold+=reward.gold;essence+=reward.souls
|
||||
var old=E.level(xp);xp=mini(E.XP_THRESHOLDS.back(),xp+reward.xp);points+=E.level(xp)-old;done+=1
|
||||
tools[w.tool].held=-1;tools[w.tool].busy=2.6;jobs.erase(job)
|
||||
else:job.state="ready";job.origin=w.tool
|
||||
w.job=null
|
||||
arrival=minf(E.SPAWN_INTERVAL,arrival+dt)
|
||||
var queue=jobs.filter(func(j):return j.state=="queue").size()
|
||||
if arrival>=E.SPAWN_INTERVAL and queue<7:
|
||||
var available=[]
|
||||
for t in tools:
|
||||
if not t.kind in available:available.append(t.kind)
|
||||
var required=[];var count=E.recipe_size(uid,xp,available.size())
|
||||
for i in range(count):required.append(available[(uid+i)%available.size()])
|
||||
jobs.append({"id":uid,"required":required,"step":0,"origin":-1,"state":"queue"});uid+=1;arrival=0;queue+=1
|
||||
if queue>=7:
|
||||
full_seconds+=dt;var old_pressure=pressure;pressure+=dt
|
||||
if pressure>=E.PRESSURE_GRACE:
|
||||
fee_clock=E.PENALTY_INTERVAL if old_pressure<E.PRESSURE_GRACE else fee_clock+dt
|
||||
if fee_clock>=E.PENALTY_INTERVAL:
|
||||
fee_clock-=E.PENALTY_INTERVAL;var fee=E.penalty(xp,pressure)
|
||||
var take_gold=mini(fee.gold,maxi(0,gold-E.GOLD_RESERVE));var take_souls=mini(fee.souls,maxi(0,essence-E.SOUL_RESERVE))
|
||||
gold-=take_gold;essence-=take_souls;loss_gold+=take_gold;loss_souls+=take_souls
|
||||
else:pressure=maxf(0,pressure-dt*2);fee_clock=maxf(0,fee_clock-dt*2)
|
||||
for wi in range(workers.size()):
|
||||
var w=workers[wi]
|
||||
if w.job!=null:continue
|
||||
var candidates=jobs.filter(func(j):return j.state=="ready")+jobs.filter(func(j):return j.state=="queue")
|
||||
for job in candidates:
|
||||
var chosen=-1
|
||||
for ti in range(tools.size()):
|
||||
if tools[ti].held<0 and tools[ti].busy<=0 and tools[ti].kind==job.required[job.step]:chosen=ti;break
|
||||
if chosen<0:continue
|
||||
if job.origin>=0:tools[job.origin].held=-1;tools[job.origin].busy=.4
|
||||
var movement=3.3+speed*.825 if wi==0 else 2.5+haste*.625
|
||||
var skill=power*.2 if wi==0 else diligence*.25
|
||||
var kind=tools[chosen].kind
|
||||
var rate=(1+skill)*(1+lead*.08)/E.work_multiplier(xp)
|
||||
var travel=8.0 if job.origin<0 else 4.0
|
||||
w.busy=travel/movement+.8+E.BASE_WORK_SECONDS[kind]/rate;w.job=job;w.tool=chosen
|
||||
job.state="active";tools[chosen].held=job.id;break
|
||||
if tick%600==0:samples.append({"seconds":now,"done":done,"gold":gold,"souls":essence,"level":E.level(xp),"queue":queue,"helpers":hires,"tools":tools.size(),"types":unlocked+1})
|
||||
return {"policy":policy,"seconds":1200,"done":done,"level":E.level(xp),"gold":gold,"souls":essence,"full_queue_seconds":snappedf(full_seconds,.1),"gold_lost":loss_gold,"souls_lost":loss_souls,"helpers":hires,"tools":tools.size(),"types":unlocked+1,"gold_spent":spent_gold,"souls_spent":spent_souls,"first_helper_seconds":first_helper,"third_helper_seconds":third_helper,"samples":samples}
|
||||
func run():
|
||||
for policy in ["hoard","no_hero","no_helpers","no_tools","invest"]:
|
||||
var result=run_case(policy);results.append(result);var summary=result.duplicate();summary.erase("samples");print("BALANCE ",JSON.stringify(summary))
|
||||
var file=FileAccess.open("res://../qa_v19/balance_simulation.json",FileAccess.WRITE);file.store_string(JSON.stringify(results," "));file.close()
|
||||
quit()
|
||||
Reference in New Issue
Block a user