Blackjack task in E-prime
Adele
adele.dimian at gmail.com
Tue May 11 16:15:02 UTC 2010
Hi all,
We have been working more on our code and made some progress. Now we
are having problems with the equation for adding the card values
together so that we can use it to determine when the dealer/computer
hits or stays. Any suggestions would be greatly appreciated!
'******************>
' CalcNewTotalVal
'******************>
Dim value As Integer
Dim total As Integer
Dim winnings as currency
Dim ValBC1 as Integer
ValBC1 = val(c.getattrib("ValBC1"))
Dim ValSC as Integer
ValSC = val(c.getattrib("ValSC"))
Dim ValHit1 as integer
ValHit1 = val(c.getattrib("ValHit1"))
Dim ValHit2 as integer
ValHit2 = val(c.getattrib("ValHit2"))
Dim ValDBC1 as Integer
ValDBC1 = val(c.getattrib("ValDBC1"))
Dim ValDSC as Integer
ValDSC = val(c.getattrib("ValDSC"))
Dim ValDHit1 as Integer
ValDHit1 = val(c.getattrib("ValDHit1"))
Dim ValDHit2 as Integer
ValDHit2 = val(c.getattrib("ValDHit2"))
debug.print "ValBC1" & c.getattrib ("ValBC1")
debug.print "ValSC" & c.getattrib ("ValSC")
debug.print "ValHit1" & c.getattrib ("ValHit1")
debug.print "ValHit2" & c.getattrib ("ValHit2")
debug.print "ValDBC1" & c.getattrib ("ValDBC1")
debug.print "ValDSC" & c.getattrib ("ValDSC")
debug.print "ValDHit1" & c.getattrib ("ValDHit1")
debug.print "ValDHit2" & c.getattrib ("ValDHit2")
playercardtotal = 0
dealercardtotal = 0
c.setattrib "playercardtotal", playercardtotal
c.setattrib "dealercardtotal", dealercardtotal
Playercardtotal = "ValBC1" + "ValSC" + "ValHit1" + "ValHit2"
<------------- This is where the code errors out, stating type
mismatch error
Dealercardtotal = "ValDBC1" + "ValDSC" + "ValDHit1" + "ValDHit2"
winnings = total - val(c.getattrib("borrowed"))
If PlayerCardTotal > 21 Or (PlayerCardTotal < DealerCardTotal And
DealerCardTotal < 22) then
MsgBox "You lose."
Elseif PlayerCardTotal < 21 Or (PlayerCardTotal > DealerCardTotal And
DealerCardTotal > 22) then
msgBox "You win."
End If
'******************<
' CalcNewTotalVal
'******************<
On May 4, 2:45 pm, Adele <adele.dim... at gmail.com> wrote:
> Hello all,
>
> We are currently trying to program a Blackjack task in e-prime and
> have been trying unsuccessfully for months now! The problem we are
> having has to do with how to calculate the value of each card so we
> can then calculate the total value of the dealer and participant's
> hands. We are trying to use an array to declare the value of the cards
> (bear with us this is our first time attempting to use an array). The
> cards are set up in a blocklist with card values. In theory we would
> like to draw from this list to declare the values, so that the values
> are consistent with the cards dealt.
>
> Once the card values are declared we then would like to use an
> equation to add the card values and compare the participant total card
> value to the dealer card value. We need the dealer card value to
> program when the dealer hits and stays.
>
> Please see below, can anyone point us in the right direction? We would
> appreciate it immensely! Thanks for your time and consideration.
>
> Kind regards,
> Adele and Brittany
>
> Please excuse our inexperience and disorganization, here are several
> different ways we were trying to get the card values:
>
> '******************>
> ' CalcNewTotalVal
> '******************>
> Dim value As Integer
> Dim total As Integer
> Dim CardCount As Integer
> Dim i As Integer
> Dim DealerCardCount As Integer
> Dim PlayerCardCount As Integer
> Dim Deck As clsDeck
> Dim hit as integer
> Dim stay as Integer
> Dim playercardtotal as integer
> Dim Dealercardtotal as integer
> Dim won as currency
> Dim lost as currency
> dim winnings as currency
>
> Dim arrValue (10) as integer
>
> For i = 0
> 'c.SetAttrib "Won", "Won"
> 'c.SetAttrib "Lost", "Lost"
> 'won = val(c.getattrib("Won"))
> 'lost = val(c.getattrib("Lost"))
> total = total + won - lost
> winnings = total - val(c.getattrib("borrowed"))
>
> 'c.SetAttrib "Hit", "Hit"
> 'c.SetAttrib "Stay", "Stay"
> 'Hit = val(c.getattrib("Hit"))
> 'Stay = val(c.getattrib("Stay"))
> 'c.getattrib("ValBC1")
> 'c.getattrib("ValSC")
> 'c.getattrib("ValHit1")
> 'c.getattrib("ValHit2")
> 'c.getattrib("ValDBC1")
> 'c.getattrib("ValDSC")
> 'c.getattrib("ValDHit1")
> 'c.getattrib("ValDHit2")
> Playercardtotal = "ValBC1" + "ValSC" + "ValHit1" + "ValHit2"
> Dealercardtotal = "ValDBC1" + "ValDSC" + "ValDHit1" + "ValDHit2"
> winnings = total - val(c.getattrib("borrowed"))
>
> If Playercardtotal > 21 Then
> MsgBox "You busted"
> goto EndlabelDealerif2
> End If
>
> 'For DealerTotal = GetCardTotal(Dealer)
> If DealerCardTotal > 21 Then
> MsgBox "Dealer busts"
> ElseIf DealerCardTotal > 15 Then
> MsgBox "Dealer stays"
> ' EndGame
> 'Else
> ' DealerCardCount = DealerCardCount + 1
> ' Deck.Deal 1, Dealer, _
> ' DealerCardCount * 80 + 20, 60, 0, FaceUp
> End If
>
> 'total = 0
> 'CardCount = Choice1.NumCardsInHand(plyer)
> 'For i = 0 To CardCount - 1
> ' value = Choice1.GetCardValue(plyer, i) Mod 13
> ' total = total + value + 1
>
> 'Dim msg As String
>
> 'Deck.ShowHandCard Dealer, 0, FaceUp
> 'DealerCardTotal = GetCardTotal(Dealer)
> 'PlayerCardTotal = GetCardTotal(Player)
> Set Choice1 = Nothing
>
> 'msg = "Dealer: " + CStr(DealerCardTotal) + _
> ' + "Player: " + CStr(PlayerCardTotal)
> If PlayerCardTotal > 21 Or (PlayerCardTotal < DealerCardTotal And
> DealerCardTotal < 22) then
> MsgBox "You lose."
> Elseif PlayerCardTotal < 21 Or (PlayerCardTotal > DealerCardTotal And
> DealerCardTotal > 22) then
> msgBox "You win."
> End If
>
> debug.print "won " & c.getattrib("won")
>
> --
> You received this message because you are subscribed to the Google Groups "E-Prime" group.
> To post to this group, send email to e-prime at googlegroups.com.
> To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/e-prime?hl=en.
--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.
More information about the Eprime
mailing list