Documentation ¶
Overview ¶
Package paycalc contains a tournament payout tables.
Example ¶
package main import ( "fmt" "github.com/cardrank/cardrank/paycalc" ) func main() { const entries, buyin, guaranteed, rake = 88, 200000, 10000000, 0.15 for _, typ := range []paycalc.Type{paycalc.Top10, paycalc.Top15, paycalc.Top20} { paid, row, col := typ.Paid(entries) fmt.Printf("%t (%d of %d):\n", typ, paid, entries) fmt.Printf(" l/e: %s/%s\n", typ.MaxLevelTitle(paid), typ.EntriesTitle(entries)) fmt.Printf(" short: %.2f%%\n", typ.Unallocated(paid, row, col)*100.0) fmt.Printf(" buyin: %d\n", buyin) fmt.Printf(" rake: %.0f%%\n", rake*100.0) fmt.Printf(" gtd: %d\n", guaranteed) fmt.Printf(" prize: %d\n", paycalc.Prize(entries, buyin, guaranteed, rake)) levels, amounts, payouts, total := typ.Stakes(entries, buyin, guaranteed, rake) fmt.Printf(" total: %d\n", total) var sum int64 var gsum, fsum float64 for i, level := range levels { title := paycalc.LevelTitle(level[0], level[1]) g := amounts[i] * float64(level[1]-level[0]) f := float64(payouts[i]) / float64(total) * float64(level[1]-level[0]) fmt.Printf(" %5s: %8d (%6.2f%% -> %6.2f%%)\n", title, payouts[i], g*100.0, f*100.0) sum, gsum, fsum = sum+payouts[i]*int64(level[1]-level[0]), gsum+g, fsum+f } fmt.Printf(" Total: %8d (%6.2f%% %6.2f%%)\n\n", sum, gsum*100.0, fsum*100.0) } }
Output: Top 10% (9 of 88): l/e: 9th/76-100 short: 2.50% buyin: 200000 rake: 15% gtd: 10000000 prize: 14960000 total: 14960004 1st: 4603077 ( 30.00% -> 30.77%) 2nd: 3068718 ( 20.00% -> 20.51%) 3rd: 1841231 ( 12.00% -> 12.31%) 4th: 1457642 ( 9.50% -> 9.74%) 5th: 1227488 ( 8.00% -> 8.21%) 6th: 920616 ( 6.00% -> 6.15%) 7th: 767180 ( 5.00% -> 5.13%) 8th: 613744 ( 4.00% -> 4.10%) 9th: 460308 ( 3.00% -> 3.08%) Total: 14960004 ( 97.50% 100.00%) Top 15% (14 of 88): l/e: 11-14/76-100 short: 1.86% buyin: 200000 rake: 15% gtd: 10000000 prize: 14960000 total: 14960007 1st: 4344406 ( 28.50% -> 29.04%) 2nd: 2515183 ( 16.50% -> 16.81%) 3rd: 1554841 ( 10.20% -> 10.39%) 4th: 1295701 ( 8.50% -> 8.66%) 5th: 1143265 ( 7.50% -> 7.64%) 6th: 914612 ( 6.00% -> 6.11%) 7th: 762177 ( 5.00% -> 5.09%) 8th: 533524 ( 3.50% -> 3.57%) 9th: 381089 ( 2.50% -> 2.55%) 10th: 381089 ( 2.50% -> 2.55%) 11-14: 283530 ( 7.44% -> 7.58%) Total: 14960007 ( 98.14% 100.00%) Top 20% (18 of 88): l/e: 16-18/76-100 short: 2.60% buyin: 200000 rake: 15% gtd: 10000000 prize: 14960000 total: 14960010 1st: 4300617 ( 28.00% -> 28.75%) 2nd: 2611089 ( 17.00% -> 17.45%) 3rd: 1290185 ( 8.40% -> 8.62%) 4th: 1151951 ( 7.50% -> 7.70%) 5th: 998358 ( 6.50% -> 6.67%) 6th: 844764 ( 5.50% -> 5.65%) 7th: 660452 ( 4.30% -> 4.41%) 8th: 445421 ( 2.90% -> 2.98%) 9th: 399343 ( 2.60% -> 2.67%) 10th: 276469 ( 1.80% -> 1.85%) 11-15: 276469 ( 9.00% -> 9.24%) 16-18: 199672 ( 3.90% -> 4.00%) Total: 14960010 ( 97.40% 100.00%)
Example (Payouts) ¶
package main import ( "fmt" "github.com/cardrank/cardrank/paycalc" ) func main() { const entries, buyin, guaranteed, rake = 110, 1000, 60000, 0.15 for _, typ := range []paycalc.Type{paycalc.Top10, paycalc.Top15, paycalc.Top20} { paid, _, _ := typ.Paid(entries) fmt.Printf("%t (%d of %d):\n", typ, paid, entries) payouts, total := typ.Payouts(entries, buyin, guaranteed, rake) for i, payout := range payouts { fmt.Printf(" %2d: %5d\n", i+1, payout) } fmt.Printf("Total: %5d\n\n", total) } }
Output: Top 10% (11 of 110): 1: 28581 2: 17353 3: 10820 4: 8779 5: 7758 6: 5410 7: 4390 8: 3369 9: 2757 10: 2144 11: 2144 Total: 93505 Top 15% (17 of 110): 1: 27500 2: 15911 3: 9134 4: 7170 5: 6188 6: 5206 7: 4125 8: 2750 9: 2063 10: 1719 11: 1719 12: 1719 13: 1719 14: 1719 15: 1719 16: 1572 17: 1572 Total: 93505 Top 20% (22 of 110): 1: 26067 2: 15930 3: 7917 4: 6951 5: 5986 6: 5021 7: 3862 8: 2607 9: 2317 10: 1545 11: 1545 12: 1545 13: 1545 14: 1545 15: 1545 16: 1111 17: 1111 18: 1111 19: 1111 20: 1111 21: 1014 22: 1014 Total: 93511
Index ¶
- Variables
- func Calc(f float64, total int64, unallocated float64) int64
- func EntriesTitle(last, entries int) string
- func Equal[S, T Ordered](a S, b T) bool
- func EqualEpsilon[R, S, T Ordered](a R, b S, epsilon T) bool
- func Init() error
- func LevelTitle(last, level int) string
- func Prize(entries int, buyin, guaranteed int64, rake float64) int64
- func Register(typ Type, t *Table) error
- func RegisterBytes(typ Type, name string, top float64, buf []byte) error
- func RegisterReader(typ Type, name string, top float64, r io.Reader) error
- type Ordered
- type Table
- func (t *Table) Amount(level, 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) Level(level int) int
- func (t *Table) LevelTitle(level int) string
- func (t *Table) MaxLevelTitle(level int) string
- func (t *Table) Name() string
- func (t *Table) Paid(entries int) (int, int, int)
- func (t *Table) Payouts(entries int, buyin, guaranteed int64, rake float64) ([]int64, int64)
- func (t *Table) Stakes(entries int, buyin, guaranteed int64, rake float64) ([][2]int, []float64, []int64, int64)
- func (t *Table) Title() string
- func (t *Table) Top() float64
- func (t *Table) Unallocated(paid, row, col int) 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(level, 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) Level(level int) int
- func (typ Type) LevelTitle(level int) string
- func (typ Type) MarshalText() ([]byte, error)
- func (typ Type) MaxLevelTitle(level int) string
- func (typ Type) Name() string
- func (typ Type) Paid(entries int) (int, int, int)
- func (typ Type) Payouts(entries int, buyin, guaranteed int64, rake float64) ([]int64, int64)
- func (typ Type) Stakes(entries int, buyin, guaranteed int64, rake float64) ([][2]int, []float64, []int64, int64)
- func (typ Type) Title() string
- func (typ Type) Top() float64
- func (typ Type) Unallocated(paid, row, col int) 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 Epsilon = 0.0000000001
Epsilon is the epsilon value used for for [EpsilonEqual].
var Paid = func(f float64, entries int) int { return int(PaidRound(f * float64(entries))) }
Paid returns the number of paid rankings, uses PaidRound.
var PaidRound = math.Ceil
PaidRound by default is math.Ceil and is used by [PaidMax] to determine the number of paid rankings.
var Precision float64 = 10000
Precision is the precision amount used by Calc.
var Round = func(f float64) float64 { return math.Ceil(math.Round(f*Precision) / Precision) }
Round is the round implementation used by Calc. Rounds to Precision.
Functions ¶
func EntriesTitle ¶ added in v0.14.1
EntriesTitle formats the entries title of last, n.
func EqualEpsilon ¶ added in v0.14.1
EqualEpsilon returns true when a and b are within epsilon.
func LevelTitle ¶
LevelTitle formats the levels title of last, n.
func Prize ¶ added in v0.14.1
Prize calculates the total payout based on entries, buyin, guaranteed amount, and rake. Uses Round to round to Precision.
func RegisterBytes ¶
RegisterBytes registers a tournament payout table read as CSV from buf.
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) Amount ¶
Amount returns the amount for the level and entries from the tournament payout table.
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) Level ¶ added in v0.14.1
Level returns the row for the level in the tournament payout table.
func (*Table) LevelTitle ¶ added in v0.14.1
LevelTitle returns the row title for the level in the tournament payout table.
func (*Table) MaxLevelTitle ¶ added in v0.14.1
MaxLevelTitle returns the row title for the max level in tournament payout table.
func (*Table) Paid ¶ added in v0.14.1
Paid returns the paid rankings, level (row) and corresponding entries column for the tournament payout table.
func (*Table) Payouts ¶
Payouts returns the tournament payouts for rankings from [start, end) based on the number of entries.
func (*Table) Stakes ¶
func (t *Table) Stakes(entries int, buyin, guaranteed int64, rake float64) ([][2]int, []float64, []int64, int64)
Stakes returns the paid levels as [low, high), the tournament table value per level, the calculated payouts per level, and the total amount paid.
func (*Table) Unallocated ¶ added in v0.14.1
Unallocated returns the unallocated amount for the paid rankings, row, and col from the tournament payout table.
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) Amount ¶
Amount returns the amount for the level and entries from the tournament payout table.
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) LevelTitle ¶ added in v0.14.1
LevelTitle returns the level (row) title for rank n in the tournament payout table.
func (Type) MarshalText ¶
MarshalText satisfies the encoding.TextMarshaler interface.
func (Type) MaxLevelTitle ¶ added in v0.14.1
MaxLevelTitle returns the row title for the max level in tournament payout table.
func (Type) Paid ¶ added in v0.14.1
Paid returns the paid rankings, level (row) and corresponding entries column for the tournament payout table.
func (Type) Stakes ¶
func (typ Type) Stakes(entries int, buyin, guaranteed int64, rake float64) ([][2]int, []float64, []int64, int64)
Stakes returns the paid levels as [low, high), the tournament table value per level, the calculated payouts per level, and the total amount paid.
func (Type) Unallocated ¶ added in v0.14.1
Unallocated returns the unallocated amount for the paid rankings, row, and col from the tournament payout table.
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.