# < - fuck you wordpress, give you a <- sign to break! you son of a bitch.
rank <- c(11,10,5,2,
1,11,9,
1,
1,11,10,7,4) # 1 for Ace, 11 for J, 12 for Q, 13 for K
suit <- c(1,1,1,1,2,2,2,3,4,4,4,4,4) # 1S2H3D4C 
p.rank <- rank
p.rank[p.rank==1] <- 14
hand <- data.frame(p.rank,suit)
hcp.score <- sum(hand$p.rank[hand$p.rank > 10|hand$p.rank == 14]-10) # selection of HCP card
hcp.score #should be 15
as.data.frame(table(hand$suit))

照計可以寫到教你怎樣 bid 。我覺得應該 bid 1 Club 。

26 Feb 2010 Update:

更新更新。其實橋牌好適合統計學人去玩,你看可一手牌可以用統計軟件分析就知道好玩。更新少少,轉用另一個 Format 輸入一手牌,有點像人家的 DNA Sequence analysis 。 ((有利於日後將這些東西轉成 Function ))

# < - Chew that, bitch!
hand.code <- "SQSTS9S3HJDQDTD9CACJCTC9C8"
hand.code.break <- strsplit(hand.code,NULL)[[1]]
ranks <- c()
suits <- c()
for (i in c(1,3,5,7,9,11,13,15,17,19,21,23,25)) {
   suits[length(suits)+1] <- hand.code.break[i]
   ranks[length(ranks)+1]<- hand.code.break[i+1]
   }
p.ranks <- ranks
p.ranks[p.ranks=="A"] <- "14"
p.ranks[p.ranks=="K"] <- "13"
p.ranks[p.ranks=="Q"] <- "12"
p.ranks[p.ranks=="J"] <- "11"
p.ranks[p.ranks=="T"] <- "10" 
ranks <- as.numeric(p.ranks)
hand <- data.frame(ranks,suits)
rm(p.ranks)
rm(ranks)
rm(suits)
rm(hand.code.break)
hcp.score <- sum(hand$ranks[hand$ranks > 10]-10) # selection of HCP card
hcp.score #should be 10
suits.table < - as.data.frame(table(hand$suits)) 

suits.table 可以用 any() 看看有沒有 Singleton

# < - suck this!
any(suits.table$Freq ==1) # True
suits.table$Var1[suits.table$Freq ==1] # H