UVA CS 150 - Problem Set 2 - Procedurally Predicting Poker Probabilities

Unformatted text preview:

Collaboration Policy - Read Carefully For this problem set, you are required to work with an assigned partner. You will receive an email before Wednesday's class containing the partner assignments. Before starting to work with your partner, you should go through questions 1 and 2 yourself on paper. When you meet with your partner, check if you made the same predicitions. If there are any discrepancies, try to decide which is correct before using DrScheme to evaluate the expressions. You and your partner should work together on the rest of the assignment and turn in a single staped document containing both your answers to the questions 1 and 2, and one answer to the rest of the questions with both of your names on it. You should read the whole problem set yourself and think about the questions before beginning to work on them with your partner. In addition to your partner, you may discuss this assignment with other students in the class and ask and provide help in useful ways. You may consult any outside resources you wish including books, papers, web sites and people except for materials from previous cs150 courses. If you use resources other than the class materials, indicate what you used along with your answer. You are strongly encouraged to take advantage of the lab hours posted on the cs150 website. Purpose  Practice programming with procedures.  Become familiar with cons cells and how they can be used to manage complex data.  Understand recursive procedures.  Create the beginnings of a poker bot that might win the 2007 World Poker Robot Championships These robots are much better than the average player ... It would for sure make money online. Phil Laak, Los Angeles Times, July 18, 2005. In this problem set, you will develop procedures that can calculate odds for poker. Actually creating a poker bot involves making decisions based on incomplete information about what the other players have and how they behave. This is much harder than just calculating odds, but knowing the odds is important for any poker strategy. In the game we will consider, Texas Hold 'Em (this is the poker variant that is used in most major tournaments) each player is dealt two hole cards. These are kept hidden from the other players and can only be used by the player who was dealt them. Then, five community cards are dealt. Every player may use these cards. There are betting rounds after the hold cards are dealt, and after the third, fourth, and final community cards. At the end of the hand, each player makes their best five-card hand using as many of their own hole cards as they want and the remaining cards from the community cards. So, a player may make a hand using just the five community cards (and none of their hole cards), either of their hole cards and any four of the community cards, or both of their hold cards and any three of the community cards. To calculate the odds a player will win a hand, we need to know all possible hands that player could get and how many of them beat the other player's hand. For example, when there is one community card left to be dealt, that means we need to consider how many of the remaining cards in the deck will allow the player to make a hand that is better than the other players hand. University of Virginia, Department of Computer Science cs150: Computer Science — Spring 2007 Problem Set 2: Procedurally Predicting Poker ProbabilitiesDue: Friday, 2 February Beginning of classPage 1 of 9CS150: Problem Set 2: Procedural Poker1/22/2007Reading: Chapters 4 and 5 of the course book. Becoming Pros at Cons It never hurts for potential opponents to think you're more than a little stupid and can hardly count all the money in your hip pocket, much less hold on to it. Amarillo Slim The simplest compound data structure is a pair: a way of grouping two things into one. In Scheme, we can make pairs using cons cells. A cons cell has two elements. For silly historical reasons, these are known as the car and cdr: cons cell The elements in a cons pair can be anything, even another cons pair. By using cons pairs inside cons pairs inside cons pairs we can build up complex data structures to represent any data we want. Nullifying Null A list is either the special value null (which represents the empty list), or a pair whose second element is a list. Scheme provides many useful procedures for manipulating lists. The ones we use in this assignment include:  (list Expression*) — evaluates to a list containing the values of all the operand expressions. Evaluating (list 1 2 3) is equivalent to (cons 1 (cons 2 (cons 3 (cons 4 null)))).  (null? Expression) — evaluates to #t if and only if the operand evaluates to null  (list? Expression) — evaluates to #t if and only if the operand evaluates to a list.  (length Expression) — evaluates to the number of elements in the value the operand evaluates to. Produces an error if the operand does not evaluate to a list. Note that null is a list of length 0.  (append Expression1 Expression2) — evaluates to a list containing the elements of the list Expression1 evaluates to followed by the elements of the list Expression2 evaluates to. Produces an error if either operand does not evaluate to a list.  (map Expression1 Expression2) — evaluates to a list that contains elements that result from applying the procedure Expression1 evalutes to, to each elements in the list Expression2 evaluates to. Produces an error if Expression1 does not evaluate to a procedure or Expression2 does not evaluate to a list.  (sort Expression1 Expression2) — evaluates to a list that contains the elements that the list car element cdr elementQuestion 1: For this question you should not use the Scheme interpreter. For each fragment below, either: 1. Explain why the fragment is not a valid Scheme expression; or, 2. Predict what value the expression will evaluate to. If the expression evaluates to a compound data structure, draw a box-and-pointer picture showing the structure (for example, see Figure 2.3 in SICP). a. (cons 100 50) b. (cons (cons 1 2) 3) c. (cons 1 (cons 2 3)) d. (car (cons (cons 1 2) null)) e. (cdr (car (cons (cons 1 2) null))) f. (car (cdr (cons (cons 1 2) null))) Page 2 of 9CS150: Problem Set 2: Procedural Poker1/22/2007Expression1 evaluates to, but reordered according to the comparison procedure Expression2 evaluates to. For sort to make sense, Expression2 must evaluate to a transitive


View Full Document

UVA CS 150 - Problem Set 2 - Procedurally Predicting Poker Probabilities

Documents in this Course
Objects

Objects

6 pages

Load more
Download Problem Set 2 - Procedurally Predicting Poker Probabilities
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Problem Set 2 - Procedurally Predicting Poker Probabilities and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Problem Set 2 - Procedurally Predicting Poker Probabilities 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?