Blackjack modelling with BPM

Ioanna Rivas
Urudata Software
Published in
13 min readNov 23, 2018

What is the relationship between Blackjack and BPM? If you think there is none, then you are mistaken and the following article might change your grey and dull view of what BPM Software can do for you.

Every time a Q-flow update is out, we gather around to discuss the new enhancements and play with them whenever possible. This spring we decided to play Blackjack for beers. The latest version of Qflow 4.2 is out and this is the spook: Q-flow.

IBIS HOTEL Montevideo

Little did I know that I was about to play no-cards, no croupier, no tipping, no parking 10 miles away Blackjack at the dawn of All Saints day at the IBIS hotel in Montevideo. The room was packed with IT Blackjack thirsty folks.

Splitted in 6 teams of 5 we collaborated and implemented a flow with the objective of playing Blackjack. We designed it using Q-flow software and developed some specific behaviour for it using C#.

All teams implemented the behaviour of their play in real time, so, when all design activities were done, teams waited for the dealer’s integrated app to send a Start Signal.

Our goal

We aim to have a BPMN diagram that will get us and conduct through the game. The dealer will show us how we and how our competition is doing. It will also let us know if we have won or lost. However, the BPMN diagram will tell us what we should be focusing on. See the complete diagram below.

This article will describe step by step how can we get a BPMN diagram as such for Blackjack, and eventually use it to model any rules or processes you wish to visualize.

Complete BPMN Diagram

BPM Software skills allowed us to demystify the dark Blackjack game. We broke down it’s rules into simple steps, streamlined the game in a flow diagram and distinguished the different tasks of each one of the game’s actors. By actors understand the digital game actors, meaning: teams or players, the dealer or croupier app and the bot that will do the difficult formula tasks. Going back to the mentioned tasks, they are the elements that have the magic to crumble down and rearrange complex rules into simple and understandable actions and events.

We will explain each task later.

What exactly should we be modelling?

Our challenge is to model Blackjack’s ground rules.

Blackjack’s objective is simple and yet complicated if you are not a genius in guessing or counting cards. A Blackjack game has several hands. On each hand, the player must add up the values of all cards and attempt to approach the 21 value from below as close as you can without going over. Each card has a point value, so, Aces may be counted with either 1 or 11 points, and tens and face cards always count with ten points each.

A “Blackjack” hand is the highest hand you can get and it consists of an ace and any 10 point card, it will outrank all other 21 point hands. Easy breeze right?.

If you are not familiar with Blackjack, we have simplified the rules for our implementation.

  • Each player sets a bet.
  • Each player will receive two cards on the first round.
  • Each player will add up the values of the two initial card´s value received, and, according to logic decisioning, the player decides to continue playing, or stands and holds.
  • If the player decides to stand, then, after all players have made their “move” or decisioning, the dealer will show it´s hands value. The dealer will stop at 17, any hand below the value of 17, the dealer must continue playing for another round.
  • If the player decides to continue, then, after all players have made their move the dealer will assign a another card to all continuing players, and once again, all players will add up the new value to the previous result and evaluate to stand or continue another round.
  • Winnings are defined as follows: winners receive double their bet, while Blackjack winners receive three times their bet. The rest of the players, lose their bets to the dealer.

In Q-flow, business processes are modelled through a Process Design or BPMN Diagrams . These are tools help us streamlining the game process contemplating any set of rules. Each “step” or “task” in the diagram will be clearly described as a different BPMN Task. Tasks are labeled with a meaningful name so as to indicate where are we positioned, and also show “who” is accountable for executing it. Distinguishing game actors is crucial to thoroughly understand processes.

Nomenclature Explained

Let’s start by aligning on the Q-flow icons so we can convey on the accountable task owners, whether it’s the bot, a player, a script or a service.

Start Event
Script Task
Service Task
Catch Signal Event
User Task
Formula Task
Async Service Tasks
Exclusive Gateway
User Notification Task
End Task

Demystifying Blackjack

It’s now time to drill down a little further. We have the tools to describe im what ways does each BPMN Task help to build up the BPMN diagram for the Blackjack game.

BPMNs Start and Catch Signal Events tell us when to do something according to information sent by the system bot. Exclusive Gateways Tasks will also facilitate our decisioning driving us into one or another path according to information portrayed on our screen.

Our game rules require the following Catch Signal Events and End Tasks:

  • Wait for Start Game Signal. It represents us actually waiting until we receive a signal from the bot indicating that we can place our bet.
  • No Money Left. We wish that our wallet was as big as the FED. Sorry it is not. If we do not go lucky and consistently loose hands, we will run out of money and our wallet will be empty. The bot will send a signal and indicate us there is no money left by changing colour of the event that represent that state.

Exclusive Gateways Tasks also can be used to drive the player to one or another path according to a result calculated by a Service or a Script Task. In our case, Gateways have been defined to determine whether we should ask for another card or to hold and wait for the hand’s overall result. They have been labeled as:

  • Over 21. If our hand adds up above 21, we have lost this hand and we are redirected to task: Wait for Result until all players complete this play. If it is not, then, it push us to the next task event of asking the user if it wants another card and test luck.
  • New Card? . We make a decision, however we need to tell Q-flow that we are making a decision because there are optional paths we take. The above task is a gateway only cannot work alone, it needs more information from the user. Might he want a another card?. Maybe not.

Moving forward, Q-flow Scripts Tasks and Service Tasks are the Diva players. Let me explain why. Each Service or Script task will be describing how the Blackjack rules will be manifested. They are very powerful functional and coding enabled pieces that will allow us to target pre-defined variables, parameters and storage structures that we will be using during the different hands. These special tasks allow us to customize and improve the specific behaviour we wish to execute repeatedly. By designing only once, we can retarget variables several times.

Some Service Tasks used for our Blackjack implementation include:

  • Set Flow Id. You need to tell Q-flow that it is you that it is playing. Imagine this Id like your identity or social security number. Some systems have it as an entity id. Same idea.
  • Register With The Dealer. Now, send this “this is me, I’m unique” information to the third party app that will serve as a dealer. Your Flow Id will represent you and only you.
  • Send Your Bet. Self explanatory and easy to understand. Send the value amount you want to set as a bet for this round. All you risk prone individuals show yourselves…
  • Add To My Cards. Tell Q-low that you want your new card to be added on to the list of your existing play cards.

Can you get a feel of our initial point of breaking down ground rules so as to completely own them?

Service Tasks at your service

The power of one of our two Divas can be described by the Task of Registering a User, we need to invoke the integration service with a signal and wait for the bot to ensure us the user is geared up and registered within the game.

Assuming that the dealer’s third party integration is in place, we customize the task by mapping our information with the dealers app. map data with the integration. In this case we will map the Type of Item:”Data”. The Data Items are the Flow Id and the Name of the player.

Note there are other Types of Items that Qflow allows you to match, other types include Roles, Domains, Integrations, Validations, and Custom Forms.

The customized service looks like this:

Now we are in and the flow will indicate that we must wait for all players to complete their registrations. Events are coloured differently to show you where you are positioned, what you have accomplished and what you should be expecting next.

Obviously Service or Script tasks cannot do the job alone and other magical enchantments are needed. There are other type events and notifications that need to be thrown in. For example, User Tasks and User Notification Tasks, they capture all manual input of the user and User Notification Tasks are self explanatory actully. Recall that Service Tasks might be additionally required to store the inputs of the user .

The User Tasks we defined are:

  • Place your bet. We manually entered the value amount of your bet.
  • Would you like a new card?. As explained above, -Qflow understands there are different paths to go with, so he asks your if you want a new card and continue to the next designed state or hold.

Divas need your applause

Gaming requires decisioning and therefore some interaction that would provide this feed. User Tasks allow this form of communication.

We need to create the environment for the user to place a bet. Taking out the money out of the wallet, placing it somewhere and telling the dealer “This Flow Id is betting this amount”. User Tasks will allow this customization. “My Wallet” and “My Team” variables that say this is me using this wallet. They have been designed on a previous state and will be used to calculate my remaining money in a later step.

The application data section will require us to manually enter the bet value, and so whatever we enter will be stored after we click on Bet.

Don’t feel like betting today?. Not your game then. “My bet” will be set as a mandatory field.

Action Buttons are important and engaging, they allow for the interaction between the user and the system. Team players will see to an Action Button on their interface labeled as “BET” . The button hides the function of betting itself, and sending the dollar amount to the corresponding task.

Maybe not before your eyes but this is what’s happening:

Other User Notification Tasks that we used include:

  • Ask for New Card notification. How will you be notified that you could continue playing this round if the value of the card list is below 21?. Q-flow will ask you on screen if you want a new card. The player is in control of the game all the time.
  • Notify the result. Maybe not with the glittering sparks you deserve, Q-flow will show your hands result on your screen indicating whether you have lost, won or obtained the Blackjack bet you long for.

Once we have placed our bets and we have added up the values of two or more cards, we are ready to receive the result. For that to happen we need an Async Service Step and a User Notification Step. Both are used to wait until all players have decided participated. The User Notification Task will be your winning news bellboy.

Back to the stellar actress, the Script Task.

In order to customize the behaviour of Blackjack to just how we want it we need to get our hands dirty and do so some coding. Script Tasks are the perfect example of how Q-flow offers us this possibility.

Adding up new cards values is the perfect dress for this special Diva.

  • Sum up Your Cards. Meaning, adding up the value of the new card to the value result of the existing list.

The following code is simple, it takes both cards assigned and identifies if there is an Ace within. Our script will add up the values assigned, and, if the sum is greater than ten, and we have an ace in our hands, then, we will we will have it with a 1 value. In the other hand, if our game sums up to a value lower than 10, then, we will have the ace with a 11 point value.

A Diva needs accessories

We need Formula Tasks to complement our Blackjack logic with basic operations.

We used this type of events to update the dollar amount of our wallet by subtracting our total betting capabilities minus our bet. The task has been labeled as Update your Wallet. This value is stored in a field we define in our code. Simple operations can be conveyed with Formula Tasks, while Script Tasks are used for more complex functionalities.

Remember when we mentioned that we needed to design variables once so we can reuse them over and over again only by setting them up?

Below we have an excellent example that conveys that thought:

Formula tasks are used for designing simple operations and logic. It absolutely necessary for example to update the dollar amount of our wallet once a hand is over. The operation can be done by using a subtraction operation only. The dollars of my wallet after one or several hands is the value of my wallet after one hand minus the bet of the current hand.

We demystified together the dark and controversial card game into a simple me and you hats and tails.Formula tasks are used for designing simple operations and logic. It absolutely necessary for example to update the dollar amount of our wallet once a hand is over. The operation can be done by using a subtraction operation only. The dollars of my wallet after one or several hands is the value of my wallet after one hand minus the bet of the current hand.

Conclusion

There is no overwhelming conclusion really. It wasn’t a tough thing to do, correct?

Look above at the beginning of this article to what we have contoured without considerable development effort. The achieved Q-flow BPMN Diagram allows all actors to understand when each action should take place and who should be executing it. All task types and accountable owners are represented with their representative icon.

Wrapping Up

The truth. I’ve heard of Blackjack in the past, I was nowhere near playing it and miles from understanding it. For comprehension purposes a diagram did the trick. Having my business rules listed and my flow diagram complete, allowed my thoughts to be conducted and my processes clearly described. These representations allowing me to be in the game and enjoy it even though I have never counted a card before.

For modelling purposes, knowing exactly what you want out of your business and how you want it to come across, are the only two elements you need start streamlining your business process using Q-flow.

Any seemingly complex business rule can be laid flat and rearranged by engaging all of its actors and elements. Your new model would be accentuating integrity, transparency and comprehensiveness across your business ecosystem.

Ready for a new challenge …. maybe Poker?

Email us at us@urudata.com for any comments or questions!

Our purpose in Urudata Software is making our customers more efficient through technology.

We develop BPM (Workflow) and Document Management solutions and implement these with our experienced team, which analyzes our customers’ business processes looking for efficiency gains and automation opportunities. These projects allow for the generation of cost efficiencies, improved quality and predictability, better customer experience and availability of data for analytics.

--

--

Ioanna Rivas
Urudata Software

1950labs copywriter and author. Be friendly and be ambitious. Ask me anything, I’d love to chat.