1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
package casino
import "fmt"
// CrapsConfig selects explicit house rules and the shared wager limits.
type CrapsConfig struct {
Odds int `yaml:"odds,omitempty"` // 0 = 3-4-5x; positive = uniform Nx
Field12 int `yaml:"field_12,omitempty"`
Variant string `yaml:"variant,omitempty"`
}
func (c CrapsConfig) Normalize() CrapsConfig {
if c.Field12 == 0 {
c.Field12 = 2
}
return c
}
func validateCraps(c TableConfig) error {
if c.Craps.Odds < 0 || c.Craps.Odds > 1000000 {
return fmt.Errorf("craps odds must be 0 (3-4-5x) or 1..1000000")
}
if c.Craps.Field12 != 0 && c.Craps.Field12 != 2 && c.Craps.Field12 != 3 {
return fmt.Errorf("craps field_12 must be 2 or 3")
}
switch c.Craps.variant() {
case "bank", "simplified", "high_point", "crapless", "new_york", "die_rich", "diceless":
default:
return fmt.Errorf("unknown craps variant %q", c.Craps.Variant)
}
if !c.Craps.allows("odds") && c.Craps.Odds != 0 {
return fmt.Errorf("this craps variant does not support odds")
}
return nil
}
func crapsNumber(n int) bool { return n == 4 || n == 5 || n == 6 || n == 8 || n == 9 || n == 10 }
func crapsTrueOdds(n int) (int, int) {
switch n {
case 2, 12:
return 6, 1
case 3, 11:
return 3, 1
case 4, 10:
return 2, 1
case 5, 9:
return 3, 2
default:
return 6, 5
}
}
func (c CrapsConfig) oddsLimit(n int, against bool) int {
if c.Odds > 0 {
return c.Odds
}
if c.variant() == "crapless" && !crapsNumber(n) {
return 1
}
if against {
return 6
}
switch n {
case 4, 10:
return 3
case 5, 9:
return 4
default:
return 5
}
}
func (c TableConfig) CrapsRulesText() string {
r := c.Craps.Normalize()
if r.variant() != "bank" && r.variant() != "diceless" {
return r.variantRulesText()
}
prefix := ""
if r.variant() == "diceless" {
prefix = "Diceless Craps — bank rules using cards, not dice. Two independent six-card packs labelled 1-6; draw one from each, replace and reshuffle BOTH after EVERY roll. All 36 ordered pairs are equally likely. No finite shoe or card counting.\n"
}
odds := "3-4-5x (don't: 6x laid)"
if r.Odds > 0 {
odds = fmt.Sprintf("%dx", r.Odds)
}
return prefix + fmt.Sprintf("Bank Craps | Free odds %s | Field 12 pays %d:1\n"+
"bet <amount> on pass / dontpass / come / dontcome / field\n"+
"bet <amount> on place 6 / buy 4 / lay 10 / hard 8 / hop 2 3\n"+
"bet <amount> on seven / craps / eleven / ace-deuce / aces / boxcars / horn\n"+
"bet <amount> on odds pass / odds come 6 (also dontpass/dontcome)\n"+
"bet <amount> on fire / small / tall / all (before shooter's first roll only)\n"+
"Pass/come 1:1; don't bars 12. Place 4/10 9:5, 5/9 7:5, 6/8 7:6.\n"+
"Buy/lay true odds; 5%% commission on buy STAKE / lay WIN, rounded up, wins only.\n"+
"Field 2 pays 2:1; 3/4/9/10/11 pay 1:1. Hard 4/10 7:1; 6/8 9:1.\n"+
"Seven 4:1; craps 7:1; 11/3 15:1; 2/12 30:1; hop easy 15:1, hard 30:1.\n"+
"Horn splits equally across 2/3/11/12. Fire: 4/5/6 distinct made points pay 24/249/999:1.\n"+
"Small (2-6) / Tall (8-12) pay 34:1; All pays 175:1. Any 7 resets ATS.\n"+
"Place/buy/hard and come odds are OFF on come-out; lay and don't odds work.\n"+
"Exact payout units required; no fractional-credit rounding except commission.\n"+
"Solo: roll anytime. Multiplayer: 10 seconds to bet, then 60 seconds for the shooter.\n"+
"Bets remain open until the roll. Dice rotate on seven-out.\n"+
"autoroll: repeat every 3 seconds on your turn (multiplayer waits 10 seconds).\n"+
"unbet: remove every non-contract bet and all free odds; pass/come contracts stay.\n"+
"stop cancels autoroll without leaving; in manual mode stop waits for live bets.\n"+
"Disconnect forfeits live bets.\n"+
"Winning bets return stake and are removed (no automatic pressing).", odds, r.Field12)
}
// outcome returns resolved and profit numerator/denominator; -1 means loss.
func crapsOutcome(kind string, n, a, b, point, field12 int) (bool, int, int) {
s := a + b
hard := a == b
switch kind {
case "pass", "come", "dontpass", "dontcome":
against := kind == "dontpass" || kind == "dontcome"
if n == 0 {
if against {
switch s {
case 2, 3:
return true, 1, 1
case 7, 11:
return true, -1, 1
case 12:
return true, 0, 1
}
} else {
switch s {
case 7, 11:
return true, 1, 1
case 2, 3, 12:
return true, -1, 1
}
}
return false, 0, 1
}
if s != 7 && s != n {
return false, 0, 1
}
if (s == n) != against {
return true, 1, 1
}
return true, -1, 1
case "place", "buy", "lay":
if point == 0 && kind != "lay" {
return false, 0, 1
}
if s != 7 && s != n {
return false, 0, 1
}
if (s == 7) != (kind == "lay") {
return true, -1, 1
}
x, y := crapsTrueOdds(n)
if kind == "lay" {
x, y = y, x
}
if kind == "place" {
x, y = crapsPlaceOdds(n)
}
return true, x, y
case "hard":
if point == 0 {
return false, 0, 1
}
if s == 7 || (s == n && !hard) {
return true, -1, 1
}
if s == n {
if n == 4 || n == 10 {
return true, 7, 1
}
return true, 9, 1
}
return false, 0, 1
case "field":
switch s {
case 2:
return true, 2, 1
case 12:
return true, field12, 1
case 3, 4, 9, 10, 11:
return true, 1, 1
}
return true, -1, 1
case "seven":
if s == 7 {
return true, 4, 1
}
case "craps":
if s == 2 || s == 3 || s == 12 {
return true, 7, 1
}
case "eleven", "ace-deuce":
if (kind == "eleven" && s == 11) || (kind == "ace-deuce" && s == 3) {
return true, 15, 1
}
case "aces", "boxcars":
if (kind == "aces" && s == 2) || (kind == "boxcars" && s == 12) {
return true, 30, 1
}
case "hop":
if a*10+b == n || b*10+a == n {
if hard {
return true, 30, 1
}
return true, 15, 1
}
case "horn":
switch s {
case 2, 12:
return true, 27, 4
case 3, 11:
return true, 3, 1
}
default:
return false, 0, 1
}
return true, -1, 1
}
|