Documentation ¶
Overview ¶
Package paycalc contains a tournament payout tables.
Example ¶
package main import ( "fmt" "github.com/cardrank/cardrank/paycalc" ) func main() { const typ, entries, buyin, guaranteed, rake = paycalc.Top10, 110, 1000, 60000, 0.15 levels, amounts, payouts := typ.Stakes(entries, buyin, guaranteed, rake) for i := 0; i < len(levels); i++ { title := paycalc.LevelTitle(levels[i][0], levels[i][1]) fmt.Printf("%s (%0.2f%%): %d\n", title, amounts[i]*100, payouts[i]) } }
Output: 1st (28.00%): 26180 2nd (17.00%): 15895 3rd (10.60%): 9911 4th (8.60%): 8041 5th (7.60%): 7106 6th (5.30%): 4955 7th (4.30%): 4020 8th (3.30%): 3085 9th (2.70%): 2524 10th (2.10%): 1963 11-15 (2.10%): 1963
Example (Payout) ¶
package main import ( "fmt" "github.com/cardrank/cardrank/paycalc" ) func main() { const typ, entries, buyin, guaranteed, rake = paycalc.Top10, 110, 1000, 60000, 0.15 for i := 0; i < 15; i++ { payout := typ.Payout(i, entries, buyin, guaranteed, rake) fmt.Printf("%d: %d\n", i+1, payout) } }
Output: 1: 26180 2: 15895 3: 9911 4: 8041 5: 7106 6: 4955 7: 4020 8: 3085 9: 2524 10: 1963 11: 1963 12: 1963 13: 1963 14: 1963 15: 1963
Index ¶
- Variables
- func Calc(f float64, entries int, buyin, guaranteed int64, rake float64) int64
- func EpsilonEqual[R, S, T Ordered](a R, b S, epsilon T) bool
- func Init() error
- func LevelTitle(last, n int) string
- func Register(typ Type, t *Table) error
- func RegisterBytes(typ Type, buf []byte, top float64, name string) error
- func RegisterReader(typ Type, r io.Reader, top float64, name string) error
- func Total(entries int, buyin, guaranteed int64, rake float64) int64
- type Ordered
- type Table
- func (t *Table) Amount(n, entries int) float64
- func (t *Table) Amounts(start, end, entries int) []float64
- func (t *Table) At(row, col int) float64
- func (t *Table) Entries(entries int) int
- func (t *Table) EntriesMax() int
- func (t *Table) EntriesTitle(entries int) string
- func (t *Table) Format(f fmt.State, verb rune)
- func (t *Table) Levels(start, end int) []int
- func (t *Table) LevelsMax(entries int) int
- func (t *Table) LevelsTitle(n int) string
- func (t *Table) Name() string
- func (t *Table) Payout(n, entries int, buyin, guaranteed int64, rake float64) int64
- func (t *Table) Payouts(start, end, entries int, buyin, guaranteed int64, rake float64) []int64
- func (t *Table) RankingMax() int
- func (t *Table) Rankings(start, end int) []int
- func (t *Table) Stakes(entries int, buyin, guaranteed int64, rake float64) ([][2]int, []float64, []int64)
- func (t *Table) Title() string
- func (t *Table) Top() float64
- func (t *Table) WriteCSV(w io.Writer) error
- func (t *Table) WriteMarkdown(w io.Writer, header int) error
- func (t *Table) WriteTable(w io.Writer, title bool) error
- func (t *Table) WriteTo(w io.Writer, f func(interface{}, int, bool) string, ...) error
- type Type
- func (typ Type) Amount(n, entries int) float64
- func (typ Type) Amounts(start, end, entries int) []float64
- func (typ Type) At(row, col int) float64
- func (typ Type) Entries(entries int) int
- func (typ Type) EntriesMax() int
- func (typ Type) EntriesTitle(entries int) string
- func (typ Type) Format(f fmt.State, verb rune)
- func (typ Type) Levels(start, end int) []int
- func (typ Type) LevelsMax(entries int) int
- func (typ Type) LevelsTitle(n int) string
- func (typ Type) MarshalText() ([]byte, error)
- func (typ Type) Name() string
- func (typ Type) Payout(n, entries int, buyin, guaranteed int64, rake float64) int64
- func (typ Type) Payouts(start, end, entries int, buyin, guaranteed int64, rake float64) []int64
- func (typ Type) RankingMax() int
- func (typ Type) Rankings(start, end int) []int
- func (typ Type) Stakes(entries int, buyin, guaranteed int64, rake float64) ([][2]int, []float64, []int64)
- func (typ Type) Title() string
- func (typ Type) Top() float64
- func (typ *Type) UnmarshalText(buf []byte) error
- func (typ Type) WriteCSV(w io.Writer) error
- func (typ Type) WriteMarkdown(w io.Writer, header int) error
- func (typ Type) WriteTable(w io.Writer, title bool) error
- func (typ Type) WriteTo(w io.Writer, f func(interface{}, int, bool) string, ...) error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var Precision = int(math.Pow(10, 2))
Precision is the precision amount used by Calc.
var Round = func(f float64) float64 { return math.Round(f*float64(Precision)) / float64(Precision) }
Round is the round implementation used by Calc. Rounds to Precision.
Functions ¶
func Calc ¶
Calc calculates a payout for the percentage f, based on entries, buyin, guaranteed amount, and rake. Uses Round to round to Precision.
func EpsilonEqual ¶
EpsilonEqual returns true when a and b are within epsilon.
func RegisterBytes ¶
RegisterBytes registers a tournament payout table read as CSV from buf.
func RegisterReader ¶
RegisterReader registers a tournament payout table read as CSV from the reader.
Types ¶
type Ordered ¶
type Ordered interface { ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ~float32 | ~float64 }
Ordered is a constraint that permits any ordered type: any type that supports the operators < <= >= >. If future releases of Go add new ordered types, this constraint will be modified to include them.
Note that floating-point types may contain NaN ("not-a-number") values. An operator such as == or < will always report false when comparing a NaN value with any other value, NaN or not. See the [Compare] function for a consistent way to compare NaN values.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is a tournament payout table.
func LoadReader ¶
LoadReader loads a CSV formatted tournament payout table from the reader.
func (*Table) Amounts ¶
Amounts returns the tournament payout amounts for positions for [start, end) as determined by the number of entries.
func (*Table) EntriesMax ¶
EntriesMax returns the max entries for the tournament payout table.
func (*Table) EntriesTitle ¶
EntriesTitle returns the column title for the specified entries in the tournament payout table.
func (*Table) Format ¶
Format satisfies the fmt.Formatter interface.
func (*Table) LevelsMax ¶
LevelsMax returns the max levels for the tournament payout table for the specified entries.
func (*Table) LevelsTitle ¶
LevelsTitle returns the level (row) title for rank n in the tournament payout table.
func (*Table) Payouts ¶
Payouts returns the tournament payouts for positions from [start, end) based on the number of entries.
func (*Table) RankingMax ¶
RankingMax returns the max ranking for the tournament payout table.
func (*Table) Stakes ¶
func (t *Table) Stakes(entries int, buyin, guaranteed int64, rake float64) ([][2]int, []float64, []int64)
Stakes returns slice of the ranges of the paid levels in the form of [low, high), table amount, and calculated payouts for each position.
func (*Table) WriteMarkdown ¶
WriteMarkdown writes a Markdown formatted version of the tournament payout table to w.
func (*Table) WriteTable ¶
WriteTable writes a plain text version of the tournament payout table, along with optional title, to w.
type Type ¶
type Type int
Type is a tournament payout table type.
func (Type) Amounts ¶
Amounts returns the tournament payout amounts for positions for [start, end) as determined by the number of entries.
func (Type) EntriesMax ¶
EntriesMax returns the max entries for the tournament payout table.
func (Type) EntriesTitle ¶
EntriesTitle returns the column title for the specified entries in the tournament payout table.
func (Type) Format ¶
Format satisfies the fmt.Formatter interface.
func (Type) LevelsMax ¶
LevelsMax returns the max levels for the tournament payout table for the specified entries.
func (Type) LevelsTitle ¶
LevelsTitle returns the level (row) title for rank n in the tournament payout table.
func (Type) MarshalText ¶
MarshalText satisfies the encoding.TextMarshaler interface.
func (Type) Payouts ¶
Payouts returns the tournament payouts for positions from [start, end) based on the number of entries.
func (Type) RankingMax ¶
RankingMax returns the max ranking for the tournament payout table.
func (Type) Stakes ¶
func (typ Type) Stakes(entries int, buyin, guaranteed int64, rake float64) ([][2]int, []float64, []int64)
Stakes returns slice of the ranges of the paid levels in the form of [low, high), corresponding tournament payout table amount f, and calculated amount for each position.
func (*Type) UnmarshalText ¶
UnmarshalText satisfies the encoding.TextUnmarshaler interface.
func (Type) WriteMarkdown ¶
WriteMarkdown writes a Markdown formatted version of the tournament payout table to w.
func (Type) WriteTable ¶
WriteTable writes a plain text version of the tournament payout table, along with optional title, to w.