Debugging the Main Frame

In one of the previous posts, error prevention was mentioned.

While running each sub function through thousands of test cases proves very effective with most of the classes, this procedure is quite problematic on the main frame.
On one hand there are simply too many possible states that would need testing (the few thousand states of each subfunction must be combined with those of all other subfunctions). A shear brute force evaluation (testing every combination) would need ages.
On the other hand, most state combinations must be discarded in advance (a player can not act after he folded… a player can not check after another raised… etc), otherwise the brute force protocol would show millions of caught exeptions that are irrelevant (and the real problems would dissapear below that enormous amount of junk).

So debugging the main frame needs other tactics: Continuous monitoring of critical values and double check results with different calculation algorithms.
See the following examples.

  • The bank system is monitoring how much money is located on each table (by regarding only what is withdrawn on buy-in and what is deposited when a player leaves a table). The dealer is monitoring the same amount (by regarding only the stack of each player and the pot). These two values are compared at each round (and must be identical).
  • When no game is active (all money is located at the bank, none at the tables), the sum of all bank accounts must be 0.
  • The statistics of each player (number of folds/calls/raises or wins/losses) must correspond in their sum to the number of played games (this is even calculated per round, taking in count that later rounds have lower numbers due to folds or early wins)

This is not a fail safe check as not all possible combinations are tested… but only the examples above can already detect most calculation errors handling the money andstatistical numbers… and as they are widely interconnected with the game engine, this gets checked, too. So the blind spots can be widely decreased by (1) adding monitoring programs wherever reasonable and (2) running as many games in simulation mode as possible.

As quality control is held very high at, every time an exception flag is shown, its debugging gets prioritized over whatever new functions are currently being developed.
Since the alpha phase started in march, the list on open issues from exception flags was a constant pain in the a…, sometimes new issues came up way faster than old ones got solved. But yesterday the last known exception on this list was cleared and a test run of 500.000 games (12 player table pot limit, 120.000 games per AI) got through without a single flag coming up.
This does not mean, we are finished (there are still many functions that need to be developed for the final version and every step can create new exceptions), but getting rid of this additional weight lifts the moral and frees much energy for the next steps.


P.D: Here the ranking of Gen-1 AIs after this new test run (to be compared to the 8 player table results last week): Janus (303k), Flora (289k), Hephaistos (258k), Merkur (238k), Tyche (228k), Hades (227k), Fortuna (224k), Hermes (220k), Vulcanos (210k), Pluto (189k), Saturn (180k), Kronos (174k), Selene (167k), Luna (153k), Minerva (125k), Juno (124k), Bellona (103k), Hera (101k), Athene (97k), Nike (95k), Victoria (76k) Ares (58k), Uranus (50k), Apollo (44k), Nemesis (36k), Zeus (15k), Somnus (7k), Mars (-4k), Morpheus (6k), Eos (-16k), Aurora (-26k), Always Fold Test AI (-30k), Jupiter (-52k), Pan (-53k), Faunus (-54k), Aphrodite (-144k), Venus (-145k), Sol (-186k), Helios (-200k), Poseidon (-227k), Neptun (-261k), Erinyen (-274k), Furiae (-289k), Eros (-337k), Cupido (-360k), Bacchus (-608k), Dionysos (-626k)

AI Generation 1

The Poker Trainer will have oponents, whose artificial intelligence is grouped in “generations” (defining their skills and difficulty levels). This allows beginning players to succeed in entry levels but encounter gradually increased difficulty in higher levels until getting AIs in expert levels that are quite challenging even for professionals.

The first generation (Gen-1) is a very basic AI developed for tables where beginners can learn the game. Some AIs are too passive, some are too aggressive, some are too tight and some are too loose. They keep their static properties not only during a game but for a lifetime so the beginning player can learn their behaviour and develop optimized counter strategies (adaptive AIs will be introduced with Gen-2).

Gen-1 AIs are named after greek and roman gods and we tried to adjust their parameters (e.g. aggressive/passive or tight/loose) according to their characteristics: the godfathers Zeus/Jupiter are quite aggressive while the gods of wine Bacchus/Dionysos play like drunk (passive and loose).

Here the actual 46 Gen-1 AIs. They are ordered according to their performance in an extensive test run (they played around 30.000 games each) on an 8 player table pot limit hold’em (buy in 100, blinds 1/2).

  1. Flora (97360) – Roman Goddess of Flowers
  2. Tyche (88050) – Greek Goddess of Fortune (see 7.)
  3. Vulcanos (84640) – Roman God of Fire (see 5.)
  4. Janus (81110) – Roman God of Gates
  5. Hephaistos (81000) – Greek God of Fire (see 3.)
  6. Pluto (79660) – Roman God of the Underworld (see 10.)
  7. Fortuna (65940) – Roman Goddess of Fortune (see 2.)
  8. Hermes (64410) – Greek Messenger of the Gods (see 14.)
  9. Bellona (61880) – Roman Goddess of War
  10. Hades (53920) – Greek God of the Underworld (see 6.)
  11. Kronos (52260) – Greek God of Harvests (see 19.)
  12. Luna (46120) – Roman Goddess of Moon (see 13.)
  13. Selene (42180) – Greek Goddess of Moon (see 12.)
  14. Merkur (40570) – Roman Messenger of the Gods (see 8.)
  15. Ares (40120) – Greek God of War (see 18.)
  16. Nike (39190) – Greek Goddess of Victory (see 17.)
  17. Victoria (39070) – Roman Goddess of Victory (see 16.)
  18. Mars (36660) – Roman God of War (see 15.)
  19. Saturn (21630) – Roman God of Harvests (see 11.)
  20. Nemesis (18640) – Roman Goddess of Retribution
  21. Jupiter (12920) – Roman King of Gods (see 24.)
  22. Juno (10970) – Roman Goddess of Marriage (see 23.)
  23. Hera (10490) – Greek Goddess of Marriage (see 22.)
  24. Zeus (7680) – Greek King of Gods (see 21.)
  25. Apollo (6500) – Greek/Roman God of Music and Medicine
  26. Athene (5860) – Greek Goddess of Wisdom (see 27.)
  27. Minerva (5220) – Roman Goddess of Wisdom (see 26.)
  28. Morpheus (-6950) – Greek God of Dreams (see 31.)
  29. Always-Fold Test AI (-11050)
  30. Eos (-18780) – Greek Goddess of Dawn (see 33.)
  31. Somnus (-20470) – Roman God of Sleep (see 28.)
  32. Neptun (25170) – Roman God of the Sea (see 37.)
  33. Aurora (-26050) – Roman Goddess of Dawn (see 30.)
  34. Pan (-33580) – Greek God of Woods (see 35.)
  35. Faunus (-36670) – Roman God of Woods (see 34.)
  36. Uranus (-36910) – Greek/Roman God of the Sky
  37. Poseidon (-42240) – Greek God of the Sea (see 32.)
  38. Venus (-47320) – Roman Goddess of Love (see 40.)
  39. Furiae (-49990) – Roman Avenging Spirit (see 42.)
  40. Aphrodite (-60030) – Greek Goddess of Love (see 38.)
  41. Helios (-63260) – Greek Sun God (see 43.)
  42. Erinyen (-73150) – Greek Avenging Spirit (see 39.)
  43. Sol (-74640) – Roman Sun God (see 41.)
  44. Eros (-97160) – Greek God of Love (see 45.)
  45. Cupido (-92250) – Roman God of Love (see 44.)
  46. Dionysos (-15235) – Greek God of Wine (see 47.)
  47. Bacchus (-159430) – Roman God of Wine (see 46.)

Each AI exists twice for analysis on statistical variance. The pairs can be spotted by the different names of the same god (Zeus/Jupiter, Neptun/Poseidon, Aphrodite/Venus, Eros/Cupido).

Statistic Screen 2

While the ranking list was already implemented in the alpha build two weeks ago, the screen showing trend curve and action overview was not finished until this week.
This second screen will be hidden while a player is still playing the beginner tables and is enabled when he passes to intermediate level.

Trend Curve

The screen appears on selection of any player within the ranking list and gives a more detailed view of his actions and how he performed in the past.

Statistic Screen 1

I hoped to be able to present you all 3 statistic screens at once but developement slowed down as (1) we are currently facing major downtimes (free time is mainly used to watch the Euro Championship) and (2) debugging proved to be much harder than any previous code as the statistics have quite a few more interfaces to the existing classes than previous code.

To prevent long periods in between updates, I hereby present the already existing statistic screens.


The first screen is a simple ranking list (which exists for each game mode by separate) that shows you where you are compared to the artificial intelligences (and how each of them performes).
This screen will be available right after installing the game.

Dynamic User Interface is ready

Until now, the screen was adjusted to iPhone 6 only, making it impossible to play on devices with a lower screen resolution and leaving lots of unused space on bigger screens.
Now it adapts to each device… a 6 player table on iPhone 4 and 5, 8 players on iPhone 6/6+, up to 12 players on most iPad and even 16 players are possible on iPad Pro.


The spartanic screens may still look quite rough, but they serve the purpose  to test the game engine, where the main focus of this app lies (and I do not see much good in binding our resources in developing fancy graphics while there is still much work left on more important functions)

User Interface Overview

Note: for information about the content of the game engine screen, see this older post.

Welcome, Rex

The poker trainer app just got a mascot: Rex, the octopus.

Why an octopus?
After large sessions of brainstorming (with truckloads of good whisky), cephalopodes seemed to be unarguably the best choice for a poker bot.
– highly intelligent
– multiple long arms (perfect for dealing)
– unequaled in the domain of disguising and bluffing
– can be very aggressive
– in some cases will leave you dead on the floor (and certain death for fishes)

Why “Rex”?
As our head engineer is constantly travelling (10 month a year, up to 3 continents per month), a mascot of pocket size had to be found.
Unfortunately the final choice was a cute fellow with short arms, instantly reminding everyone of the “T-Rex” (a nickname for those coming late to poker sessions as they have to sit on the far outer rims of the table).



Preventing Programming Errors

One of the most time consuming tasks in the developement of our poker app is quality control…

– commenting every segment (to prevent misunderstandings on updates)
– long code review sessions
– equip each function with detailed data monitoring code (e.g. each interface)
– writing thousands of test cases
– test runs, test runs and more test runs

This is especially important for poker programs, as every bug in the AI will result in exploitable behaviour or other problems that spoil the fun of the game.
Numerous bugs in every single of the available offline-poker-apps (!) was the reason that started this project, so special care is taken not to make the same mistakes.

Quality Control

Entering Alpha-Phase

On this easter weekend we were finally able to release a first alpha version of the Poker Trainer App.
There is still much work to do, but at least we reached a point where third party tests are possible of what we archived in the last 22 month.

2014 Jun 10 – Start of theoretical analysis for this project
2014 Jul 14 – Start of function coding for analysis (VBA)
2014 Nov 11 – Start of function coding for poker trainer app (C++)
2015 Mar 08 – Start of intensive internal code review
2016 Mar 11 – End of code review, start test phase of game engine
2016 Mar 26 – Compile build of first alpha version

Sorry it took so long but the 1-year code review was necessary… every single function had to be sent through a test center where thousands of test-cases needed to be programmed… and every interface (between programs, classes and functions) had to be equiped with detailed data monitoring code and bug reporting systems…
Having to do this in your free time can take very very long and be very very boring.