# TenAndHalf

Xianfeng Li
Ziqing Zhuang
December 3, 2014

## Overview

This project is a card game called Ten and A Half which a person can play against a computer.
All cards are counted as different points: face cards (kings, queens and jacks) are counted as 0.5 points. Ace is 1 point. All other cards are counted as the numeric value shown on the card. Two players compare the sum of all their cards to decide which one wins. Its rule is: 5-faces > 5-cards > 10.5 > below 10.5 > 0, in which 5-faces is that all five cards are faces (kings, queens and jacks), 5-cards is that the sum of five cards is not greater than 10.5, and at least one card in five cards is not a face. When the sum of all cards is greater than 10.5, the player will get zero point as a punishment.
If both players get 5-faces or 5-cards, the dealer (computer player here) wins. If both players get a same point (not greater than 10.5 and not zero), the player who has more cards wins, or the dealer wins if both have the same number of cards. If both players get zero point, it is a draw.

## Concepts Demonstrated

• Map, filter and accumulate are used very often to manipulate the card value list and the total point list.
• Let/lambda are used commonly for functional programming.
• Cond/if/when are used for checking the list total value or bust.
• Global variables and environment concepts are demonstrated.

## External Technology and Libraries

In this project, we used two racket libraries: GUI and Cards. GUI is used to show button and add event handling function. Cards library allows us to make casino table and visible card. Also, each card contains a value that we can used for list manipulation.

## Favorite Lines of Code

• Xianfeng Li:

This code inputs human card value list and computer card value list, and return 0(computer wins) or 1(computer lose) or 2(computer play hit).

```(define (compt_player compt_lst human_lst)
(cond ((= 0 (win_lose compt_lst human_lst)) 0)
((five_faces? human_lst) (if (all_faces? compt_lst) 2 1))
((<= (sum compt_lst) 10.5) 2)
(else 1)))

```
• Ziqing Zhuang:

This code input original card value and map it to value list. For a card J,Q, or K, one-card-value map it to 0.5. For others, it will keep original value.

```(define (point-list lst)
(map one-card-value lst))
(define (one-card-value c)
(let ([v (send c get-value)]) (if (> v 10) 0.5 v)))

```