texasholdem 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/src/action.ts +3 -3
- package/src/betting.ts +9 -9
- package/src/card.ts +1 -1
- package/src/deck.ts +4 -4
- package/src/error.ts +1 -1
- package/src/evaluator.ts +5 -4
- package/src/event.ts +3 -3
- package/src/hand.ts +18 -18
- package/src/index.ts +14 -14
- package/src/loop.ts +9 -9
- package/src/player.ts +3 -3
- package/src/pokersolver.d.ts +3 -0
- package/src/position.ts +10 -10
- package/src/pot.ts +3 -3
- package/src/table.ts +11 -11
- package/tsconfig.json +2 -2
- package/tsup.config.ts +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "texasholdem",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Modular, functional Texas Hold'em poker engine built with Effect-TS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"main": "./dist/index.js",
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "
|
|
13
|
+
"build": "tsup",
|
|
14
14
|
"test": "vitest run",
|
|
15
15
|
"test:watch": "vitest",
|
|
16
16
|
"typecheck": "tsc --noEmit",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"eslint-config-prettier": "^10.1.8",
|
|
34
34
|
"fast-check": "^3.23.0",
|
|
35
35
|
"prettier": "^3.8.1",
|
|
36
|
+
"tsup": "^8.5.1",
|
|
36
37
|
"typescript": "^5.7.0",
|
|
37
38
|
"typescript-eslint": "^8.56.0",
|
|
38
39
|
"vitest": "^3.0.0"
|
package/src/action.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Data, Either, Match, Option, Schema, pipe } from "effect";
|
|
8
|
-
import type { Chips } from "./brand
|
|
9
|
-
import { Chips as makeChips, chipsToNumber, ChipsSchema } from "./brand
|
|
10
|
-
import { InvalidAction } from "./error
|
|
8
|
+
import type { Chips } from "./brand";
|
|
9
|
+
import { Chips as makeChips, chipsToNumber, ChipsSchema } from "./brand";
|
|
10
|
+
import { InvalidAction } from "./error";
|
|
11
11
|
|
|
12
12
|
// ---------------------------------------------------------------------------
|
|
13
13
|
// Action — Data.TaggedEnum (type-level) + Data.tagged (constructors)
|
package/src/betting.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Array as A, Either, HashSet, Match, Option, pipe } from "effect";
|
|
2
2
|
|
|
3
|
-
import type { Chips, SeatIndex } from "./brand
|
|
3
|
+
import type { Chips, SeatIndex } from "./brand";
|
|
4
4
|
import {
|
|
5
5
|
Chips as makeChips,
|
|
6
6
|
ZERO_CHIPS,
|
|
@@ -9,14 +9,14 @@ import {
|
|
|
9
9
|
chipsToNumber,
|
|
10
10
|
seatIndexToNumber,
|
|
11
11
|
SeatIndexOrder,
|
|
12
|
-
} from "./brand
|
|
13
|
-
import type { Player } from "./player
|
|
14
|
-
import { canAct, placeBet, fold as foldPlayer } from "./player
|
|
15
|
-
import type { Action, LegalActions } from "./action
|
|
16
|
-
import { computeLegalActions, validateAction } from "./action
|
|
17
|
-
import type { GameEvent } from "./event
|
|
18
|
-
import { PlayerActed, BettingRoundEnded } from "./event
|
|
19
|
-
import { InvalidAction, NotPlayersTurn } from "./error
|
|
12
|
+
} from "./brand";
|
|
13
|
+
import type { Player } from "./player";
|
|
14
|
+
import { canAct, placeBet, fold as foldPlayer } from "./player";
|
|
15
|
+
import type { Action, LegalActions } from "./action";
|
|
16
|
+
import { computeLegalActions, validateAction } from "./action";
|
|
17
|
+
import type { GameEvent } from "./event";
|
|
18
|
+
import { PlayerActed, BettingRoundEnded } from "./event";
|
|
19
|
+
import { InvalidAction, NotPlayersTurn } from "./error";
|
|
20
20
|
|
|
21
21
|
// ---------------------------------------------------------------------------
|
|
22
22
|
// BettingRoundState
|
package/src/card.ts
CHANGED
package/src/deck.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Array as A, Chunk, Effect, Either, HashMap, Random } from "effect";
|
|
2
|
-
import type { Card } from "./card
|
|
3
|
-
import { ALL_CARDS } from "./card
|
|
4
|
-
import type { SeatIndex } from "./brand
|
|
5
|
-
import { DeckExhausted } from "./error
|
|
2
|
+
import type { Card } from "./card";
|
|
3
|
+
import { ALL_CARDS } from "./card";
|
|
4
|
+
import type { SeatIndex } from "./brand";
|
|
5
|
+
import { DeckExhausted } from "./error";
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
// Deck type
|
package/src/error.ts
CHANGED
package/src/evaluator.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Array as A, Either, Order, pipe } from "effect";
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import pokersolver from "pokersolver";
|
|
3
|
+
const { Hand: PokersolverHand } = pokersolver;
|
|
4
|
+
import type { Card } from "./card";
|
|
5
|
+
import { toPokersolverString } from "./card";
|
|
6
|
+
import { InvalidGameState } from "./error";
|
|
6
7
|
|
|
7
8
|
// ---------------------------------------------------------------------------
|
|
8
9
|
// HandRank — our public type that does NOT leak pokersolver internals
|
package/src/event.ts
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import { Data } from "effect";
|
|
12
|
-
import type { Chips, SeatIndex, HandId } from "./brand
|
|
13
|
-
import type { Card } from "./card
|
|
14
|
-
import type { Action } from "./action
|
|
12
|
+
import type { Chips, SeatIndex, HandId } from "./brand";
|
|
13
|
+
import type { Card } from "./card";
|
|
14
|
+
import type { Action } from "./action";
|
|
15
15
|
|
|
16
16
|
// ---------------------------------------------------------------------------
|
|
17
17
|
// GameEvent — Data.TaggedEnum (type-level) + Data.tagged (constructors)
|
package/src/hand.ts
CHANGED
|
@@ -6,21 +6,21 @@
|
|
|
6
6
|
|
|
7
7
|
import { Array as A, Effect, Either, HashMap, Option, pipe } from "effect";
|
|
8
8
|
|
|
9
|
-
import type { Chips, SeatIndex, HandId } from "./brand
|
|
9
|
+
import type { Chips, SeatIndex, HandId } from "./brand";
|
|
10
10
|
import {
|
|
11
11
|
ZERO_CHIPS,
|
|
12
12
|
minChips,
|
|
13
13
|
SeatIndexOrder,
|
|
14
|
-
} from "./brand
|
|
15
|
-
import type { Card } from "./card
|
|
16
|
-
import type { Deck } from "./deck
|
|
17
|
-
import { shuffled, dealHoleCards, dealFlop, dealOne } from "./deck
|
|
18
|
-
import type { HandRank } from "./evaluator
|
|
19
|
-
import { evaluateHoldem } from "./evaluator
|
|
20
|
-
import type { Player } from "./player
|
|
21
|
-
import { placeBet, winChips, collectBet, dealCards, canAct } from "./player
|
|
22
|
-
import type { Action, LegalActions } from "./action
|
|
23
|
-
import type { GameEvent } from "./event
|
|
14
|
+
} from "./brand";
|
|
15
|
+
import type { Card } from "./card";
|
|
16
|
+
import type { Deck } from "./deck";
|
|
17
|
+
import { shuffled, dealHoleCards, dealFlop, dealOne } from "./deck";
|
|
18
|
+
import type { HandRank } from "./evaluator";
|
|
19
|
+
import { evaluateHoldem } from "./evaluator";
|
|
20
|
+
import type { Player } from "./player";
|
|
21
|
+
import { placeBet, winChips, collectBet, dealCards, canAct } from "./player";
|
|
22
|
+
import type { Action, LegalActions } from "./action";
|
|
23
|
+
import type { GameEvent } from "./event";
|
|
24
24
|
import {
|
|
25
25
|
HandStarted,
|
|
26
26
|
BlindsPosted,
|
|
@@ -30,18 +30,18 @@ import {
|
|
|
30
30
|
ShowdownStarted,
|
|
31
31
|
PotAwarded,
|
|
32
32
|
HandEnded,
|
|
33
|
-
} from "./event
|
|
34
|
-
import type { PokerError } from "./error
|
|
35
|
-
import { InvalidGameState } from "./error
|
|
36
|
-
import type { Pot } from "./pot
|
|
37
|
-
import { collectBets, awardPots } from "./pot
|
|
38
|
-
import type { BettingRoundState } from "./betting
|
|
33
|
+
} from "./event";
|
|
34
|
+
import type { PokerError } from "./error";
|
|
35
|
+
import { InvalidGameState } from "./error";
|
|
36
|
+
import type { Pot } from "./pot";
|
|
37
|
+
import { collectBets, awardPots } from "./pot";
|
|
38
|
+
import type { BettingRoundState } from "./betting";
|
|
39
39
|
import {
|
|
40
40
|
createBettingRound,
|
|
41
41
|
applyAction as bettingApplyAction,
|
|
42
42
|
getLegalActions as bettingGetLegalActions,
|
|
43
43
|
activePlayer as bettingActivePlayer,
|
|
44
|
-
} from "./betting
|
|
44
|
+
} from "./betting";
|
|
45
45
|
|
|
46
46
|
// ---------------------------------------------------------------------------
|
|
47
47
|
// ForcedBets
|
package/src/index.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export * from "./brand
|
|
2
|
-
export * from "./card
|
|
3
|
-
export * from "./deck
|
|
4
|
-
export * from "./evaluator
|
|
5
|
-
export * from "./player
|
|
6
|
-
export * from "./action
|
|
7
|
-
export * from "./event
|
|
8
|
-
export * from "./error
|
|
9
|
-
export * from "./pot
|
|
1
|
+
export * from "./brand";
|
|
2
|
+
export * from "./card";
|
|
3
|
+
export * from "./deck";
|
|
4
|
+
export * from "./evaluator";
|
|
5
|
+
export * from "./player";
|
|
6
|
+
export * from "./action";
|
|
7
|
+
export * from "./event";
|
|
8
|
+
export * from "./error";
|
|
9
|
+
export * from "./pot";
|
|
10
10
|
|
|
11
11
|
// Re-export betting with namespace prefix to avoid conflicts with hand/table
|
|
12
12
|
export {
|
|
@@ -17,9 +17,9 @@ export {
|
|
|
17
17
|
activePlayer as bettingActivePlayer,
|
|
18
18
|
getPlayer as bettingGetPlayer,
|
|
19
19
|
updatePlayer as bettingUpdatePlayer,
|
|
20
|
-
} from "./betting
|
|
20
|
+
} from "./betting";
|
|
21
21
|
|
|
22
|
-
export * from "./hand
|
|
22
|
+
export * from "./hand";
|
|
23
23
|
|
|
24
24
|
// Re-export table with explicit names to avoid conflicts with hand module
|
|
25
25
|
export {
|
|
@@ -32,9 +32,9 @@ export {
|
|
|
32
32
|
act as tableAct,
|
|
33
33
|
getActivePlayer,
|
|
34
34
|
getTableLegalActions,
|
|
35
|
-
} from "./table
|
|
35
|
+
} from "./table";
|
|
36
36
|
|
|
37
|
-
export * from "./position
|
|
37
|
+
export * from "./position";
|
|
38
38
|
|
|
39
39
|
export {
|
|
40
40
|
type Strategy,
|
|
@@ -52,4 +52,4 @@ export {
|
|
|
52
52
|
stopWhenFewPlayers,
|
|
53
53
|
alwaysFold,
|
|
54
54
|
passiveStrategy,
|
|
55
|
-
} from "./loop
|
|
55
|
+
} from "./loop";
|
package/src/loop.ts
CHANGED
|
@@ -8,19 +8,19 @@
|
|
|
8
8
|
|
|
9
9
|
import { Duration, Effect, Either, HashMap, Option, Schema, pipe, identity } from "effect";
|
|
10
10
|
|
|
11
|
-
import type { Action } from "./action
|
|
12
|
-
import { Fold, Check, Call } from "./action
|
|
13
|
-
import type { GameEvent } from "./event
|
|
14
|
-
import type { PokerError } from "./error
|
|
15
|
-
import type { SeatIndex } from "./brand
|
|
16
|
-
import type { TableState } from "./table
|
|
11
|
+
import type { Action } from "./action";
|
|
12
|
+
import { Fold, Check, Call } from "./action";
|
|
13
|
+
import type { GameEvent } from "./event";
|
|
14
|
+
import type { PokerError } from "./error";
|
|
15
|
+
import type { SeatIndex } from "./brand";
|
|
16
|
+
import type { TableState } from "./table";
|
|
17
17
|
import {
|
|
18
18
|
startNextHand,
|
|
19
19
|
act as tableAct,
|
|
20
20
|
getActivePlayer,
|
|
21
|
-
} from "./table
|
|
22
|
-
import type { StrategyContext } from "./position
|
|
23
|
-
import { buildStrategyContext } from "./position
|
|
21
|
+
} from "./table";
|
|
22
|
+
import type { StrategyContext } from "./position";
|
|
23
|
+
import { buildStrategyContext } from "./position";
|
|
24
24
|
|
|
25
25
|
// ---------------------------------------------------------------------------
|
|
26
26
|
// Function types — plain TypeScript (Schema can't represent functions)
|
package/src/player.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Option } from "effect";
|
|
2
|
-
import type { Chips, SeatIndex } from "./brand
|
|
2
|
+
import type { Chips, SeatIndex } from "./brand";
|
|
3
3
|
import {
|
|
4
4
|
ZERO_CHIPS,
|
|
5
5
|
addChips,
|
|
6
6
|
subtractChips,
|
|
7
7
|
chipsToNumber,
|
|
8
|
-
} from "./brand
|
|
9
|
-
import type { Card } from "./card
|
|
8
|
+
} from "./brand";
|
|
9
|
+
import type { Card } from "./card";
|
|
10
10
|
|
|
11
11
|
// ---------------------------------------------------------------------------
|
|
12
12
|
// Player interface — immutable snapshot of a player's state within a hand
|
package/src/pokersolver.d.ts
CHANGED
package/src/position.ts
CHANGED
|
@@ -8,22 +8,22 @@
|
|
|
8
8
|
|
|
9
9
|
import { Option, Schema } from "effect";
|
|
10
10
|
|
|
11
|
-
import type { SeatIndex } from "./brand
|
|
11
|
+
import type { SeatIndex } from "./brand";
|
|
12
12
|
import {
|
|
13
13
|
Chips as makeChips,
|
|
14
14
|
SeatIndexSchema,
|
|
15
15
|
ChipsSchema,
|
|
16
16
|
chipsToNumber,
|
|
17
17
|
ZERO_CHIPS,
|
|
18
|
-
} from "./brand
|
|
19
|
-
import { CardSchema } from "./card
|
|
20
|
-
import { LegalActionsSchema } from "./action
|
|
21
|
-
import type { LegalActions } from "./action
|
|
22
|
-
import type { Player } from "./player
|
|
23
|
-
import type { HandState } from "./hand
|
|
24
|
-
import { getLegalActions as handGetLegalActions } from "./hand
|
|
25
|
-
import type { GameEvent } from "./event
|
|
26
|
-
import type { TableState } from "./table
|
|
18
|
+
} from "./brand";
|
|
19
|
+
import { CardSchema } from "./card";
|
|
20
|
+
import { LegalActionsSchema } from "./action";
|
|
21
|
+
import type { LegalActions } from "./action";
|
|
22
|
+
import type { Player } from "./player";
|
|
23
|
+
import type { HandState } from "./hand";
|
|
24
|
+
import { getLegalActions as handGetLegalActions } from "./hand";
|
|
25
|
+
import type { GameEvent } from "./event";
|
|
26
|
+
import type { TableState } from "./table";
|
|
27
27
|
|
|
28
28
|
// ---------------------------------------------------------------------------
|
|
29
29
|
// PositionalRole
|
package/src/pot.ts
CHANGED
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { Array as A, pipe } from "effect";
|
|
8
|
-
import type { Chips, SeatIndex } from "./brand
|
|
8
|
+
import type { Chips, SeatIndex } from "./brand";
|
|
9
9
|
import {
|
|
10
10
|
Chips as makeChips,
|
|
11
11
|
ZERO_CHIPS,
|
|
12
12
|
addChips,
|
|
13
13
|
chipsToNumber,
|
|
14
14
|
SeatIndexOrder,
|
|
15
|
-
} from "./brand
|
|
16
|
-
import type { HandRank } from "./evaluator
|
|
15
|
+
} from "./brand";
|
|
16
|
+
import type { HandRank } from "./evaluator";
|
|
17
17
|
|
|
18
18
|
// ---------------------------------------------------------------------------
|
|
19
19
|
// Pot type
|
package/src/table.ts
CHANGED
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
|
|
7
7
|
import { Array as A, Effect, Either, HashMap, Option, pipe } from "effect";
|
|
8
8
|
|
|
9
|
-
import type { Chips, SeatIndex } from "./brand
|
|
9
|
+
import type { Chips, SeatIndex } from "./brand";
|
|
10
10
|
import {
|
|
11
11
|
HandId as makeHandId,
|
|
12
12
|
chipsToNumber,
|
|
13
13
|
seatIndexToNumber,
|
|
14
14
|
SeatIndexOrder,
|
|
15
|
-
} from "./brand
|
|
16
|
-
import type { Player } from "./player
|
|
17
|
-
import { createPlayer, clearHand } from "./player
|
|
18
|
-
import type { Action, LegalActions } from "./action
|
|
19
|
-
import type { GameEvent } from "./event
|
|
20
|
-
import { PlayerSatDown, PlayerStoodUp } from "./event
|
|
15
|
+
} from "./brand";
|
|
16
|
+
import type { Player } from "./player";
|
|
17
|
+
import { createPlayer, clearHand } from "./player";
|
|
18
|
+
import type { Action, LegalActions } from "./action";
|
|
19
|
+
import type { GameEvent } from "./event";
|
|
20
|
+
import { PlayerSatDown, PlayerStoodUp } from "./event";
|
|
21
21
|
import {
|
|
22
22
|
SeatOccupied,
|
|
23
23
|
SeatEmpty,
|
|
@@ -26,10 +26,10 @@ import {
|
|
|
26
26
|
HandInProgress,
|
|
27
27
|
NoHandInProgress,
|
|
28
28
|
InvalidConfig,
|
|
29
|
-
} from "./error
|
|
30
|
-
import type { PokerError } from "./error
|
|
31
|
-
import type { ForcedBets, HandState } from "./hand
|
|
32
|
-
import * as hand from "./hand
|
|
29
|
+
} from "./error";
|
|
30
|
+
import type { PokerError } from "./error";
|
|
31
|
+
import type { ForcedBets, HandState } from "./hand";
|
|
32
|
+
import * as hand from "./hand";
|
|
33
33
|
|
|
34
34
|
// ---------------------------------------------------------------------------
|
|
35
35
|
// TableConfig
|
package/tsconfig.json
CHANGED