Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function myStrategy ({ rules, bets, hand, playerMind }) { ... }
| `noBetting` | Makes no bets. Useful as a baseline or placeholder. |
| `minPassLineOnly` | Pass line bet at `minBet` on each come-out. No odds. |
| `minPassLineMaxOdds` | Pass line at `minBet` + maximum odds behind the line once a point is set. |
| `minPassLineMidOdds` | Pass line at `minBet` + approximately half of maximum odds once a point is set. Odds multiple is `Math.ceil(maxOddsMultiple / 2)`. |
| `minPassLineMinOdds` | Pass line at `minBet` + minimum payable odds once a point is set. Rounds up to nearest $5 for points 6/8, nearest even number for points 5/9, exact `minBet` for points 4/10. |
| `placeSixEight` | Place the 6 and 8 at the nearest multiple of $6 ≥ `minBet`. No pass line. Bets come down on a win and are re-placed next turn. |
| `minComeLineMaxOdds` | One come bet at `minBet` with max odds once it travels to a point. |
Expand Down
16 changes: 16 additions & 0 deletions betting.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ function minPassLineMaxOdds (opts) {
})
}

function minPassLineMidOdds (opts) {
const bets = minPassLineOnly(opts)
const { rules, hand } = opts

if (hand.isComeOut === false && !bets?.pass?.odds) {
const maxMultiple = rules.maxOddsMultiple[hand.point]
const oddsMultiple = Math.ceil(maxMultiple / 2)
const oddsAmount = oddsMultiple * bets.pass.line.amount
bets.pass.odds = { amount: oddsAmount }
bets.new += oddsAmount
}

return bets
}

function minPassLineMinOdds (opts) {
const bets = minPassLineOnly(opts)
const { rules, hand } = opts
Expand Down Expand Up @@ -318,6 +333,7 @@ module.exports = {
minPassLineOnly,
lineMaxOdds,
minPassLineMaxOdds,
minPassLineMidOdds,
minPassLineMinOdds,
placeSixEight,
placeSixEightUnlessPoint,
Expand Down
23 changes: 23 additions & 0 deletions betting.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1392,3 +1392,26 @@ tap.test('minPassLineMinOdds: no odds on come-out', (t) => {
t.notOk(result.pass?.odds, 'no odds on come-out')
t.end()
})

tap.test('minPassLineMidOdds: places roughly half of max odds on point set', (t) => {
const rules = { minBet: 5, maxOddsMultiple: { 4: 3, 5: 4, 6: 5, 8: 5, 9: 4, 10: 3 } }
const hand = { isComeOut: false, result: 'point set', point: 5 }
const bets = { pass: { line: { amount: 5 } } }

const result = lib.minPassLineMidOdds({ rules, bets, hand })
const expectedMultiple = Math.ceil(rules.maxOddsMultiple[5] / 2)

t.ok(result.pass.odds, 'odds placed')
t.equal(result.pass.odds.amount, expectedMultiple * rules.minBet, 'odds at ceil(maxMultiple/2) * minBet')
t.end()
})

tap.test('minPassLineMidOdds: no odds on come-out', (t) => {
const rules = { minBet: 5, maxOddsMultiple: { 4: 3, 5: 4, 6: 5, 8: 5, 9: 4, 10: 3 } }
const hand = { isComeOut: true }

const result = lib.minPassLineMidOdds({ rules, hand })

t.notOk(result.pass?.odds, 'no odds on come-out')
t.end()
})
Loading