wip(bunsik): 경제 개편 공용 로직 — 업그레이드 갈래, 의자·테이블 배치와 길 찾기(Floor), 알바생 역할·시급, 손님 러시·홍보·쫓아내기 로직, 서버↔클라이언트 약속(NETWORK.md)
서버·클라이언트는 다음 커밋에서 새 구조로 옮깁니다(이 커밋만으로는 빌드 검사가 통과하지 않음). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,23 +1,50 @@
|
||||
-- 경제 시뮬레이터 본체: 실제 게임 로직(src/shared/Shop)을 봇이 쉬지 않고 최적으로 플레이합니다.
|
||||
-- 경제 시뮬레이터 본체: 실제 게임 로직(src/shared/Shop)을 봇이 쉬지 않고 플레이합니다.
|
||||
-- 실행은 tools/sim.luau, 검사는 tests/Sim.spec.luau
|
||||
-- 봇 가정: 조리대 <-> 테이블 편도 WALK/2초, 알바생이 있으면 직접 조리하지 않고 나르기만 합니다.
|
||||
-- 봇 가정: 조리대 <-> 테이블 편도 WALK/2초, 요리 알바가 있으면 직접 조리하지 않고 나르기만 합니다.
|
||||
-- 조리 시간은 요리 화면을 쉬지 않고 했을 때의 시간(Recipes.expectedTime: 메뉴 고르기 + 단계 + 완성 연출)입니다.
|
||||
-- 사는 순서: 지금 살 수 있는 것(업그레이드 갈래 다음 단계, 의자, 테이블, 알바생 고용) 중 가장 싼 것부터.
|
||||
local Economy = require("../src/shared/Economy")
|
||||
local Recipes = require("../src/shared/Recipes")
|
||||
local Shop = require("../src/shared/Shop")
|
||||
|
||||
local Sim = {}
|
||||
|
||||
function Sim.run(mult: number, limit: number): { { t: number, id: string, cost: number } }
|
||||
local shop = Shop.new(0, 0, 0)
|
||||
export type Entry = { t: number, id: string, cost: number, kind: string }
|
||||
|
||||
-- 봇이 다음에 살 것(가장 싼 것)
|
||||
local function nextBuy(shop, tables: number): { kind: string, id: string, cost: number }?
|
||||
local offers = Economy.offers(shop.levels, tables, shop.stats.seats)
|
||||
local list = {}
|
||||
for _, o in offers do
|
||||
table.insert(list, { kind = o.kind, id = o.id, cost = o.cost })
|
||||
end
|
||||
if shop.stats.staffUnlocked then
|
||||
for _, r in Economy.ROLES do
|
||||
-- 서빙·홍보 알바는 실내 분식집부터 고용(봇 가정)
|
||||
local want = if r.id == "Cook" then 1 elseif shop.stats.stage >= 2 then r.max else 0
|
||||
if (shop.staff[r.id] or 0) < want then
|
||||
table.insert(list, { kind = "hire", id = r.id, cost = r.hire })
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(list, function(a, b)
|
||||
return a.cost < b.cost
|
||||
end)
|
||||
return list[1]
|
||||
end
|
||||
|
||||
function Sim.run(mult: number, limit: number, untilStage: number?): { Entry }
|
||||
local shop = Shop.new({ money = 0, now = 0 })
|
||||
shop.moneyMult = mult
|
||||
local tables = 1
|
||||
local dt = 0.1
|
||||
local t = 0
|
||||
local at = "stove"
|
||||
local busyUntil = 0
|
||||
local pending: string? = nil -- 끝나면 할 일: "cook" | "arrive_tables" | "arrive_stove"
|
||||
local log = {}
|
||||
while t < limit and Shop.nextPurchase(shop) do
|
||||
local log: { Entry } = {}
|
||||
local goal = untilStage or 3
|
||||
while t < limit do
|
||||
Shop.tick(shop, t)
|
||||
if t >= busyUntil then
|
||||
if pending == "cook" then
|
||||
@@ -30,7 +57,8 @@ function Sim.run(mult: number, limit: number): { { t: number, id: string, cost:
|
||||
pending = nil
|
||||
if at == "stove" then
|
||||
Shop.pickup(shop)
|
||||
local canCook = not shop.stats.helper and not Shop.handFull(shop) and Shop.nextCookMenu(shop) ~= nil
|
||||
local cooks = shop.staff.Cook or 0
|
||||
local canCook = cooks == 0 and not Shop.handFull(shop) and Shop.nextCookMenu(shop) ~= nil
|
||||
if canCook then
|
||||
pending = "cook"
|
||||
local menu = Shop.nextCookMenu(shop) :: string
|
||||
@@ -51,10 +79,26 @@ function Sim.run(mult: number, limit: number): { { t: number, id: string, cost:
|
||||
end
|
||||
end
|
||||
end
|
||||
local p = Shop.nextPurchase(shop)
|
||||
if p and shop.money >= p.cost then
|
||||
Shop.buyNext(shop)
|
||||
table.insert(log, { t = t, id = p.id, cost = p.cost })
|
||||
local b = nextBuy(shop, tables)
|
||||
-- 시급 낼 돈은 남겨 둡니다.
|
||||
local reserve = Economy.totalWage(shop.staff, shop.stats)
|
||||
if b and shop.money >= b.cost + reserve then
|
||||
if b.kind == "track" then
|
||||
Shop.buyLevel(shop, b.id)
|
||||
elseif b.kind == "hire" then
|
||||
Shop.hire(shop, b.id)
|
||||
else
|
||||
Shop.spend(shop, b.cost)
|
||||
if b.kind == "table" then
|
||||
tables += 1
|
||||
end
|
||||
Shop.setSeats(shop, shop.stats.seats + 1)
|
||||
end
|
||||
local label = if b.kind == "track" then `{b.id}{shop.levels[b.id]}` else b.id
|
||||
table.insert(log, { t = t, id = label, cost = b.cost, kind = b.kind })
|
||||
if shop.stats.stage >= goal and b.id == "Stage" then
|
||||
break
|
||||
end
|
||||
end
|
||||
t += dt
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user