;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; functions available to the players that access the ; public/hand-information structure. ; ; Copyright (c) 2000 Wesley H. Huang. All rights reserved. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (newline) (display "Information functions for poker players: Version 1.1\n") (display "Copyright (c) 2000 Wesley H. Huang. All rights reserved.\n") ; (last-bet player-name) ; ; returns the type of bet the last player made (pass, call, raise) ; (define (last-bet player-name) (let ((bh (assoc player-name (puhi/betting-history public/hand-information)))) (if (null? bh) '() (second bh)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; (last-raise . player-name) ; ; Finds the last raise made by the given player and returns the amount ; of the raise. If the player-name is not specified, then it simply ; finds the last raise. If there is no such raise, then this function ; returns 0. ; ; This function calls a helper function which searches through a ; betting history list. It is given a function to see whether the ; player that made the bet is the player we're looking for. If a ; player name is not given, the function passed to the helper is ; simply a function that always returns true. The function returns 0 ; if it comes to the end of the list without finding a raise made by ; the right player. ; (define (last-raise . player-name) (define (find-last-raise history right-player?) (if (null? history) 0 (if (and (equal? (second (car history)) 'raise) (right-player? (first (car history)))) (third (car history)) (find-last-raise (cdr history) right-player?)))) (find-last-raise (puhi/betting-history public/hand-information) (if (null? player-name) (lambda (x) #t) (lambda (x) (equal? x (car player-name)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; Returns the number of clams a given player has. ; (define (clams player-name) (if (not (member player-name all/seated-players)) (error "Unknown player-name given to function clams" player-name)) (apply + (map (lambda (name num-clams) (if (equal? name player-name) num-clams 0)) all/seated-players current-clams)))