Anyone familiar with the card game Spades?

chuckles1066

Banned
Joined
Dec 20, 2004
Messages
372
I'm writing one via VBA and have been working through an algorithm to calculate a hand's strength and, accordingly, ascertain a bid for that hand.

I've got my routine to deal cards to each player so now it's time to examine the cards and make a bid.

Spades brief tutorial for those not in the know:

For the purposes of this exercise, there are two teams of partners (i.e four players) each dealt 13 cards. Spades are trump cards but can only be led when you have no suit of the lead deal.

(So a play of Queen of Diamonds, Jack of Diamonds, Ace of Diamonds, 2 of Spades sees the 2 of Spades take the trick).

Maximum bid is obviously 13, minimum bid is 0.

How would you go about calculating the strength of a hand?

I am developing my own algorithm which is slowly getting there but I'd appreciate any guidance or thoughts from those wiser than I.

After all, once I've got this game up and running, I'll release it to all and sundry :-)
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
When I wrote card games in VBA, I would have a list of all the cards 2C, 3H, 5D, 7S etc with values next to them. With spades, you'll have to put an if statement on each card thrown to see "If(right(card,1)="S") to see if it's a spade. OR, I'd make all the spades values start at 100. So no matter what card is throw, if a Spade is thrown, it's value will always be higher.
 
Upvote 0
You might take the approach of evaluating each card on its trick taking potential 0% through 100% (Ace of spades for example). The diffuculty is that a queen might have a 100% value if it is a spade and you have both the Ace and King. Short suits promote the value of lower spades. Additionally if your partner bids before you and makes a relatively high bid, the value of some of the cards in your hand become greater. It sounds like a difficult task. Good luck.
 
Upvote 0
Thanks both......it's tricky due to (as West Man points out) what your partner bids.

He/she bids 6 and my algorithm says my hand is worth 5.........whoa, that's gonna need a rethink if the opponents have bid 4 between them.

The learning curve is there to be climbed I guess :-)
 
Upvote 0
Hi there, what you're trying to do is very difficult. I know because i've already completed this exact project (well almost, i have a little fine tuning to do before i release it). You can see my game progression tracker at www.elvgames.com/elvg . i don't normally share my code but i will paste a small script here for one player for the bidding portion only. maybe you can figure it out from there. The other two above are both right. you can see below how i did the bidding portion.

you can become a fan at www.facebook.com/elvg and you will know as soon as i'm finished. i will be offering free downloads from my site.

by the way, if you're stuck here, you have a long road ahead to teach the computer how to play against you. I scincerely wish you the best of luck and hope you don't develop as many gray hairs as me!



this code starts the bidding, only display for player one.

' DETERMINE BID FOR EACH PLAYER
'_________________________________________________________________________________
If Range("d6").Value = "LEAD" Then
GoTo 100
End If
If Range("p1").Value = "LEAD" Then
GoTo 200
End If
If Range("z6").Value = "LEAD" Then
GoTo 300
End If
If Range("p11").Value = "LEAD" Then
GoTo 400
End If
100
' determine bid for player 1
If playeronebid = 1 Then
GoTo 200
End If
playeronebid = 1
If Range("ac4").Value + Range("ad4").Value + Range("ae4").Value >= 13 Then
bid1 = "DNIL"
dn1 = 1
GoTo 200
End If
For bone2 = 1 To 13
If Right(Cells(bone2, 34), 1) = "4" And Cells(bone2, 34).Value < 100 Then
bid1 = bid1 + 1
End If
Next bone2
If bid1 > 0 Then
bid1 = bid1 - 1
End If
For bone1 = 1 To 13
If Right(Cells(bone1, 34), 1) = "4" And Cells(bone1, 34).Value >= 100 Then
bid1 = bid1 + 1
End If
Next bone1
For bone3 = 1 To 13
If Right(Cells(bone3, 34), 1) <> "4" And Cells(bone3, 34).Value >= 140 Then
bid1 = bid1 + 1
End If
Dim Kone1, Kone2, Kone3 For bone4 = 1 To 13
If Cells(bone4, 34).Value = 131 Then
Kone1 = 1
End If
If Cells(bone4, 34).Value = 132 Then
Kone2 = 1
End If
If Cells(bone4, 34).Value = 133 Then
Kone3 = 1
End If
Next bone4
For bone5 = 1 To 13
If Cells(bone5, 34).Value = 141 And Kone1 = 1 Then
bid1 = bid1 + 1
End If
If Cells(bone5, 34).Value = 142 And Kone2 = 1 Then
bid1 = bid1 + 1
End If
If Cells(bone5, 34).Value = 143 And Kone3 = 1 Then
bid1 = bid1 + 1
End If
Next bone5
Dim Qone1, Qone2, Qone3
For bone6 = 1 To 13
If Cells(bone6, 34).Value = 121 Then
Qone1 = 1
End If
If Cells(bone6, 34).Value = 122 Then
Qone2 = 1
End If
If Cells(bone6, 34).Value = 123 Then
Qone3 = 1
End If
Next bone6
For bone7 = 1 To 13
If (Cells(bone7, 34).Value = 141 Or Cells(bone7, 34).Value = 131) And Qone1 = 1 Then
bid1 = bid1 + 1
End If
If (Cells(bone7, 34).Value = 142 Or Cells(bone7, 34).Value = 132) And Qone2 = 1 Then
bid1 = bid1 + 1
End If
If (Cells(bone7, 34).Value = 143 Or Cells(bone7, 34).Value = 133) And Qone3 = 1 Then
bid1 = bid1 + 1
End If
Next bone7
If bid1 = 0 Then
bid1 = "NIL"
n1 = 1
End If
If playeronebid = 1 And playertwobid = 1 And playerthreebid = 1 And palyerfourbid = 1 Then
GoTo 500
End If
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,538
Messages
6,179,412
Members
452,912
Latest member
alicemil

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top