Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Blackjack
Old
OddOstrich
Junior Member
 
Status: Offline
Posts: 2
Join Date: May 2014
Default Blackjack - 05-11-2014, 08:41 PM

Ignore the blurry image, here's a link to the image: http://i.imgur.com/5hJuG7M.png

I am trying to make an interactive Blackjack game in Alice 3.

The top picture shows the code that is able to deal cards to the two players, however it cannot identify the value of each cards.

In the bottom picture, I try to fix this by putting each set of cards into different arrays, but can't find a way to put all the arrays into another array so I could just use that array to deal...

I also am having trouble understanding how the eventlisteners work. I added an event that states if H is pressed to run the procedure called "hitMe" which will deal a new card to the next thingMarker. However, the variables keep resetting every time H is pressed so the cards keep moving to the same thingMarker.

My questions:
Is there anyway to put an array of objects(Billboards) into an array of whole numbers?
How can I assign numerical values to objects?
Is there a way to assign global variables?
Attached Images
File Type: jpg blackjack.jpg (12.0 KB, 17 views)

Last edited by OddOstrich; 05-12-2014 at 02:30 PM.
   
Reply With Quote
Old
jrrTolkien
Senior Member
 
jrrTolkien's Avatar
 
Status: Offline
Posts: 166
Join Date: Feb 2014
Location: Middle-Earth (Merrimack, NH)
Default 05-12-2014, 09:37 AM

Could you please post your Alice world? It makes it much easier to fix it when you have the whole program. Also, what do you want fixed , exactly?
   
Reply With Quote
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default 05-12-2014, 02:10 PM

Quote:
Originally Posted by OddOstrich View Post
Ignore the blurry image, here's a link to the image: http://i.imgur.com/5hJuG7M.png

The top picture shows the code that is able to deal cards to the two players, however it cannot identify the value of each cards.

In the bottom picture, I try to fix this by putting each set of cards into different arrays, but can't find a way to put all the arrays into another array so I could just use that array to deal...

Been trying to figure this out for the better part of a weekend. Any help is appreciated.
The easiest way to do this is to just use numbers 0 - 51 and then define you suites as being Hearts 0-12, Clubs 13-25, Diamonds 26-38 and Spades as 39-51. So your sorted deck starts out as value = index. This lets you just work with the numbers 0 to 51 for most of the program while being able to convert the number to the card name string when needed.
To do that I would use an array of strings and use the cards value as an index. So if you had the card 23 you could get the string in your name array at index 23 and it would (hopefully) be the Jack of Clubs. To determine what suite a card is you can just divide by 13 and take the integer part of the result, 0 for hearts, 1 for clubs ...

Hope this helps
Mark


Mark Henwood
mhenwood@ieee.org
   
Reply With Quote
Old
OddOstrich
Junior Member
 
Status: Offline
Posts: 2
Join Date: May 2014
Default 05-12-2014, 02:23 PM

Quote:
Originally Posted by jrrTolkien View Post
Could you please post your Alice world? It makes it much easier to fix it when you have the whole program. Also, what do you want fixed , exactly?
Using my library's computer to post here, I'll post the image of my world when I get home. But really it's just a table with a deck of cards and thingMarkers where the cards will be dealt to for each player.

I have been thinking more and more about my problem, and everything could be solved if I knew how to assign values to objects. In this case, how do I, for example, assign the value 2 to all the twos(clubs, diamonds, hearts, spades) in the deck and so on for all the other cards.

Quote:
Originally Posted by chickentree View Post
The easiest way to do this is to just use numbers 0 - 51 and then define you suites as being Hearts 0-12, Clubs 13-25, Diamonds 26-38 and Spades as 39-51. So your sorted deck starts out as value = index. This lets you just work with the numbers 0 to 51 for most of the program while being able to convert the number to the card name string when needed.
To do that I would use an array of strings and use the cards value as an index. So if you had the card 23 you could get the string in your name array at index 23 and it would (hopefully) be the Jack of Clubs. To determine what suite a card is you can just divide by 13 and take the integer part of the result, 0 for hearts, 1 for clubs ...

Hope this helps
Mark
I am sorry, I should have elaborated on what I was trying to do. I am making an interactive game of Blackjack in Alice 3. So I need to find a way for the computer to identify the value of each card. In Blackjack, card suites are irrelevant. Thank you for answering anyway, it's something helpful to know if I decide to remake Spades.
   
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.