From 0b52b1bce9596887f78b7e571d7bbaceae9c4c82 Mon Sep 17 00:00:00 2001 From: wtks <30363887+wtks@users.noreply.github.com> Date: Fri, 6 Dec 2024 14:43:15 +0900 Subject: [PATCH] =?UTF-8?q?=E6=A4=85=E5=AD=90=E3=81=AE=E5=A2=97=E3=81=88?= =?UTF-8?q?=E6=96=B9=E3=82=92=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bench/benchmarker/world/owner.go | 20 +++++++++++++++----- bench/benchmarker/world/owner_test.go | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bench/benchmarker/world/owner.go b/bench/benchmarker/world/owner.go index 86b9d27a..93902443 100644 --- a/bench/benchmarker/world/owner.go +++ b/bench/benchmarker/world/owner.go @@ -236,10 +236,20 @@ func (p *Owner) ValidateChairs(serverSide *GetOwnerChairsResponse) error { return nil } +const ( + desiredChairNumFirstTerm = 15000 + desiredChairNumCommonRatio = 1.02 +) + +var ( + desiredChairNum50thTerm = desiredChairNumFirstTerm * math.Pow(desiredChairNumCommonRatio, 50-1) + desiredChairNum50Sum = int(desiredChairNumFirstTerm * (math.Pow(desiredChairNumCommonRatio, 50) - 1) / (desiredChairNumCommonRatio - 1)) +) + func desiredChairNum(s int) int { - const ( - a = 15000 - r = 1.02 - ) - return int(math.Log((a-float64(s)*(1-r))/a) / math.Log(r)) + if s >= desiredChairNum50Sum { + // 50個以降は必要売り上げが一定 + return 50 + int(float64(s-desiredChairNum50Sum)/desiredChairNum50thTerm) + } + return int(math.Log((desiredChairNumFirstTerm-float64(s)*(1-desiredChairNumCommonRatio))/desiredChairNumFirstTerm) / math.Log(desiredChairNumCommonRatio)) } diff --git a/bench/benchmarker/world/owner_test.go b/bench/benchmarker/world/owner_test.go index 415efcf6..46bedcf4 100644 --- a/bench/benchmarker/world/owner_test.go +++ b/bench/benchmarker/world/owner_test.go @@ -4,7 +4,7 @@ import "testing" func TestDesiredChairNum(t *testing.T) { n := 0 - for i := 0; i < 10000; i++ { + for i := 0; i < 30000; i++ { num := desiredChairNum(i * 100) if num > n { n = num