Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: (URGENT) Plz help me with the black jack program.

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default (URGENT) Plz help me with the black jack program.

    Hi everyone. I am currently working on this problem.

    ================
    Machine learning and data mining has become a very important part of computer science as huge datasets are becoming more and more prevalent.

    This program is designed to help a computer “discover” the appropriate hit and stay percentages for blackjack. To implement this create an array of numbers that has indexes up to 21, and assign each location a starting value of .5. This indicates at the beginning that a computer would have a 50/50 chance of choosing to hit at that sum value of cards.

    Decide on a way to draw cards (many times you can use a previously constructed deck class) and after dealing two cards, have the computer decide to hit/stay based on the percentage that it has stored at the index for the card sum. If the action does not result in going over 21, then reinforces that percentage (by adding a small amount). If you go over 21 then you should decrease the possibility of that action in the future.
    After getting the program to work, run it for 100 trials and discuss the results, then run it for 200, 1000, 2000. Talk about how the increased number of trials give you better results, and what the computer “learned” from the trials.
    ============

     
    import java.util.ArrayList;
     
    public class SimpleDeck
    {
        private int numberOfDecks = 40;
        private ArrayList<Integer> deck = new ArrayList<Integer>(52*numberOfDecks);
     
        public SimpleDeck()
        {
            for (int i = 0; i < 52*numberOfDecks; i++)
            {  
                int value = (i+1) % 13;
                if ((value > 10) || (value == 0)) value = 10;
                deck.add(value);  //values for cards ACE=1, JACK=QUEEN=KING=10
            }   
        }
     
        public int getACard()
        {
            if (deck.size() == 0) return 0;  //if out of cards, return 0
            int choice = (int)(deck.size() * Math.random());
            int cardValue = deck.get(choice);  //get card value
            deck.remove(choice);  //remove chosen card from deck
            return cardValue;
        }
     
        public static void main()
        {
            int x;
            SimpleDeck d = new SimpleDeck();  //creates deck(s)
            do
            {
                x = d.getACard();             //pick a random card from deck(s)
                System.out.println(x);
            }
            while (x != 0);
        }
    }

    I have this base code. Can someone help me to solve the question?


    THanks !


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: (URGENT) Plz help me with the black jack program.

    What exactly is the problem? Posting an assignment plus a little code without a defined/distinct question doesn't help us much in helping you. Suggested reading: How To Ask Questions The Smart Way

  3. #3
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: (URGENT) Plz help me with the black jack program.

    And your problem is..... ?

Similar Threads

  1. Need a program using only for loop its urgent
    By pokuri in forum Object Oriented Programming
    Replies: 2
    Last Post: January 14th, 2011, 05:13 AM
  2. Black Jack Statistics game? lost.
    By mindlessn00b in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 20th, 2010, 07:20 AM
  3. urgent simple help for a very simple program
    By albukhari87 in forum Java Applets
    Replies: 4
    Last Post: June 5th, 2010, 03:43 PM
  4. Urgent Help Please :)
    By Jamie94 in forum Algorithms & Recursion
    Replies: 0
    Last Post: May 12th, 2010, 06:34 AM
  5. useing the comp's phone jack
    By wolfgar in forum Java Theory & Questions
    Replies: 10
    Last Post: November 7th, 2009, 03:57 PM