Implementing the Poker Game in Jess Vanmoerkerke Frederik Project APLAI.

Slides:



Advertisements
Similar presentations
Advanced Strategies for Craps and Poker Billy J. Duke Joel A. Johnson.
Advertisements

ECE 491 Final Project Multiplayer Card Game Author: Tian Ma Presentation 5/4/2004.
Virtual Host: John Morales Revised: September 21, 2011 Project 4: Multi-media Lesson.
Counting. Counting in Algorithms How many comparisons are needed to sort n numbers? How many steps to compute the GCD of two numbers ? How many steps.
Java Coding 8 David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. Object-Oriented Design Example - The.
© Glenn Rowe AC Lab 2 A simple card game (twenty- one)
Mock Objects. Unit-testing and TDD are challenging They require some effort to: – Write a test for a small functionality – Refactor production code and.
CS18000: Problem Solving and Object-Oriented Programming.
Stat 35b: Introduction to Probability with Applications to Poker Outline for the day: 1.Zelda, continued. 2.Difficult homework 3 problem. 3.WSOP 2013 hand.
Short Stack Strategy – How to play after the flop Strategy: No Limit.
Dealer Comm Hand Player makes Ante bet and optional Bonus bet. Five cards are dealt to each player from the shuffler. Five cards are dealt from the shuffler.
An application of the Probability Theory
12 Pontoon1May Pontoon program CE : Fundamental Programming Techniques.
Chapter 3 Collections. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 3-2 Chapter Objectives Define the concept and terminology related.
Building Memory… Notes from class on 4/4/07. The Game First understand what we are trying to build. Then, create a list of requirements/functionality.
Intro to Probability & Games
Spades Game Application with Video Conference Group 12 Anıl Yaman Emre Ergün Hüseyin Aktaş Pınar Tekir.
Java Coding 8 David Davenport Computer Eng. Dept., Bilkent University Ankara - Turkey. Object-Oriented Design Examples.
Introduction to Cognition and Gaming 9/22/02: Bluffing.
VOCABULARY  Deck or pack  Suit  Hearts  Clubs  Diamonds  Spades  Dealer  Shuffle  Pick up  Rank  Draw  Set  Joker  Jack 
John Neal and Kalli Smith. Each player has a master number that starts at 10. The goal of the game is to get your opponent’s master number to 0. The first.
1 TCSS 360, Spring 2005 Lecture Notes Design Phase and UML Class Diagrams Relevant Reading: UML Distilled, Third Edition M. Fowler.
1 The game of poker You are given 5 cards (this is 5-card stud poker) The goal is to obtain the best hand you can The possible poker hands are (in increasing.
Blackjack: Myths vs. Reality Group K Andrew KerrAndrew Phillips Sven SkoogWoj Wrona.
The Parameterized Poker Squares EAAI NSG Challenge
Poker UML and ADT design plan.
Introduction for Rotarians
Game Rules Rules define game objects and define allowable actions by the players.
MOM! Phineas and Ferb are … Aims:
JokerStars: Online Poker William Sanville CSE 4904 Milestone II.
Quark Card Game by Helio Takai (and dice game)
Outline for the day: 1.Discuss handout / get new handout. 2.Teams 3.Example projects 4.Expected value 5.Pot odds calculations 6.Hansen / Negreanu 7.P(4.
Polina Alex Eviatar Roey Andrea Erez.  For those that heard but don’t know exactly:  Scrabble is a word game for two and more players on a square board.
The Poker Game in Jadex by Group 1 Mohammed Musavi (Ashkan) Xavi Dolcet Enric Tejedor.
1 Knowledge Based Systems (CM0377) Lecture 10 (Last modified 19th March 2001)
Texas Hold’em Playing Styles Team 4 Matt Darryl Alex.
Author Ivan Dominic Baguio. ABOUT THE GAME Game Objective  The goal of each player in the game is to discard all cards in his hand before every other.
All In To put all the rest of your money into the pot.
Game Procedures Who does what, where, when, and how?
Random Numbers Random numbers are extremely useful: especially for games, and also for calculating experimental probabilities. Formula for generating random.
By: John Cook 11/06/2009 PTTE John Cook 3/4/2016.
Spin for Expressions Materials: – Plus/minus spinner – A number cube – Expression playing cards Pass out all the expression cards FACE DOWN. The dealer.
Stat 35b: Introduction to Probability with Applications to Poker Outline for the day: 1.Expected value. 2.Heads up with AA. 3.Heads up with Gus vs.
Intelligent systems Lecture 11 Tools for development of Expert Systems.
Probability and statistics - overview Introduction Basics of probability theory Events, probability, different types of probability Random variable, probability.
Texas Holdem A Poker Variant vs. Flop TurnRiver. How to Play Everyone is dealt 2 cards face down (Hole Cards) 5 Community Cards Best 5-Card Hand Wins.
Spring ‘10 Term Project Casino Game Overview
TCSS 305 (Stepp) OO Design with UML Class Diagrams
By: Jordan Simon Mike Norman Charles Slack
Intelligent Systems JESS constructs.
Sequential Placement Optimization Games: Poker Squares, Word Squares, and Take It Easy! Todd W. Neller Abstract: In this talk, we teach how to play “Poker.
Key Rule: Each Number has only one valid combination of Prime Factors.
Lecture on Design Phase and UML Class Diagrams
Tarneeb Game.
Chapter 7: Introduction to CLIPS
THE TEXAS HOLD’EM.
The Parameterized Poker Squares EAAI NSG Challenge
Probability of casino games
J. J. Divin Astrid Glende Jon McClain Lorenzo Moore
Truth tables: Ways to organize results of Boolean expressions.
بسم الله الرحمن الرحیم آموزش نرم افزار CLIPS
Truth tables: Ways to organize results of Boolean expressions.
Move in Two’s From the card Pass between two’s. T T
Jess Knowledge, Influence, Behavior
Term Project: Poker Game
Task 2 Implementation help
Stat 35b: Introduction to Probability with Applications to Poker
Agenda Warmup Lesson 1.9 (random #s, Boolean variables, etc)
HOW TO PLAY POKER.
Agenda Warmup Lesson 1.9 (random #s, Boolean variables, etc)
Presentation transcript:

Implementing the Poker Game in Jess Vanmoerkerke Frederik Project APLAI

Aim of the project Learn the rules of the Poker game Learn the rules of the Poker game Implement the rules of the game in Jess Implement the rules of the game in Jess Practical example of the theory Practical example of the theory Interaction between Java and Jess Interaction between Java and Jess Benefits of rule based systems Benefits of rule based systems

Structure of the program Java Applet for Graphical User Interface Java Applet for Graphical User Interface Jess for implementing the rules of the game Jess for implementing the rules of the game

Video Poker Single player game Single player game Try to get a Poker hand Try to get a Poker hand Poker hand: pair, double pair, three of a kind,... Poker hand: pair, double pair, three of a kind,... Task Jess: check if we have a Poker hand Task Jess: check if we have a Poker hand

deftemplates + deffacts (deftemplate card "The number, value and suit of the card" (slot number) (slot value) (slot suit)) (deftemplate result "Payout index" (slot index)) (deffacts indexnumber "Initiate the indexnumber" (result (index 0)))

Assert the card facts Deftemplate cardtemp = engine.findDeftemplate("card"); Fact card1 = new Fact(cardtemp); card1.setSlotValue("number",new Value(0,RU.INTEGER)); card1.setSlotValue("value",new Value(value[0],RU.INTEGER)); card1.setSlotValue("suit",new Value(suit[0],RU.INTEGER)); engine.assertFact(card1);

Example rule Check if we have a full house (pair and three of a kind) Check if we have a full house (pair and three of a kind) (defrule check-full-house (card (number ?n1) (value ?v1)) (card (number =(+ ?n1 1))(value ?v1)) (card (number ?n2&~?n1) (value ?v2&~?v1)) (card (number =(+ ?n2 1)) (value ?v2)) (card (number =(+ ?n2 2)) (value ?v2)) ?oldindex <- (result (index ?i&:(< ?i 8))) => (retract ?oldindex) (assert (result (index 8))))

Get the result fact Fact fact = new Fact(engine.findDeftemplate("result")); String factName=""; Iterator it = engine.listFacts(); while (it.hasNext()&&!factName.endsWith("result")) { fact = (Fact) it.next(); factName = fact.getName() ; } vindex = fact.getSlotValue("index"); index = vindex.intValue(engine.getGlobalContext()); score += index*bet;

Draw Poker Multiplayer game Multiplayer game Also trying to get a Poker hand Also trying to get a Poker hand Winner = best Poker hand Winner = best Poker hand Tasks Jess Tasks Jess What action the computer player should take What action the computer player should take Which cards to hold Which cards to hold Finding the winner Finding the winner Different modules: CARDS,ACTION,HOLD Different modules: CARDS,ACTION,HOLD

deftemplates en deffacts (deftemplate CARDS::card "The value and suit of the card" (slot number) (slot value) (slot suit)) (deftemplate HOLD::hold "number card to hold" (slot number)) (deftemplate HOLD::index "index to be sure that highest rank is holded" (slot number)) (deftemplate CARDS::dealer "show if dealer had has his turn" (slot state)) (deftemplate ACTION::action "action: Fold,Pass/Call,Bet/Raise" (slot text)) (deftemplate ACTION::index "index to know what action to take and height of the cards" (slot number) (slot height1) (slot height2)) (deffacts CARDS::indexnumber "Initiate the indexnumbers and a random number" (HOLD::index (number 0)) (ACTION::index (number 0) (height1 0) (height2 0)) (ACTION::rand (round (* 10 (/ (random) 65536)))))

Action of computer player Choice of action depends of the cards Choice of action depends of the cards Getting index from same rules as in Video Poker Getting index from same rules as in Video Poker Example rule Example rule (defrule ACTION::action-raise (CARDS::dealer (state "false")) (or (and (ACTION::index (number ?i&:(> ?i 3))) (ACTION::rand ?j&:(> ?j 1)) ) (and (ACTION::index (number ?i&:(> ?i 0)&:(< ?i 4))) (ACTION::rand ?j&:(> ?j 4)) ) ) => (assert (ACTION::action (text Bet/Raise))))

Hold cards for computer player Example rule when having four of a kind Example rule when having four of a kind (defrule HOLD::hold-four-of-a-kind (CARDS::card (number ?n) (value ?v)) (CARDS::card (number =(+ ?n 1)) (value ?v)) (CARDS::card (number =(+ ?n 2)) (value ?v)) (CARDS::card (number =(+ ?n 3)) (value ?v)) ?oldindex <- (HOLD::index (number ?i&:(< ?i 7))) => (retract ?oldindex) (assert (HOLD::index (number 7))) (assert (HOLD::hold (number ?n))) (assert (HOLD::hold (number (+ ?n 1)))) (assert (HOLD::hold (number (+ ?n 2)))) (assert (HOLD::hold (number (+ ?n 3)))))

Finding Winner Same rules as in Video Poker Same rules as in Video Poker Additional slots: Height1, Height2 Additional slots: Height1, Height2 Example rule for checking two pairs Example rule for checking two pairs (defrule CARDS::check-two-pair (CARDS::card (number ?n1) (value ?v1)) (CARDS::card (number =(+ ?n1 1)) (value ?v1)) (CARDS::card (number ?n2&~?n1) (value ?v2&~?v1)) (CARDS::card (number =(+ ?n2 1)) (value ?v2)) ?oldindex <- (ACTION::index (number ?i&:(< ?i 2))) => (retract ?oldindex) (assert (ACTION::index (number 2) (height1 ?v1) (height2 ?v2))))

Conclusion Very easy to implement rules in Jess Very easy to implement rules in Jess Better overview of rules than in a normal programming language like Java Better overview of rules than in a normal programming language like Java Easy communication between Java and Jess Easy communication between Java and Jess

Demo Video Poker Video Poker Draw Poker Draw Poker