Any obvious errors here?

// From JAVA PROGRAMMING: FROM THE BEGINNING, by K. N. King /
// Copyright (c) 2000 W. W. Norton & Company, Inc. //
import jpb.*;
import java.io.*;
import java.lang.Thread;
public class bjack{
     public static int playerCount=0;
public static int dealerCount=0;
public static int computerCount=0;
// public static int cCard1 = 0;
//public static int cCard2 = 0;
public static int newCard = 0;
int ep, pl;
BJStates bjstates;
     public bjack (BJStates parent, int episodes, int plays)
          bjstates = new BJStates(this, 1000, 100);
          //int ep, pl;
public static void main(String[] args) {
     int playerWins = 0;
     int dealerWins = 0;
     int computerWins = 0;
     SimpleIO.prompt("Learn or Play?");
String userInput1 = SimpleIO.readLine();
if (userInput1.equalsIgnoreCase("P"))
     while (true) {
     // Choose two cards for both player and dealer
Card playerCard1 = Card.pickRandom();
Card playerCard2 = Card.pickRandom();
Card dealerCard1 = Card.pickRandom();
Card dealerCard2 = Card.pickRandom();
Card computerCard1 = Card.pickRandom();
Card computerCard2 = Card.pickRandom();
Card nCard = Card.pickRandom();
// Display player's cards
System.out.println("Your cards: " + playerCard1 +
" " + playerCard2);
System.out.println("Computer cards: " + computerCard1 +
" " + computerCard2);
System.out.println("Dealer cards: " + dealerCard1 +
" " + dealerCard2);
// Compute initial counts for player and dealer and computer
int playerCount = getCount(playerCard1) +
getCount(playerCard2);
int dealerCount = getCount(dealerCard1) +
getCount(dealerCard2);
int computerCount = getCount(computerCard1)+
                         getCount(computerCard2);
//int cCard1 = getCount(computerCard1);
//int cCard2 = getCount(computerCard2);
int newCard = getCount(nCard);
// Check whether player's count is 21. If so, dealer
// must have 21 or lose automatically.
if (playerCount == 21) {
if (dealerCount != 21 && computerCount != 21)
dealerCount = 0;
computerCount = 0;
} else {
// Player's count was not 21. Ask player to draw
// additional cards and determine new value of
// player's hand.
playerCount = getPlayerCards(playerCard1,
playerCard2);
// Player loses if new count exceeds 21
if (playerCount > 21)
playerCount = 0;
else {
// Player's count does not exceed 21. Show dealer's
// cards.
//System.out.println("Dealer's cards: " +
// dealerCard1 + " " + dealerCard2);
// Draw additional cards for dealer and determine
// new value of dealer's hand
dealerCount = getDealerCards(dealerCard1,
dealerCard2);
// Dealer loses if new count exceeds 21
if (dealerCount > 21)
dealerCount = 0;
// Compare player's count with dealer's count to
// determine the winner; display the outcome and
// update the win counts
if (playerCount > dealerCount && playerCount > computerCount) {
System.out.println("You win!");
playerWins++;
} else if (playerCount < dealerCount && computerCount < dealerCount) {
System.out.println("Dealer wins");
dealerWins++;
} else if (playerCount < computerCount && dealerCount < computerCount){
     System.out.println("Computer wins");
computerWins++;
else
     System.out.println("Tie");
// Display the win counts
System.out.println("Dealer: " + dealerWins +
" Player: " + playerWins + " Computer:" + computerWins);
// See if user wants to play again; exit from loop if
// answer is no
SimpleIO.prompt("Play again (Y/N)? ");
String userInput = SimpleIO.readLine();
if (!userInput.equalsIgnoreCase("Y"))
     break;
System.out.println();
else if (userInput1.equalsIgnoreCase("L"))
     while(true)
          ///BJStates.
          /*Buffer sharedLocation = new UnsychronizedBuffer();
          bjothers Bjothers = new bjothers( sharedLocation );
          Bjothers.start();*/
          /*public void run()
          /*X whatever = new X();
          class X implements Runnable {
               X() {
Thread t = new Thread(this);
t.start();
public void run() {
//bjothers(); //some code that executes the functionality of the thread
     bjothers Bjothers = new bjothers();
     //     public void run() {
/// BJStates();
/*public void Work() {
while(true)
System.out.println("+|+");
               //parent.initbjothersVariables();
                    //BJStates.curEpisode = 0;
                    //B//JStates.curPlay = 0;
                    //running = true;
                    //thisThread.start();
                    //Q.setName("Current");
                    //BPlayers.player[0].setCurrentStrategy(Q);
                    //BPlayers.player[1].setCurrentStrategy(Q);
          bjstates = new BJStates(this, ep, pl);
          bjstates.setEpisodes(ep);
          bjstates.setPlays(pl);
          bjstates.start();
     //startLearning();
          SimpleIO.prompt("Stop ");
String userInput2 = SimpleIO.readLine();
if (userInput2.equalsIgnoreCase("S"))
     break;
// NAME: getDealerCards
// BEHAVIOR: Adds cards to the dealer's hand until the
// value reaches 17 or more
// PARAMETERS: card1 - One of dealer's original two cards
// card2 - The other original card
// RETURNS: Value of the dealer's hand, including
// original cards and new cards
private static int getDealerCards(Card card1, Card card2) {
int dealerCount = getCount(card1) + getCount(card2);
int aceCount = 0;
// Determine number of aces among original pair of cards
if (card1.getRank() == Card.ACE)
aceCount++;
if (card2.getRank() == Card.ACE)
aceCount++;
while (true) {
// If the dealer's count exceeds 21 and the hand
// contains aces still valued at 11, then reduce the
// number of aces by 1 and reduce the count by 10
if (aceCount > 0 && dealerCount > 21) {
aceCount--;
dealerCount -= 10;
// Return if dealer's count is at least 17
if (dealerCount >= 17)
return dealerCount;
// Pick a new card and update the dealer's count
Card newCard = Card.pickRandom();
System.out.println("Dealer drew: " + newCard);
dealerCount += getCount(newCard);
// Check whether the new card is an ace
if (newCard.getRank() == Card.ACE)
aceCount++;
// NAME: getPlayerCards
// BEHAVIOR: Adds cards to the player's hand until the
// value exceeds 21 or the player decides to
// stand
// PARAMETERS: card1 - One of player's original two cards
// card2 - The other original card
// RETURNS: Value of the player's hand, including
// original cards and new cards
private static int getPlayerCards(Card card1, Card card2) {
int playerCount = getCount(card1) + getCount(card2);
int aceCount = 0;
// Determine number of aces among original pair of cards
if (card1.getRank() == Card.ACE)
aceCount++;
if (card2.getRank() == Card.ACE)
aceCount++;
while (true) {
// If the player's count exceeds 21 and the hand
// contains aces still valued at 11, then reduce the
// number of aces by 1 and reduce the count by 10
if (aceCount > 0 && playerCount > 21) {
aceCount--;
playerCount -= 10;
// Return if player's count exceeds 21
if (playerCount > 21)
return playerCount;
// Ask user whether to stand or hit
SimpleIO.prompt("(S)tand or (H)it? ");
String userInput = SimpleIO.readLine();
if (!userInput.equalsIgnoreCase("H"))
return playerCount;
// Pick a new card and update the player's count
Card newCard = Card.pickRandom();
System.out.println("You drew: " + newCard);
playerCount += getCount(newCard);
// Check whether the new card is an ace
if (newCard.getRank() == Card.ACE)
aceCount++;
//Computer Cards
//public void run() {
     /*     int s;
          while (true) {
          try {
                    Thread.currentThread().sleep(10);
          } catch (Exception e)
                    System.out.println("Exception on sleep");
                    // Sarsa Strategy
                         s = bjothers.calcState(card);
               // select the best action associated with s
               curAction = strat[strategy].selectAction(s);
               //take choosed action
               switch(curAction) {
                         case BStrategy.HIT : {
                              addCard(Cards.next());
                         drawCards();
                         points = calcPoints();
                         if (points<=21) {
                                   setCanPlay(true);
                         else
                                   setCanPlay(false);
                         break;
                         case BStrategy.STAND : {
                         setCanPlay(false);
                         break;
                         default : {setCanPlay(false);}
// NAME: getCount
// BEHAVIOR: Returns the Blackjack value of a particular
// card
// PARAMETERS: c - a Card object
// RETURNS: The Blackjack value of the card c. The value
// of a card is the same as its rank, except
// that face cards have a value of 10 and aces
// have a value of 11.
private static int getCount(Card c) {
switch (c.getRank()) {
case Card.TWO: return 2;
case Card.THREE: return 3;
case Card.FOUR: return 4;
case Card.FIVE: return 5;
case Card.SIX: return 6;
case Card.SEVEN: return 7;
case Card.EIGHT: return 8;
case Card.NINE: return 9;
case Card.ACE: return 11;
default: return 10; // TEN, JACK, QUEEN, KING
public void startLearning(int ep, int pl) {
     bjstates = new BJStates(this, ep, pl);
     bjstates.setEpisodes(ep);
     bjstates.setPlays(pl);
     bjstates.start();
}

any obvious errors here?Yup:
No code tags
No indentation
Too long to read
All cluttered up

Similar Messages

  • Mail for Exchange no obvious error but no email

    I've got an E71 with MfE 2.5.5 and an Exchange 2003 SP2 server.
    I've configured MfE so that it can talk to the server: The "Search Company Directory" works ok, and I can send email (and the sent item gets synced into my Outlook sent folder). For now, it's not using SSL just simple http.
    But when I try to sync, I always get no email, and in the log there is "Added 0, Updated 0, Deleted 0, Discarded 0". I definitely have email (including some unread) on the server. I've disabled all sync items except email.
    I've searched the forum but no-one seems to have quite the same problem, as I don't get any errors in the logs. The "pdu_log.txt" contains a bunch of xml with nothing that looks like an error message, and the "admin_log1.txt" has entries like:
    16/07/2008 14:49:51 clearing device entries for initial sync
    16/07/2008 14:49:51 start Email sync
    16/07/2008 14:49:52 client->server adds=0 changes=0 deletes=0 fails=0
    16/07/2008 14:49:52 server->client adds=0 changes=0 deletes=0 fails=0
    6/07/2008 14:49:53 client->server adds=0 changes=0 deletes=0 fails=0
    16/07/2008 14:49:53 server->client adds=0 changes=0 deletes=0 fails=0
    16/07/2008 14:49:53 end Email sync
    So no obvious errors about "snapshot database" or "server error" that other people were having.
    Any ideas? TIA.

    I have exactly the same problem!!
    It's driving me nuts! Several e-mail and calendar items won't appear on the phone. MfE log tells me there were no changes:
    22/04/2007 01:15:49 start Calendar sync
    22/04/2007 01:15:51 client->server adds=0 changes=0 deletes=0 fails=0
    22/04/2007 01:15:51 server->client adds=0 changes=0 deletes=0 fails=0
    When I login through web access I see a lot of new e-mails in my Inbox and I created several new calendar items in Outlook but none of them appear on the phone.
    Already upgraded to latest firmware on Nokia E51 and Nokia E71 and tried several versions of MfE. Currently on 2.7.
    Does somebody have any clue on what's going on here?
    Message Edited by koosg on 02-Apr-2009 11:47 AM

  • Can anybody spot an obvious error?

    Hello
    I would appreciate any help with the following error message I am getting while trying to compile a file. The following shows up in DOS:
    C:\jdk1.3.1\bin>javac javaPost.java
    javaPost.java:129: cannot resolve symbol
    symbol : method newInputStreamReader (java.io.InputStream)
    location: class javaPost
    mailreplyreader = newBufferedReader(newInputStreamReader(mailsocket.getInputStream()));
    ^
    1 error
    Can anybody spot an obvious error?
    Thank you in anticipation.

    Hello Kleink
    Thanks for your message.
    It did the trick. In fact, I've now noticed that new always seems to be followed by a space:
    new JScrollPane
    new JPanel
    new JButton
    Thanks again!

  • This Document doesnot contain any Reports(:Error Inf)

    Hello All,
    I have a Web-I report which is working fine with BO XI R3 sp2.3.
    Later we migrated the report to sp3.3.
    Here the same report is giving the below error.
    "This Document doesnot contain any Reports(:Error Inf)"
    Please sugget me a solution along with the reason for this error
    Thanks.

    Try stopping all your SIA, then clearing out webi cache at following locations :
    C:\Program Files\Business Objects\BusinessObjects Enterprise 12.0\Data\<yourcmsname>\hostname.WebIntelligenceProcessingServer
    and
    C:\Program Files\Business Objects\BusinessObjects Enterprise 12.0\Data\<yourcmsname>\storage\docs
    C:\Program Files\Business Objects\BusinessObjects Enterprise 12.0\Data\<yourcmsname>\storage\universes
    then start SIA again and test.

  • HI i have strange errors here. Oracle 9i Installation

    HI i have strange errors here.
    "Thrown when IP Address of a host cannot be determined"
    I am using SUN 0S, version 5.9
    %uname -a
    SunOS -i 5.9 Generic_117171-14 sun4u sparc SUNW,Ultra-Enterprise
    %uname -r
    5.9
    %uname -n
    -i
    %hostname
    -i
    when i type "hostname" its returning "-i". quite strange.any one have any solution for this?

    HI,
    are you check below thread.
    Thrown when IP Address of a host cannot be determined
    regards
    Taj

  • Cant take pics any more, error message sez "CANNOT TAKE PHOTO"

    cant take pics any more, error message sez "CANNOT TAKE PHOTO there is not enogh available storage to take photo. You can manage your storage in Settings." but then I go there and cant do anyhting...?
    I believe I have backed up all photos to my computor and I even just now bought more icloud storage for $20.00 a year and still nothing....?
    I cant find a way to delete camera roll....?

    Guess what? The folks responding to you here are all just users like you, we don't work for Apple, so, you know, your pain is of little interest.
    This has been the cause of your problems:
    I checked in Iphoto preferences and the box to automatically import photos to Iphoto was unchecked.
    What that means is you have connected your camera and iPhoto has imported references to your photos - links, in other words. It did not copy your files into the Library.
    Then you took away the camera.
    Now iPhoto is looking for the pictures.
    You'll need to import the images again - but if you do you'll have masses of duplicates. So, trash the existing library, create a new one and start over.
    For more on iPhoto and file management see this User Tip:
    https://discussions.apple.com/docs/DOC-6361

  • I cant call to a mobile number since yesterday, but can receive call from the same number. I am using iphone 4s. Is there any setting error?

    I can't call to a mobile number since yesterday, but still can receive call from the same number. I am using iphone 4s. Is there any setting error?

    you have to make sure that CFWD Bridge Mode under the Line tab of the SPA9000 where the SPA400 is registered is set to ALL...include VMSP Bridge and XFER Bridge Mode as well..power cycle then check if you are still getting one-way audio
    | isolate! isolate! isolate! |

  • Any Ideas ERROR U44M1P7 Update to Camera RAW 8.1(CS6) plug-in Fails to Update

    Any Ideas ERROR U44M1P7 Update to Camera RAW 8.1(CS6) plug-in Fails to Update

    Hi jper_pixated_com
    Please refer : http://forums.adobe.com/message/5391508

  • Is there any obvious benefit to buying my imac from the apple store vs. Best Buy?  Saves $40 so I am contemplating not haggling with crowds at Apple Store.  Any thoughts?

    is there any obvious benefit to buying my imac from the apple store vs. Best Buy?  Saves $40 so I am contemplating not haggling with crowds at Apple Store.  Any thoughts?

    Return policy may be different from Apple's vs Best Buy. Regardless of crowds, only buy from Apple. Dealing with Best Buy in the future, if there's a problem it may not be worth what you believe to be a $40 savings.
    You can make an appointment in advance at the Genius Bar.
    Apple Retail Store - Genius Bar

  • I have an iPhone 4 and plugged it into itunes on my computer for teh first time. Only to discover my sister has obviously plugged hers into my itunes account and now I have lost all my photos and numbers. Please help me!!

    I have an iPhone 4 and plugged it into itunes on my computer for the first time. Only to discover my sister has obviously plugged hers into my itunes account and now I have lost all my photos and numbers. Please help me!!

    It can't do that by itself. You had to click through several prompts telling it to restore it from a backup of an old phone for that to happen.
    If the phone was not backed up to iCloud before this happened, or to another computer, then the data is gone. There is no way to recover it.

  • My wife uploaded new fonts to her macbook and now can not see any writing on her screen, can I fix this?

    Hi, my wife uploaded new fonts to her macbook and now can not see any writing on her screen, can I fix this?
    System fonts deleted accidentally. Does anyone know how I can fix this please?

    Thanks Mike,
    Absolutely right. I restarted in Safe Mode. This enabled me to see the actual text on the screen. Then I backed up. Then reinstalled. All fixed.
    Thanks again,
    Chris

  • Hi I need Apple Hardware test 2.5.2 Apple does'nt have it. Any one on here have a copy or know how I could get access to?Thaks

    hi I need Apple Hardware test 2.5.2 Apple does'nt have it, I orderit it and they no longer carry it so they say. Any one on here have a copy that I could get access to?Thanks

    What model PowerMac do you have? The AHT is on the Install/Restore disc that came with your Mac.
     Cheers, Tom

  • Going from 10gR2 to 11gR2 - any obvious performance 'pitfalls'?

    Hi, there,
    I'm moving some databases from 10gR2 to 11gR2. I was wondering whether there were any obvious pitfalls in performance that I should be aware of (like the optimizer ones in previous versions). I'm taking the SPFILE from 10gR2 and modifying it as little as possible to use as my 11gR2's SPFILE.
    Also, I've heard murmurs of timezones being an issue in migrating to 11gR2? I'm either going to be using export/import or TTS to move my data. I wonder if the timezone issue is related to RMAN somehow.
    Mark

    Hi,
    I performed an Upgrade from 10.2.0.4.4 to 11.2.0.1 two weeks ago.
    I used a note from oracle support for manual upgrade to 11gR2
    the database had database vault and also had auditing enabled.
    these peculiarities are all covered in the note.
    I would suggest that if you have auditing enabled, set the parameter audit_trail=none before you commence upgrade.
    In addition make sure the you have tested the upgrade before implementing on your production environment, this would prepare you greatly.
    after the upgrade, the timezone was upgraded to 11, database vault was turned on, EM upgraded, database vault application redeployed.
    all the best
    samuelk
    Edited by: Samuel K on Feb 24, 2011 3:13 PM
    Edited by: Samuel K on Feb 24, 2011 3:14 PM
    Edited by: Samuel K on Feb 24, 2011 3:15 PM

  • My iPhone 4 is stuck on connect to iTunes  mode!!!!!! Plzzzzz sm help me. What should i do??  I am from albania and i have gone to any apple service here but no help

    my iphone is stuck on connect to itunes mode!!!!! Plzz smb help me!!! What should i do? I am from albania and i have gone to any apple service here but no help!!!!

    Hi enkifromtirane,
    If you had an issue with your iPhone and are now seeing an icon screen instructing you to connect to iTunes, you may find the following article helpful:
    Apple Support: If you can't update or restore your iOS device
    http://support.apple.com/kb/ht1808
    Regards,
    - Brenden

  • I am trying to help a friend who`s imac is giving her trouble. when the user logon is typed the machine begins to load, then in about a minute, kicks back out into the logon screen. ANY insight to her problem will be greatly appreicated?

    I am trying to help a friend who`s imac is giving her trouble. when the user logon is typed the machine begins to load, then in about a minute, kicks back out into the logon screen. ANY insight to her problem will be greatly appreicated?

    Start up in Safe Mode.
    http://support.apple.com/kb/PH11212?viewlocale=en_US
    Repair Disk
    Steps 2 through 8
    http://support.apple.com/kb/PH5836
    http://support.apple.com/kb/ts1417

Maybe you are looking for

  • Applejack hung up on permissions

    When I run Applejack on my PowerBook G4 (10.4.5), it works just fine until it gets to the Repair Permissions step, and there it hangs. It tells me that it takes a while, please wait, and then it begins generating its row of dots. An hour later it's u

  • BAPI for Getting Project Profiles in Project System

    hi,      Can any 1 tell me the BAPI to invoke to get project profiles from project system. Thanks, Debashish Sarkar

  • Unable to activate the DSO in PM Business Content

    I am trying to activate the Business Content for PM (Plant Maintenance). I was able to activate the cubes without any problem. But when I tried activating the DSO 0PM_DS01, the activation is failing while activating the DSO with the message. "You are

  • OS6 only in English?

    Hi, I'm new. I bought my first BB last Saturday, a Curve 9300. I did the upgrade from OS5 to OS6, I suppose. Before the upload I choose Italian as language of the BB, now it's only in English. Somebody know if it's possible to change the language in

  • Accessing COM Objects provided by an EXE server

    Hello, I need to control an application through COM. I did this before with Excel and other software and used LabView's ActiveX functions. But this time I can't find the object I need when I browse the type library. The COM server actually is registe