Results 1 to 10 of 10

Thread: TicTacTo

  1. #1
    Blacknight is offline Member
    Join Date
    Feb 2009
    Posts
    13
    Rep Power
    0

    Default [Solved]TicTacTo

    Problem solved.
    Last edited by Blacknight; 05-08-2009 at 07:52 AM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    What error messages do you see?

    edit: Also please post the whole message, and indicate which lines are causing the error.
    Last edited by Fubarable; 05-08-2009 at 02:33 AM.

  3. #3
    Blacknight is offline Member
    Join Date
    Feb 2009
    Posts
    13
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    What error messages do you see?

    edit: Also please post the whole message, and indicate which lines are causing the error.
    http:/img7.imageshack.us/img7/8339/errorvit.png

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    So you're getting an arrayindexoutofbounds error where you're using a -1 as the array index. However you still haven't told us what line is causing the error, and only you will know as the line numbers in the error correlate with the lines as they exist in your exact code. Please help us help you.

    Also from the error we know that somewhere you're setting an array index to -1. If you walk through your code using the line that causes the error as a reference point, you should see where you're doing this, and then with thought and perseverance, figure out why. You may wish to restart this project but first plan out just what you want your code to do and how it does it on paper. Your program will be much more organized and easier to debug if done this way. Best of luck.
    Last edited by Fubarable; 05-08-2009 at 04:16 AM.

  5. #5
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

    Default

    Java Code:
    while (a != -1) { // Check for winner(Not Complete)
    		if (Column1[a] == -1) {
    			a = -1;
    		}
    		if (Column2[a] == -1) {
    			a = -1;
    		}
    		if (Column3[a] == -1) {
    			a = -1;
    		}
    		
    		if (a == 2) {
    			GameOver = true;
    		}
    		
    		a = a + 1;
    	}
    this is the culprit code. you're deliberately accessing array index of -1 over and over and over again. i'm sure you know what you really wanna do with it?

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    I was trying to lead the OP to this conclusion, but I guess not fast enough...

  7. #7
    Blacknight is offline Member
    Join Date
    Feb 2009
    Posts
    13
    Rep Power
    0

    Default

    Thanks for the replys
    Quote Originally Posted by emceenugget View Post
    Java Code:
    while (a != -1) { // Check for winner(Not Complete)
    		if (Column1[a] == -1) {
    			a = -1;
    		}
    		if (Column2[a] == -1) {
    			a = -1;
    		}
    		if (Column3[a] == -1) {
    			a = -1;
    		}
    		
    		if (a == 2) {
    			GameOver = true;
    		}
    		
    		a = a + 1;
    	}
    this is the culprit code. you're deliberately accessing array index of -1 over and over and over again. i'm sure you know what you really wanna do with it?
    Thanks, Didn't notice at first, that if the first IF was true then it would still continue..

    Changed to:

    Java Code:
    	int i = 0;
    	boolean Done = false;
    	while (Done == false) { // Check if there's a winner, IF not continue.
    		if (Column1[i] == -1 || Column2[i] == -1 || Column3[i] == -1) 
    		{
    			Done = true;
    		}
    		if (i == 2) {
    			GameOver = true;
    			Done = true;
    		}
    		
    		i++;
    	}

  8. #8
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

    Default

    well my purpose for going a little deeper is cuz there's a lot of people who can't take subtle hints and get angry lately (the majority of my responses). that, and there are also a lot of people who would still take advice like i gave and still say "what's that supposed to mean" (see the "illigel" expression topic). thankfully, this was not one of those people.

  9. #9
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    true you're right. Also, the nature of communication here is a bit slow at times to have a dialog.

  10. #10
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Default

    Blacknight: Please leave original post and use the Thread Tools: Mark as Solved next time one of your questions is answered.
    If the above doesn't make sense to you, ignore it, but remember it - might be useful!
    And if you just randomly taught yourself to program, well... you're just like me!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •