Skip to content
Open
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
28 changes: 16 additions & 12 deletions table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,20 +289,24 @@ func (t *Table) payout() {
})
// select winners who split pot if more than one
winners := []*Player{}
h1 := hands[pot.contesting[0]]
for _, seat := range pot.contesting {
h2 := hands[seat]
if h1.CompareTo(h2) != 0 {
break
if len(pot.contesting) == 1 {
winners = []*Player{pot.contesting[0]}
} else {
h1 := hands[pot.contesting[0]]
for _, seat := range pot.contesting {
h2 := hands[seat]
if h1.CompareTo(h2) != 0 {
break
}
winners = append(winners, seat)
}
winners = append(winners, seat)
// sort closest to the button for spare chips in split pot
sort.Slice(winners, func(i, j int) bool {
iDist := t.distanceFromButton(winners[i])
jDist := t.distanceFromButton(winners[j])
return iDist < jDist
})
}
// sort closest to the button for spare chips in split pot
sort.Slice(winners, func(i, j int) bool {
iDist := t.distanceFromButton(winners[i])
jDist := t.distanceFromButton(winners[j])
return iDist < jDist
})
// payout chips
for i, seat := range winners {
seat.Chips += pot.chips / len(winners)
Expand Down
12 changes: 12 additions & 0 deletions table/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ var (
},
description: "full hand 1",
},
{
start: threePerson100Buyin(),
actions: []table.Action{
{table.Raise, 5},
{Type: table.Fold},
{Type: table.Fold},
},
condition: func(s table.State) bool {
return s.Seats[0].Chips == 97 && s.Seats[1].Chips == 101 && s.Seats[2].Chips == 99 && s.Round == table.PreFlop
},
description: "preflop folds",
},
}
)

Expand Down