Blackjack task in E-prime
David McFarlane
mcfarla9 at msu.edu
Tue May 11 17:02:09 UTC 2010
Adele,
Stock reminder: 1) I do not work for PST. 2) PST's trained staff
takes any and all questions at
http://support.pstnet.com/e%2Dprime/support/login.asp , and they
strive to respond to all requests in 24-48 hours (although latest
reports indicate more like 10 days) -- this is pretty much their
substitute for proper documentation, so make full use of it. 3) If
you do get an answer from PST Web Support, please extend the courtesy
of posting their reply back here for the sake of others.
That said, here is my take ...
According to your earlier code, you declared Playercardtotal (or
PlayerCardTotal, which reads better) as type Integer. Your troublesome line
Playercardtotal = "ValBC1" + "ValSC" + "ValHit1" + "ValHit2"
Constructs the string ""ValBC1ValSCValHit1ValHit2" and then tries to
assign that to the Integer variable Playercardtotal, which of course
makes no sense. You could check the result of "ValBC1" + "ValSC" +
"ValHit1" + "ValHit2" yourself just by doing
MsgBox "ValBC1" + "ValSC" + "ValHit1" + "ValHit2"
Perhaps you meant to do
Playercardtotal = ValBC1 + ValSC + ValHit1 + ValHit2
Remember, quotes enclose literal text values, whereas variable names
are never quoted (although, to confuse matters slightly, it may look
like you enclose variable names in quotes when they indicate items in
a Collection object (e.g., SlideState.Objects("subObjectName")), but
even here the name is strictly speaking a key value associated with
the Collection item).
Really, this is elementary programming stuff. Perhaps you and
colleagues need to take a time out and take an introduction to
computer programming class, just as I did long ago.
-- David McFarlane, Professional Faultfinder
"For a successful technology, reality must take precedence over
public relations, for nature cannot be fooled." (Richard Feynman,
Nobel prize-winning physicist)
>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 at http://groups.google.com/group/e-prime?hl=en.
More information about the Eprime
mailing list