简体   繁体   中英

Objective-C parser poker hand history

I'm building some software for iOS that needs to parse poker hand histories. Since I don't know a lot about parsing, I hoped someone could point me in the right direction, point me to some tutorial, ...

I've started to break up the poker hand in lines, and then I started to process each line with string function. But now I've seen that there are parsing tools available for which I can write a BNF-grammar. So this might be the right way to go if I want to achieve performance, right? However, I know nothing about BNF-grammars, and how to use them, ... Anyone who can point me to some tutorial for beginners?

Ow, a poker hand history looks something like this:

PokerStars Game #73611647630:  Hold'em No Limit ($0.01/$0.02 USD) - 2012/01/10 17:15:42 CET [2012/01/10 11:15:42 ET]
Table 'Joella VIII' 6-max Seat #1 is the button
Seat 1: S@pphiR ($0.85 in chips) 
Seat 2: Pet21 ($1.96 in chips) 
Seat 3: derphurp ($2.79 in chips) 
Seat 4: -M-A-R-K-qaz ($0.90 in chips) 
Seat 5: Rolle55 ($2.47 in chips) 
Seat 6: SanderDecler ($2 in chips) 
Pet21: posts small blind $0.01
derphurp: posts big blind $0.02
*** HOLE CARDS ***
Dealt to SanderDecler [Jc 2s]
-M-A-R-K-qaz: folds 
Rolle55: calls $0.02
SanderDecler: folds 
S@pphiR: folds 
Pet21: folds 
derphurp: checks 
*** FLOP *** [2h 3s As]
derphurp: checks 
Rolle55: checks 
*** TURN *** [2h 3s As] [Kh]
derphurp: bets $0.02
Rolle55: calls $0.02
*** RIVER *** [2h 3s As Kh] [5d]
derphurp: bets $0.02
Rolle55: raises $0.02 to $0.04
derphurp: raises $0.16 to $0.20
Rolle55: raises $0.16 to $0.36
derphurp: folds 
Uncalled bet ($0.16) returned to Rolle55
Rolle55 collected $0.47 from pot
*** SUMMARY ***
Total pot $0.49 | Rake $0.02 
Board [2h 3s As Kh 5d]
Seat 1: S@pphiR (button) folded before Flop (didn't bet)
Seat 2: Pet21 (small blind) folded before Flop
Seat 3: derphurp (big blind) folded on the River
Seat 4: -M-A-R-K-qaz folded before Flop (didn't bet)
Seat 5: Rolle55 collected ($0.47)
Seat 6: SanderDecler folded before Flop (didn't bet)

A BNF would be the ideal way to do this... however if you have limited time and don't want to learn too much, may I suggest a quick and dirty solution. Use regular expressions and do a switch based on which one matches.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM