Event Sourcing Poker Reducers
- Stare: Closed
- Premiu: $470
- Intrări primite: 5
- Câștigător: CryptoChris
Sumarul concursului
Create software to reduce the state of a Poker game by events
The software to create will reduce/compute the state of a Texas Hold Em Game. Reducers are pure functions that specify how the application's state changes in response to events. Events are simply objects that have a required type and an optional payload.
REQUIREMENTS:
-Javascript/NodeJS (Typescript strongly preferred)
The architecture of the software is event based; in other words, the inputs will be events and the software should create snapshots of state (to a file) after each event is processed.
Feel free to redesign the input events and/or state to improve the system, the only requirement is that your software will have to process the events.
It is sufficient for your program to process the input events from a JSON file, and to output state snapshots to another file.
Here might be the initial state of the game:
export const INIT_DEALER: IDealerState = {
'communityCards': [],
'options': {
'smallBlind': 5,
'bigBlind': 10,
'gameType': GameType.NLH,
},
'seed': {
'buttonPosition': 0,
'players': null,
'playersWhoStartedTheGame': [],
'deck': []
},
'players': null,
'pot': 0,
'temporaryPot': 0,
'playersInPlay': [],
'bettingQueue': [],
'timeout': null,
'status': PokerRound.PREDEAL,
'winner': null,
'wagerToCall': 0,
'timeAddRequested': false,
'rabbitRequested': false,
'roundComplete': false,
'gameStarted': false,
'gameOver': false
};
These are the different event types that your software must respond to:
export enum DealerEvents {
LOAD_GAME = 'LOAD_GAME',
CHECK= 'CHECK',
CALL = 'CALL',
FOLD = 'FOLD',
BET = 'BET',
RAISE = 'RAISE',
ALL_IN = 'ALL_IN',
HUNT_RABBIT = 'HUNT_RABBIT',
ADD_TIME= 'ADD_TIME',
TIMEOUT= 'TIMEOUT',
ADVANCE_ROUND= 'ADVANCE_ROUND'
}
Here might be an example input JSON file with example events (remember you can redesign the events/state as you need):
type: 'REGISTERED', payload: {'options': {'gameType': 'NoLimitHoldEm',
'smallBlind': 5,
'bigBlind': 10}
, 'seed':{
'players': {
'123': initPlayer('123', 1000), // A player object with id ‘123’ and chip stack 1000
'abc': initPlayer('abc', 1000),
},
'playerIdsWhoStartedTheGame': ['abc', '123'],
'deck': ['As', 'Kh', 'Ah', 'Kd', 'Ad', '2d', '3d', '7c', '8c', ...], /*CardIds are strings that are made of 2 characters, the RANK (A = ace, K= king, J= king, T=10, 9 = 9…. , followed by a lowercase suit*/
'buttonPosition': 0
}}; // Load game with options and seeds
{ type: DealerEvents.CALL, payload: {playerId: '123'} }
{ type: DealerEvents.CHECK, payload: {playerId: 'abc'} }
{ type: DealerEvents.ADVANCE_ROUND, payload: {} }// To flop
{ type: DealerEvents.CHECK, payload: {playerId: '123'} }
{ type: DealerEvents.CHECK, payload: {playerId: 'abc'} }
{ type: DealerEvents.ADVANCE_ROUND, payload: {} }// To turn
{ type: DealerEvents.CHECK, payload: {playerId: '123'} }
{ type: DealerEvents.CHECK, payload: {playerId: 'abc'} }
{ type: DealerEvents.ADVANCE_ROUND, payload: {} }// To river
{ type: DealerEvents.CHECK, payload: {playerId: '123'} }
{ type: DealerEvents.CHECK, payload: {playerId: 'abc'} }
{ type: DealerEvents.ADVANCE_ROUND, payload: {} } // To showdown
Remember, after each event, record the snapshot of the current state to a json file. (So if there are 10 events, you should have 10 snapshots)
Aptitudinile recomandate
Feedback de la Angajator
“Exceeded expectations”
jordansuarez0, United States.
Cele mai bune intrări pentru acest concurs
-
CryptoChris United States
-
Raya Link Egypt
-
marlolo Brazil
-
jubayedahmed Bangladesh
Panoul public de clarificare
Cum să începi concursurile
-
Postează-ți concursul Rapid și ușor
-
Obține o mulțime de intrări Din întreaga lume
-
Premiază cea mai bună intrare Descarcă ușor fișierele