Highlights
In these exercises, we will build a ProbLog model that encodes a game of Poker. We will do this step by step, by first constructing a Bayesian network. Next, we will use Prolog to encode the logic of poker hands. In part 2 that willl follow later (after handing your solutions to assignment 1), we will combine both into a ProbLog model that can perform complex inference on this probabilistic logic program
1. Bayesian networks
You are player 1 in a two player card game. You and your opponent each draw a card from your personal infinite stack of cards that contain an equal number of jacks (J), queens (Q), kings (K), and aces (A). The person who draws the highest card wins. If there is a tie, a coin gets flipped. If the coin comes up heads, player 1 (you) win. If it comes up tails, the opponent wins. You are playing fair, but you suspect there is a 1/5 chance that your opponent is cheating. A cheating opponent has replaced all the jack cards with ace cards. A cheating opponent also replaces the coin with a coin that always comes up tails.
2. Prolog
Note that in the Bayesian network example, the Highest and Winner variables actually encode a deterministic reasoning step. We will now encode a more complex version of this problem. Instead of only one card, the players now have multiple cards. Additionally, instead of only reasoning about the high cards, we also reason about: one pair, two pair, three of a kind and straight as defined here: https://en.wikipedia.org/wiki/List of poker hands. Note that the rank of the card is important when comparing two hands of the same type, i.e. a pair of queens is better than a pair of jacks. Part of the code is given in exercise2.pl. Complete the code by implementing the following predicates:
3. ProbLog
Adapt and combine the Bayesian neural network from Exercise 1 and the Prolog program from Exercise 2 to encode the game where each player now draws 4 cards from their own stack. Use the game outcome/3 predicate to determine who has the best hand. In the case of a tie, the coin is used to determine the winner. The chance that the opponent is a cheater, and its impact on the game remains the same. The code from Exercise 1 will need to be slightly adapted. Complete the following program (exercise3.pl):
This IT Computer Science has been solved by our PhD Experts at My Uni Paper.
© Copyright 2026 My Uni Papers – Student Hustle Made Hassle Free. All rights reserved.