Documentation
¶
Overview ¶
1個1個のダイスの供給の仕方を定義するパッケージ。 このパッケージに含まれる構造体を利用することで、ダイスの値をランダムにするか、指定したものにするかを切り替えることができる。
ダイスの値をランダムにする場合は、MT19937を使用する。 ダイスの値を指定したものにする場合は、Queueを使用する。
Example (MT19937WithSeedFromTime) ¶
ダイスをランダムに供給:現在時刻をシードとする場合の例。
// ダイスの値をランダムにする dieFeeder := NewMT19937WithSeedFromTime() // 6面ダイスを1個振る d, _ := dieFeeder.Next(6) return d
Output:
Example (MT19937WithSpecifiedSeed) ¶
ダイスをランダムに供給:シードを指定する場合の例。
// ダイスの値をランダムにする dieFeeder := NewMT19937(1) // 6面ダイスを1個振る d, _ := dieFeeder.Next(6) return d
Output:
Example (Queue) ¶
供給するダイスを指定する場合の例。
// 供給するダイスを指定する dieFeeder := NewQueue([]dice.Die{{1, 6}, {3, 6}, {5, 6}}) // 6面ダイスを1個振る d, err := dieFeeder.Next(6) if err != nil { return } fmt.Println(d.String())
Output: <Die 1/6>
Index ¶
- type DieFeeder
- type MT19937
- type Queue
- func (f *Queue) Append(dice []dice.Die)
- func (f *Queue) CanSpecifyDie() bool
- func (f *Queue) Clear()
- func (f *Queue) Dice() []dice.Die
- func (f *Queue) IsEmpty() bool
- func (f *Queue) Next(_ int) (dice.Die, error)
- func (f *Queue) Push(d dice.Die)
- func (f *Queue) Remaining() int
- func (f *Queue) Set(d []dice.Die)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DieFeeder ¶
type DieFeeder interface { // Next はダイスを1つ供給する。 // // sides: ダイスの面数 Next(sides int) (dice.Die, error) // CanSpecifyDie は、供給されるダイスを指定できるかを返す。 CanSpecifyDie() bool }
DieFeeder は、ダイス供給機のインターフェース。
type MT19937 ¶
type MT19937 struct {
// contains filtered or unexported fields
}
ランダムにダイスを取り出すダイス供給機の構造体。 Ruby版BCDiceと同様にメルセンヌ・ツイスタを使用する。
func NewMT19937WithSeedFromTime ¶
func NewMT19937WithSeedFromTime() *MT19937
NewMT19937WithSeedFromTime は、現在の時刻をシードとしたMT19937ダイス供給機を返す。
func (*MT19937) CanSpecifyDie ¶
CanSpecifyDie は、供給されるダイスを指定できるかを返す。 MT19937ダイス供給機ではfalseを返す。
Click to show internal directories.
Click to hide internal directories.