0

これは、コーディングに苦労しているというよりも、抽象的な「これにどのようにアプローチするか」という質問です。ポイントが 0 のキャラクター作成画面を作成したいのですが、ある統計から取って別の統計に入れることができます。このシステムの下で、どのように統計をランダム化しますか。基本統計と最大偏差がありますが、統計をランダム化して特殊なキャラクターを作成する方法がわかりません。1 つが 150%、他の 2 つの統計が 75% というわけではありませんが、加重ランダマイザーを使用した穏やかな専門化が望ましいと思います。疑似コードまたはそれを行う方法の説明で自由に応答してください。:D

4

1 に答える 1

0

Pythonでの私のソリューションは次のとおりです。

import random
from operator import add, sub

baseStats = {
"baseHealth":10.00,
"baseSpeed":10.00,
"baseAccuracy":10.00,
}
baseDeviation = 3

ops = (add, sub)
charStats = {}

#Make spread. Eg: If the deviation is 3 It'll be [0, 0, 0, 0, 1, 1, 1, 2, 2, 3]
#With the highest deviations being the rarest
spread = []
for i in range(1,baseDeviation+2):
    for j in range(1,baseDeviation+2-i):
        spread.append(i)
print(spread)

#Make a list of stats without the base values.
remainingStats = []
for key, value in baseStats.items():
    charStats[key] = value
    remainingStats.append(key)

#Choose a stat and add or subract a random choice from our weighted spread
op = random.choice(ops)
chosenOne = random.choice(remainingStats)
remainingStats.remove(chosenOne)
chosenNumber = random.choice(spread)
charStats[chosenOne] = op(charStats[chosenOne],chosenNumber)
spread.remove(chosenNumber)

#Work out the difference between the randomised stat and the standard then give
#it to one and leave the other be.
difference = baseStats[chosenOne] - charStats[chosenOne]
charStats[random.choice(remainingStats)] = charStats[random.choice(remainingStats)] + difference

print(charStats)
于 2016-04-26T19:51:06.457 に答える