1. Attempting to subscript an atom

I am curently woking on a Black Jack game as some of you know. Thanks for
all who have helped me in my endevor. I have come across a new problem.
As per the subject line. I am getting an error of "Attempting to subscript
an atom". :(
-- code with the problem
integer pick
 atom dcard1,dcard2,pcard1,pcard2

 pick = rand(52)
 dcard1 = Deck[pick]
 drawBitmap(BlackJack,dcard1,45,45)
 playhand = playhand + dcard1[2]--trying to subscript an at
Any ideas on this. My lack of knowlege on computer programing and syntax
in euphoria is holding me back. What I am trying to do overall is take
the value for the card that is selected with "pick" and keep up with
the dealers hand and the players hand in a integers playhand, dealhand.
It just don't work for me. Thanks for your time.


David Roach
roachd_76 at yahoo.com

new topic     » topic index » view message » categorize

2. Re: Attempting to subscript an atom

> ---------------------- Information from the mail
header -----------------------
> Sender:       Euphoria Programming for MS-DOS
<EUPHORIA at LISTSERV.MUOHIO.EDU>
> Poster:       David Roach <roachd_76 at YAHOO.COM>
> Subject:      Attempting to subscript an atom
> --------------------------------------------------------------------------
-----
    <SNIP>
> -- code with the problem
> integer pick
>  atom dcard1,dcard2,pcard1,pcard2
>
>  pick = rand(52)
>  dcard1 = Deck[pick]
>  drawBitmap(BlackJack,dcard1,45,45)
    <SNIP>
>
> David Roach
> roachd_76 at yahoo.com
>

    dcard2 is an atom (a number)
dcard2 = 45 -- or some other number.
You are attempting to index into the number as if it was a sequences.

sequence s
s = {12, 45}
dcard2 = s[2]  -- now dcard2 = 45
? dcard2[2] --this will fail because dcard2 is an atom, not a sequence
  -- of length 2 or greater.
  -- dcard2 only holds a singe value.




        Lucius L. Hilley III
        lhilley at cdc.net
+----------+--------------+--------------+
| Hollow   | ICQ: 9638898 | AIM: LLHIII  |
|  Horse   +--------------+--------------+
| Software | http://www.cdc.net/~lhilley |
+----------+-----------------------------+

new topic     » goto parent     » topic index » view message » categorize

3. Re: Attempting to subscript an atom

David,

It appears to me that the problem starts with the way you have filled in the
variable Deck. It should be a 'sequence of sequences', i.e. 52 elements,
each consisting of a bitmap as the first element and a value as the second.
You can check this by inserting 'print Deck[1]' or '? Deck[1]' after Deck
has been created.
I think Irv and/or David Cuny gave you examples how to fill the sequence
Deck.

Ad

----- Oorspronkelijk bericht -----
Van: David Roach <roachd_76 at YAHOO.COM>
Aan: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Verzonden: maandag 6 december 1999 4:39
Onderwerp: Attempting to subscript an atom


> I am curently woking on a Black Jack game as some of you know. Thanks for
> all who have helped me in my endevor. I have come across a new problem.
> As per the subject line. I am getting an error of "Attempting to subscript
> an atom". :(
> -- code with the problem
> integer pick
>  atom dcard1,dcard2,pcard1,pcard2
>
>  pick = rand(52)
>  dcard1 = Deck[pick]
>  drawBitmap(BlackJack,dcard1,45,45)
>  playhand = playhand + dcard1[2]--trying to subscript an at
> Any ideas on this. My lack of knowlege on computer programing and syntax
> in euphoria is holding me back. What I am trying to do overall is take
> the value for the card that is selected with "pick" and keep up with
> the dealers hand and the players hand in a integers playhand, dealhand.
> It just don't work for me. Thanks for your time.
>
>
> David Roach
> roachd_76 at yahoo.com

new topic     » goto parent     » topic index » view message » categorize

4. Re: Attempting to subscript an atom

On Mon, 6 Dec 1999 08:03:55 +0100, Ad Rienks <kwibus at ZONNET.NL> wrote:

>David,
I figured out what the problem was. I had Deck in a sequence of 52 cards
where Deck[1] was the handle to the bitmap for that card. Deck[2] was the
value of the card and Deck[3] was the alternate value for the aces.
when I pick a card at random instead of this:
pick = rand(52)
hBitmap = Deck[pick]
drawBitmap(BlackJack,hbitmap,x,y)

I needed this:
pick = rand(52)
hBitmap = Deck[pick][1]
drawBitmap(BlackJack,hBitmap,x,y)

That way it wasn't trying to pick the whole element of
{card's handle, value, altenate value} and it would just
pick the cards handle. The rest is just seting up the players hand
and dealers hand to see who wins. I new it was something silly. Thanks for
all your help. I should have this done pretty soon. Ahh! my first computer
program ever. What a feeling.

David Roach
roachd_76 at yahoo.com

>
>It appears to me that the problem starts with the way you have filled in
the
>variable Deck. It should be a 'sequence of sequences', i.e. 52 elements,
>each consisting of a bitmap as the first element and a value as the second.
>You can check this by inserting 'print Deck[1]' or '? Deck[1]' after Deck
>has been created.
>I think Irv and/or David Cuny gave you examples how to fill the sequence
>Deck.
>
>Ad
>
>----- Oorspronkelijk bericht -----
>Van: David Roach <roachd_76 at YAHOO.COM>
>Aan: <EUPHORIA at LISTSERV.MUOHIO.EDU>
>Verzonden: maandag 6 december 1999 4:39
>Onderwerp: Attempting to subscript an atom
>
>

new topic     » goto parent     » topic index » view message » categorize

5. Re: Attempting to subscript an atom

David Roach wrote:


>I needed this:
>pick = rand(52)
>hBitmap = Deck[pick][1]
>drawBitmap(BlackJack,hBitmap,x,y)
>

Actually, you can't use rand() in that manner and have a working
card program. Like most true random number generators, rand() is
allowed to repeat itself...even consecutively. In other words, 32 could
be generated twice in a row. There is another type of random number
generator that generates a random sequence without repetition. That
is a much more complex process and few mathematically random
sequences are unique in this manner and can be calculated directly
without some form of subsetting such as I used for my shuffle.

Somebody is likely to send you a nasty letter when your dealer shows
up with two aces of spades.

Everett L.(Rett) Williams
rett at gvtc.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu