Need help with Connect 4 game, IndexOutOfRangeException was unhandled

Hi! I've been struggling with this for a while now, the issue is that as soon i move a game piece to the field i get this errorats "IndexOutOfRangeException was unhandled" and i don't know why since my intention with the code was to use for loops
look through the 2D array thats based on two constants: BOARDSIZEx = 9 and BOARDSIZEy = 6. Instead of traditional 7*6 connect 4 grid i made it 9 squares wide due to having pieces on the side to drag and drop.
Here's the code for my checkwin:
public bool checkWin(Piece[,] pieceArray, bool movebool)
bool found = false;
//Horizontal
for (int i = 0; i < BOARDSIZEx - 3; i++)
for (int j = 0; j < BOARDSIZEy; j++)
if ((pieceArray[i, j] != null)
&& (pieceArray[i, j] == pieceArray[i, j + 1])
&& (pieceArray[i, j] == pieceArray[i, j + 2])
&& (pieceArray[i, j] == pieceArray[i, j + 3]))
if (pieceArray[i, j].IsStarter != movebool)
found = true;
goto Done; //interesting way of getting out of nested for loop
//for more on goto: http://stackoverflow.com/questions/324831/breaking-out-of-a-nested-loop
//Vertikal
for (int i = 0; i < BOARDSIZEx; i++)
for (int j = 0; j < BOARDSIZEy - 3; j++)
if ((pieceArray[i, j] != null)
&& (pieceArray[i, j] == pieceArray[i + 1, j]) && (pieceArray[i, j] == pieceArray[i + 2, j])
&& (pieceArray[i, j] == pieceArray[i + 3, j]))
if (pieceArray[i, j].IsStarter != movebool)
found = true;
goto Done; //interesting way of getting out of nested for loop
//for more on goto: http://stackoverflow.com/questions/324831/breaking-out-of-a-nested-loop
//Diagonal, Lower left to upper right
for (int i = 0; i < BOARDSIZEx - 3; i++)
for (int j = 0; j < BOARDSIZEy - 3; j++)
if ((pieceArray[i, j] != null)
&& (pieceArray[i, j] == pieceArray[i + 1, j +1])
&& (pieceArray[i, j] == pieceArray[i + 2, j + 2])
&& (pieceArray[i, j] == pieceArray[i + 3, j + 3]))
if (pieceArray[i, j].IsStarter != movebool)
found = true;
goto Done; //interesting way of getting out of nested for loop
//for more on goto: http://stackoverflow.com/questions/324831/breaking-out-of-a-nested-loop
//Diagonal, upper left to lower right
for (int i = 0; i >= BOARDSIZEx; i--)
for (int j = 0; j < BOARDSIZEy - 3; j++)
if ((pieceArray[i, j] != null)
&& (pieceArray[i, j] == pieceArray[i - 1, j + 1])
&& (pieceArray[i, j] == pieceArray[i - 2, j + 2])
&& (pieceArray[i, j] == pieceArray[i - 3, j +3]))
if (pieceArray[i, j].IsStarter != movebool)
found = true;
goto Done; //interesting way of getting out of nested for loop
//for more on goto: http://stackoverflow.com/questions/324831/breaking-out-of-a-nested-loop
Done:
return !found;
It's at the vertical check that the error occurs and also my checkwin doesnt seem to respond to the call in the game.cs code.
//check for win
bool moveBool = true; //returns yes or no depending on whether both players have moved their pieces
if (move % 2 == 0) moveBool = false;
bool win = rules.checkWin(pieceArray, moveBool);
//The game is won!
if (win)
string winningPlayerName = player1.Name; //creating a new player instance, just for shortening the code below
if (moveBool == false) winningPlayerName = player2.Name; //if it was player 2 who won, the name changes
message = winningPlayerName + " has won the game!\n\n"; //The name of the player
Board.PrintMove(message); //Print the message
if (moveBool == true) player1.Score += 1; else player2.Score += 1; //update score for the players
//The player's labels get their update texts (score)
Board.UpdateLabels(player1, player2);
//Here, depending on what one wants to do, the board is reset etc.
else
move++; //draw is updated
And here's a picture on how it looks like at the moment.
Thanks in Advance!
Student at the University of Borås, Sweden

for (int i = 0; i < BOARDSIZEx; i++) // If BOARDSizex is the number of elements in the first dimension...
for (int j = 0; j < BOARDSIZEy - 3; j++)
if ((pieceArray[i, j] != null)
&& (pieceArray[i, j] == pieceArray[i + 1, j]) && (pieceArray[i, j] == pieceArray[i + 2, j])
&& (pieceArray[i, j] == pieceArray[i + 3, j])) // Then [i + anything, j] will be out of range.
You probably meant to add the one, two, or three to the j rather than the i.

Similar Messages

  • Need help with connecting file inputs to arrays

    In this assignment I have a program that will do the following: display a list of names inputed by the user in reverse order, display any names that begin with M or m, and display any names with 5 or more letters. This is all done with arrays.
    That was the fun part. The next part requires me to take the names from a Notepad file, them through the arrays and then output them to a second Notepad file.
    Here is the original program: (view in full screen so that the code doesn't get jumbled)
    import java.io.*;       //Imports the Java library
    class progB                    //Defines class
        public static void main (String[] arguments) throws IOException
            BufferedReader keyboard;                                  //<-
            InputStreamReader reader;                                 //  Allows the program to
            reader = new InputStreamReader (System.in);               //  read the the keyboard
            keyboard = new BufferedReader (reader);                  //<-
            String name;                 //Assigns the name variable which will be parsed into...
            int newnames;               //...the integer variable for the amount of names.
            int order = 0;              //The integer variable that will be used to set the array size
            String[] array;             //Dynamic array (empty)
            System.out.println (" How many names do you want to input?");   //This will get the number that will later define the array
            name = keyboard.readLine ();
            newnames = Integer.parseInt (name);                                         // Converts the String into the Integer variable
            array = new String [newnames];                                               //This defines the size of the array
            DataInput Imp = new DataInputStream (System.in);       //Allows data to be input into the array
            String temp;                                       
            int length;                                                                  //Defines the length of the array for a loop later on
                for (order = 0 ; order < newnames ; order++)                                //<-
                {                                                                           //  Takes the inputed names and
                    System.out.println (" Please input name ");                            //  gives them a number according to
                    temp = keyboard.readLine ();                                           //  the order they were inputed in
                    array [order] = temp;                                                  //<-
                for (order = newnames - 1 ; order >= 0 ; order--)                                //<-
                {                                                                                //  Outputs the names in the reverse 
                    System.out.print (" \n ");                                                   //  order that they were inputed
                    System.out.println (" Name " + order + " is " + array [order]);             //<-
                for (order = 0 ; order < newnames ; order++)                                  //<-
                    if (array [order].startsWith ("M") || array [order].startsWith ("m"))     //  Finds and outputs any and all
                    {                                                                         //  names that begin with M or m
                        System.out.print (" \n ");                                            //
                        System.out.println (array [order] + (" starts with M or m"));         //
                    }                                                                         //<-
                for (order = 0 ; order < newnames ; order++)                                            //<-
                    length = array [order].length ();                                                   //
                    if (length >= 5)                                                                    //  Finds and outputs names
                    {                                                                                  //  with 5 or more letters
                        System.out.print (" \n ");                                                      //
                        System.out.println ("Name " + array [order] + " have 5 or more letters ");      //<-
    }The notepad file contains the following names:
    jim
    laruie
    tim
    timothy
    manny
    joseph
    matty
    amanda
    I have tried various methods but the one thing that really gets me is the fact that i can't find a way to connect the names to the arrays. Opening the file with FileInputStream is easy enough but using the names and then outputing them is quite hard. (unless i'm thinking too hard and there really is a simple method)

    By "connect", do you just mean you want to put the names into an array?
    array[0] = "jim"
    array[1] = "laruie"
    and so on?
    That shouldn't be difficult at all, provided you know how to open a file for reading, and how to read a line of text from it. You can just read the line of text, put it in the array position you want, until the file is exhausted. Then open a file for writing, loop through the array, and write a line.
    What part of all that do you need help with?

  • Need help with ending a game

    i'm making a game at the moment.......
    i need help with a way to check all the hashmaps of enimies in a class called room......i need to check if they all == 0...when they all equal zero the game ends......
    i know i can check the size of a hash map with size().....but i want to check if all the hashmaps within all the rooms == 0.

    First of all stop cross posting. These values in the HashMap, they are a "Collection" of values, so what is wrong with reply two and putting all these collections of values into a super collection? A collection of collections? You can have a HashMap of HashMaps. One HashMap that holds all your maps and then you can use a for loop to check if they are empty. A map is probably a bad choice for this operation as you don't need a key and an array will be much faster.
    HashMap [] allMaps = {new HashMap(),new HashMap()};

  • MSI P67A-C45 (B3) Newb needs Help with connections..

    Hi all..
    First time posting here, but have been in the shadows for quite a while..   
    Anyway, i decided to finally take the plunge, and build my own PC, and now i'm beginning to hit a few bumps.
    I have a couple of questions that i would like some help with, if possible to reassure myself i may be in the right direction..
    I bought THIS PSU and was hoping someone could tell me where the Blue connectors (one labelled CP and one labelled U1) Connect to?
    Is it into JPWR2? And does it/do they only connect in the correct way? (Do i remove the plastic cap and attach both?
    and i bought THIS VIDEO/GRAPHICS CARD and i'm guessing the RED "PCI express" and "SLI ready" connect to that somehow (Haven't opened box yet for card)
    Again, wondering is there a certain way for them to connect.
    Also, from my chassis, the "AC '97" and "HDA" connectors go to JAUD (I guess), does it matter which one? (I currently have "HDA" connected)
    I have i5 2500k already on board. (If that makes a difference).

    Quote from: Ben_Cartwright on 26-May-11, 22:05:35
    Do the Audio plugs go into JAUD? and does it matter which one?
    Yep, connect the front panel audio to the JAUD. If you need the pin layout, it says in the manual. I would say the HDA connector is the one to connect.
    Quote from: Ben_Cartwright on 26-May-11, 22:05:35
    Any recommendations for testing it all, before i plug it in, and press the power?
    Should i (Can i) test individual parts first?
    Thanks again.
    Check all power connections, seating of the RAM and add-on cards, check the HSF is plugged into the fan header, and obvious things like that.
    As for testing, enter the BIOS and make sure the CPU isn't running too hot. Set up the RAM with the required timings and voltage, and test with >>Memtest86<< for several hours. No point starting the Windows installation if say your RAM has errors, since it will corrupt files during the install, if it installs at all.

  • I need help with a backup file that was deleted and now undeleted from my hard drive

    Last month (May 6, 2011), I was updating my iPod Touch 4G with the new software that came out. I always make a backup of my iPod's data before I update it. While my iPod was updating I left my iPod and computer alone and was doing things around the house with my mom. And when I was done I went in my room to see if it was done and my computer decides that it was going to freeze and crash on me (with my iPod plugged in and stuck on the updating or verifying software mode.) I managed to get my iPod back to working condition again but losing everything on my iPod. I formatted my computer hard drive but I managed to get back the backup I lost. I need help on getting the backup into iTunes so I can get my data back. I am not Jailbroken and I plan not to Jailbreak. I however saved the backup file in a folder other than the Mobilesync folder. I am also running on Windows XP. Someone please help me and thank you in advance!

    I was able to backup my iPod and I tried to restore my iPod again and it goes through the process and everything but it restores the temporary data that I had on there. It didn't restore application data or the current photos and videos that I had saved in Camera Roll before this all had happened. It is almost like it goes back to factory settings but I have some photos that were saved on the other backup that I was temporarily running on. The backup that I am looking to restore is the only backup file in the Mobilesync folder as of right now the others are saved somewhere safe for right now. Why doesn't it restore my application data or my Camera Roll pictures and videos that I saved before my computer crashed last month? Can this problem be fixed?

  • CS5.5 need help with connecting to wsdl

    Hello,
    I'm new to Dreamweaver CS5.5 and i'm looking for a simple way to connect to a CFC wsdl web service.
    Basically need to pass 1 parameter to the webservice and have it return a string result from our database.
    Is this possible to do from dreamweaver, using javascript ?
    thanks.

    Those crosshairs are controllers for an effect. The first thing to do is to start turning off layers (eyeball) until you find the layer with the crosshairs. Once you've isolated the layer make sure that it's not a pre-comp, press F3 to reveal the ECW, and check the effects. If you can't turn the effects on and off then or access any of the settings the layer is locked. What would really help here is a screenshot. I can't tell much from the photo because I can't see what's under the hood.

  • Need help with " Number guessing game " please?

    This is what teacher requires us to do for this assignment:
    Write a program that plays a simple number guessing game. In this game the user will think of a number and the program will do the guessing. After each guess from the program, the user will either indicate that the guess is correct (by typing �c�), or that the next guess should be higher (by typing �h�), or that it should be lower (by typing �l�). Here is a sample output for a game. In this particular game the user thinks of the number 30:
    $java GuessingGameProgram
    Guess a number between 0 and 100
    Is it 50? (h/l/c): l
    Is it 25? (h/l/c): h
    Is it 37? (h/l/c): l
    Is it 31? (h/l/c): l
    Is it 28? (h/l/c): h
    Is it 29? (h/l/c): h
    Is it 30? (h/l/c): c
    Thank you for playing.
    $
    This program is implementing a binary search algorithm, dividing the range of possible values in half with each guess. You can implement any algorithm that you want, but, all things being equal, binary search is the best algorithm.
    Write the program so that the functionality is split between two classes: GuessingGameProgram, and NumberGuesser.
    GuessingGameProgram will only be used for its main function. It should instantiate a NumberGuesser, and it will be responsible for the loop that notifies the user of the next guess, reads the �h�, �l�, or �c� from the user, and sends an appropriate message to the number guesser accordingly.
    The guesses themselves should all be generated by the NumberGuesser class. Here is a diagram of the members and methods for the class. Notice that the members are unspecified. Feel free to give your NumberGuesser class any members (which we have also been calling fields, or instance variables) that you find useful. Make them all private.
    NumberGuesser
    NumberGuesser(int upperLimit, int lowerLimit)
    int guess()
    void higher()
    void lower()
    The constructor should take two integer arguments, a lower and upper bound for the guesses. In your program the constructor will be called with bounds of 0 and 100.
    The guess method should return the same value if it is called more than once without intervening calls to the lower or higher methods. The class should only change its guess when it receives a message indicating that its next guess should be higher or lower.
    Enjoy. Focus your attention on the NumberGuesser class. It is more interesting than the GuessingGameProgram class because it is a general-purpose class, potentially useful to anybody who is writing a number guessing game. Imagine, for instance, that a few weeks from now you are asked to write a number guessing game with a graphical Java Applet front end. If you NumberGuesser class is well written, you may be able to reuse it without any modifications.
    I'm new to JAVA and I'm set with my 2nd homework where I'm so confused. I know how to do something of this source in C language, but I'm a bit confused with Java. This is the code me and my classmate worked on, I know it's not 100% of what teacher asked, but is there any way possibly you guys could help me? I wrote this program if the game is played less then 10 times, thought I would then re-create a program without it, but now I'm confused, and my class book has nothing about this :( and I'm so confused and lost, can you please help? And out teacher told us that it's due the end of this week :( wish I knew what to do. Thank you so so much.
    Here's the code:
    import java.text.*;
    import java.io.*;
    class GuessingGame
    public static void main( String[] args ) throws IOException
    BufferedReader stdin = new BufferedReader(new InputStreamReader( System.in ) );
    int guess = 0, limit = 9, x = 0, n, a = 0 ;
    double val = 0 ;
    String inputData;
    for ( x = 1; x <= 10; x++)      //number of games played
    System.out.println("round " + x + ":");
    System.out.println(" ");
    System.out.println("I am thinking of a number from 1 to 10. ");
    System.out.println("You must guess what it is in three tries. ");
    System.out.println("Enter a guess: ");
    inputData = stdin.readLine();
    guess = Integer.parseInt( inputData );
    val = Math.random() * 10 % limit + 1;     //max limit is set to 9
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMaximumFractionDigits(0);               //format number of decimal places
    String s = nf.format(val);
    val = Integer.parseInt( s );
         for ( n = 1; n <= 3; n++ )      //number of guess's made
                   if ( guess == val)
                        System.out.println("RIGHT!!");                    //if guess is right
                        a = a + 1;
                        System.out.println("You have won " + a + " out of " + x + " rounds");
    System.out.println(" ");
    n = 3;
    continue;
              if (n == 3 && guess != val)                         //3 guesses and guess is wromg
                        System.out.println("wrong");
    System.out.println("The correct number was " + val);
                        System.out.println("You have won " + a + " out of " + x + " rounds");
    System.out.println(" ");
    continue;
                   //how close guess is to value
                   if ( guess == val - 1 || val + 1 == guess) //Within 1
                   System.out.println("hot");
         else if ( guess == val - 2 || val + 2 == guess) // Within 2
                   System.out.println("warm");
              else
                   System.out.println("cold");                         // Greater than 3
         inputData = stdin.readLine();
         guess = Integer.parseInt( inputData );
    //ratings
    if ( a <= 7)
         System.out.println("Your rating is: imbecile.");
    else if ( a <= 8)
         System.out.println("Your rating is: getting better but, dumb.");
    else if (a <= 9)
         System.out.println("Your rating is: high school grad.");
    else if ( a == 10)
         System.out.println("Your rating is: College Grad.!!!");

    Try this.
    By saying that, I expect you ,and your classmate(s), to study this example and then write your own. Hand it in as-is and you'll be rumbled as a homework-cheat in about 20ms ;)
    When you have an attempt where you can explain, without refering to notes, every single line, you've cracked it.
    Also (hint) comment your version well so your tutor is left with the impression you know what you're doing.
    In addition (huge hint) do not leave the static inner class 'NumberGuesser' where it is. Read your course notes and find out where distinct classes should go.
    BTW - Ever wonder if course tutors scan this forum for students looking for help and/or cheating?
    It's a double edged sword for you newbies. If you ask a sensible, well researched question, get helpful answers and apply them to your coursework, IMHO you should get credit for doing that.
    On the other hand, if you simply post your assignment and sit there hoping some sucker like me will do it for you, you should be taken aside and given a good kicking - or whatever modern educational establishments consider appropriate abmonishment ;)
    I'd say this posting is, currently, slap bang between the two extreemes, so impress us. Post your solution in the form you intend to hand it in, and have us comment on it.
    Good luck!
    import java.io.InputStreamReader;
    import java.io.BufferedReader;
    public class GuessingGame
         public static void main(String[] args)
              throws Exception
              BufferedReader reader= new BufferedReader(
                   new InputStreamReader(System.in));
              NumberGuesser guesser= new NumberGuesser(0, 100);
              System.out.println(
                   "\nThink of a number between 0 and 100, oh wise one...");
              int guess= 0;
              while (true) {
                   guess= guesser.guess();
                   System.out.print("\nIs it " +guesser.guess() +"? (h/l/c) ");
                   String line= reader.readLine();
                   if (line == null) {
                        System.out.println(
                             "\n\nLeaving? So soon? But we didn't finish the game!");
                        break;
                   if (line.length() < 1) {
                        System.out.println("\nPress a key, you muppet!");
                        continue;
                   switch (line.toLowerCase().charAt(0)) {
                        case 'h':  
                             guesser.higher();
                             break;
                        case 'l':     
                             guesser.lower();
                             break;
                        case 'c':
                             System.out.println("\nThank you for playing.");
                             System.exit(0);
                        default:
                             System.out.println(
                                  "\nHow hard can it be? Just press 'h' 'l' or 'c', ok?");
                             continue;
                   if (guess == guesser.guess()) {
                        System.out.println(
                             "\nIf you're going to cheat, I'm not playing!");
                        break;
         private static class NumberGuesser
              private int mLower;
              private int mUpper;
              private int mGuess;
              NumberGuesser(int lowerLimit, int upperLimit)
                   mLower= lowerLimit;
                   mUpper= upperLimit;
                   makeGuess();
              private void makeGuess() {
                   mGuess= mLower + ((mUpper - mLower) / 2);
              int guess() {
                   return mGuess;
              void higher()
                   mLower= mGuess;
                   makeGuess();
              void lower()
                   mUpper= mGuess;
                   makeGuess();
    }                  

  • Need help with connecting laptop

    Hi there,
      I looked through the boards and found some messages that kind of fit to my problem, but not completely so here goes. 
    I have a gateway desktop(windows xp) connected to dsl (charter) and a laptop(gateway solo with windows xp) that I am trying to connect through a wireless router (Linksys wrt54g). 
    When I connect the wireless router to my laptop it says it is connected, but I cannot get a webpage to appear and once my router is connected I cannot use my desktop online. 
    I am sure there is just some configurations that need done, but I'm not that familiar with alot of the comuter lingo in order to figure this one out on my own.  I mainly use the desktop, but I would like to configure the laptop so I can use it online when needed.  Help and keep it simple please...
    Another question...do I need to use the wireless router or can I somehow connect my laptop through my desktop or just through my dsl connection?
    Thanks, Deanna

    Connect the Modem to the Internet Port on the Router.
    Then , Connect the Computer using a different
    Ethernet Cable to Port 1 or Port 2 on the Router.
    Now, Press the Reset Button on the rear panel of the Router
    for 12 Seconds. Then, Release the Reset Button,
    Unplug the Power Adapter to the Router. After 10 Seconds,
    Unplug the Power Adapter to the Modem. Then Wait for
    30 Seconds, Re-connect the Modem, and once the Lights are
    up on the Modem, Re-connect the Linksys Router.
    If yes, Open a new Internet Explorer
    Page, and in the address bar, type http://192.168.1.1, press
    return, And when asked for Username and Password,
    Leave the Username blank and in the Password field,
    type admin . This will help you access the Router's
    Console.
    In the Router's Setup Page, just below Setup Tab,
    in the blue line, you could an option " MAC Address Clone "
    Click on that, Enable it, Save the Settings
    Below the Setup Tab of the Router's Console,
    Change the MTU from "AUTO" to "MANUAL" , and
    Set the Size to 1400, Save the Settings,
    Powercycle the Modem and the Router.
    Check the Connections.
    If you are able to go Online when hard wired to the Router.
    Then make your computer wireless and verify . . .

  • RE: Need Help with Designing a game of  "GO"

    I have got the GUI sorted thanks to some source code supplied by Noah.W. I wish to add animation to the program below.
    Can someone please help me with the capture methods in the below code. I basically need it to capture all pieces that have been surrounded by opposing pieces. This may be one piece or a whole group captured.
    At the moment it only does it for one piece.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    public class GoGame extends JFrame
    public GoGame()
         getContentPane().setLayout(null);
         setBounds(10,10,510,520);
         getContentPane().add(new TheTable());
         setVisible(true);
    public class TheTable extends JPanel
         int[][]points  = new int[19][19];
         boolean black  = true;
    public TheTable()
         setBounds(20,20,453,453);
         addMouseListener(new MouseAdapter()
              public void mouseReleased(MouseEvent m)
                   Point p = clickOnIntersection(m.getPoint());
                   if (p != null && points[p.x/25][p.y/25] == 0)
                        int x = p.x/25;
                        int y = p.y/25;
                        if (black)
                             points[x][y] = 1;
                             black = false;
                             capture(x,y,2,1);
                             capture(x,y,1,2);
                        else
                             points[x][y] = 2;
                             black = true;
                             capture(x,y,1,2);
                             capture(x,y,2,1);
                        repaint();
    private Point clickOnIntersection(Point p)
         Rectangle rh = new Rectangle(0,0,getWidth(),5);
         Rectangle rv = new Rectangle(0,0,5,getHeight());
         for (int h=0; h < 19; h++)
              rh.setLocation(0,h*25-2);
              if (rh.contains(p))
                   for (int v=0; v < 19; v++)
                        rv.setLocation(v*25-2,0);
                        if (rv.contains(p)) return(new Point(v*25+1,h*25+1));
         return(null);
    private void capture(int x1, int y1, int col0, int col1)
         for (int x=Math.max(0,x1-2); x < Math.min(19,x1+2); x++)
              for (int y=Math.max(0,y1-2); y < Math.min(19,y1+2); y++)
                   if (points[x][y] == col0) capture(x,y,col1);
    private void capture(int x, int y, int col)
         if (x > 0  && points[x-1][y] != col) return;
         if (x < 18 && points[x+1][y] != col) return;
         if (y > 0  && points[x][y-1] != col) return;
           if (y < 18 && points[x][y+1] != col) return;
         points[x][y] = 0;
    public void paintComponent(Graphics g)
         super.paintComponent(g);
         Graphics2D g2 = (Graphics2D)g;
         g2.setPaint(new GradientPaint(getWidth(),getHeight(),Color.yellow,0,0,Color.red,true));
         g2.fillRect(0,0,getWidth(),getHeight());
         g2.setColor(Color.black);
         for (int n=0; n < 19; n++)
              g2.fillRect(0,n*25,getWidth(),3);
              g2.fillRect(n*25,0,3,getHeight());
         g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);          
         g2.setColor(Color.green) ;
         for (int n=0; n < 3; n++)
              g2.fillOval(25*3-1,n*150+74,5,5);
              g2.fillOval(25*9-1,n*150+74,5,5);
              g2.fillOval(25*15-1,n*150+74,5,5);
         for (int x=0; x < 19; x++)
              for (int y=0; y < 19; y++)
                   if (points[x][y] != 0)
                        if (points[x][y] == 1) g.setColor(Color.black);     
                        if (points[x][y] == 2) g.setColor(Color.white);     
                        g2.fillOval(x*25-9,y*25-9,20,20);
    public static void main(String[] args)
         GoGame game = new GoGame();
         game.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

    I am also willing to reward �20 via Paypal for the complete solution to the game of "GO", excluding the animation element. Half can be emailed first, then the rest after payment.

  • I need help with an app game purchase

    I recently added 20$ to my account with 2 10$ Itunes cards. I play the app called clash of clans, in the game you can buy things with itunes, I tried to make a purchase for 19.99 when there is just about 21 $ in my itunes and it's telling me I have insufficient funds. This is odd becusee a couple days ago I did the same thing with the itunes card but now I'm getting this error. I checked my itunes again and I have the money, please help!

    What country are you in ? If you are in the US then does your state's sales tax take it over what you have on your account ?

  • Need help with Connect to iTunes error.

    My iPhone 3GS is stuck with the "Connect to iTunes" image. It will not go away.
    It happened when I tried to get the IOS 6.0 update. I had the same issue with my iPad when I tried getting the update but at least my iTunes recognized my iPad after 2 or 3 days. I cannot wait that long to get my phone working again.
    Right now, iTunes will not recognize my phone at all.
    I have tried most of the troubleshooting tips i.e. I'm running the latest version of iTunes, I have restarted my laptop, I have done a few gard resets on my iPhone, power down, power up..etc..etc.
    I'm using a PC with windows 7.
    Any help/suggestions will be much appreciated.
    Thanks is advance.

    See:
    iOS: Unable to Update or Restore
    http://support.apple.com/kb/ht1808

  • Need help with a guessing game

    Hi. hopefully, this is a really easy issue to resolve. I had to write a program that administers a guessing game, where the computer chooses a random number, and the user has to guess the number. If the user doesn't get it within 5 guesses, they lose and start all over with a new number. I have this all in a while loop (as per my instructions). My issue is that whenever the user enters 0, the program should quit with the users final score and so on. My program will not quit unless the 0 is entered on the last (fifth) guess. please help, it would be very appreciated. Here is my code:
    import java.util.Scanner;
      public class guessgame {
        public static void main(String[] args) {
          Scanner scanner = new Scanner (System.in);
            int randnum;        //random number generated by computer
            int userguess = 1;      //number the user guesses
            int userscore = 0;      //number of correct guesses by user
            int compscore = 0;      //number of times not guessed
            int guessnum = 0;       //number of guesses for one number
            int gamenum = 0;        //number of games played
        System.out.println ("I will choose a number between 1 and 10");
        System.out.println ("Try to find the number using as few guesses as possible");
        System.out.println ("After each guess i will tell you if you are high or low");
        System.out.println ("Guess a number (or 0 to quit)");
        while (userguess != 0) {
          randnum = 1 + (int)(Math.random() * 10); //generates random number
          gamenum ++;
          userguess = userguess;
            for (guessnum = 1; guessnum < 6 && userguess != randnum; guessnum ++) {
                userguess = scanner.nextInt();
                userguess = userguess;
               if (guessnum >= 5) {
                  System.out.println ("You did not guess my number!");
                                  } //closes if statement
               if (userguess == randnum) {
                 userscore ++;
                 System.out.println ("You guessed it! It took you " + guessnum + " tries.");
                 System.out.println ("If you want to play again, enter a guess");
                 System.out.println ("If you do not want to play again, enter 0");
                                        } //closes if statement
               else if (userguess < randnum)
                 System.out.println ("Your guess is too low");
               else if (userguess > randnum)
                 System.out.println ("Your guess is too high");
                                                          }//closes for loop
                              } //closes while loop
    compscore = gamenum - userscore;
            System.out.println ("Thanks for playing! You played " + gamenum + " games");
            System.out.println ("Out of those " + gamenum + " games, you won " + userscore + " times");
            System.out.println ("That means that I won " + compscore + " times"); 
    } //closes main
    } //ends guessgame class

    The problem with your program is that the while loop doesn't get checked. The condition of the while loop will only get checked each iteration, and not during one iteration. The time you are in your for-loop is still one iteration so it won't check if userguess is 0. see it liek this
    While: is userguess 0, no, do 1 iteration
    while-iteration-forloop: check 5 guesses, userguess can be anything even 0 while loop won't stop.
    end of for loop
    end of while-iteration
    new while iteration, is userguess 0?
    and so on.
    HTH,
    Lima

  • Need help with connected / linked pop-up menus

    I want to select a preset.
    What I did is create 2 pop-up menus. The first with the preset folders and the second with the presets from that folder.
    Each pop-up group has a pop-up and a static field with the current choise.
    After selecting a different value from the first pop-up menu I want to have the second popup menu filled with the new, right presets of that folder.
    The first time everything works correct.
    However when selecting a different folder I see that the "preset table"  is filled with the correct new preset of that folder. Also the static field below the second pop-up menu shows the first value of the correct new presets. But the second pop-up menu itself still contains the presets of the first folder and not the new folder.
    Yet in the Observer I see that the preset table contains the right and new presets.
    My code is below.
    I based it on the sample in the SDK manual.
    Question: How can I update the second pop-up menu so that the pop-up menu shows the right presets.
    Code below
    local LrApplication = import 'LrApplication'
    local LrPathUtils = import 'LrPathUtils'
    local LrFileUtils = import 'LrFileUtils'
    local LrBinding = import "LrBinding"
    local LrDialogs = import "LrDialogs"local LrFunctionContext = import "LrFunctionContext"
    local LrView = import "LrView"
    local bind = LrView.bind -- shortcut for bind() method
    --     https://github.com/kikito/inspect.lua
    local inspect = require 'inspect'
    local logFilename = 'PresetList'
    local myLogger = import 'LrLogger'( logFilename )
    myLogger:enable( "logfile" )
    local logPath
    Name          emptyLogFile
    Purpose          Clears the existing log file.
    From cookbook: http://cookbooks.adobe.com/post_Clearing_your_logfile_automatically-19677.html
    function emptyLogFile()
    --local myLogger = import 'LrLogger'( 'Stash' )
    myLogger:disable()
    logPath = LrPathUtils.child(LrPathUtils.getStandardFilePath('documents'), logFilename .. ".log")
    if LrFileUtils.exists( logPath ) then
    local success, reason = LrFileUtils.delete( logPath )
    if not success then
    logger:error("Error deleting existing logfile!" .. reason)
    end
    end
    myLogger:enable( "logfile" )
    end
    Name          getLocationLogFile.
    Purpose          Returns the full path of the current log file.
    function getLocationLogFile()
    return logPath
    end
    local function getPresetFolders()
    -- Get all folders with presets
        local lrPresetFolders = LrApplication.developPresetFolders()
        local presetFolderCache = {}
    local record = {}
        for i, fo in ipairs( lrPresetFolders ) do
    record = {title = fo:getName(), value = fo }
    --record = {title = fo:getName(), value = fo:getName() }
    --myLogger:info( "folder name = " .. fo:getName() )
    table.insert ( presetFolderCache, record )
    end
    --     myLogger:info("Voor de listing")
    --     myLogger:info("preset Folders : " .. inspect (  presetFolderCache ) )
    return presetFolderCache
    end
    local function getPresets ( folderObject )
    local presets = folderObject:getDevelopPresets()
    local presetCache = {}
    local record = {}
    for j, p in ipairs( presets ) do
    record = {title = p:getName(), value = p:getName() }
    --record = {title = p:getName(), value = p:getName() }
    myLogger:info( "getPresets = " .. p:getName() )
    table.insert ( presetCache, record )
    end
    myLogger:info("presets : " .. inspect (  presetCache ) )
    return presetCache
    end
    local function ChoosePreset()
    emptyLogFile()
    local presetFolders = getPresetFolders()
    local currentPresetFolder = presetFolders[1]["value"]
    local presets = getPresets ( currentPresetFolder )
    myLogger:info(presets)
    --     myLogger:info("preset Folders : " .. inspect (  presetFolders ) )
    LrFunctionContext.callWithContext( 'Pop-up example', function( context )
    local f = LrView.osFactory() -- obtain view factory
    local properties = LrBinding.makePropertyTable( context ) -- make prop table
    -- create some keys with initial values
    properties.presetFolder = presetFolders[1]["value"] -- for radio buttons and pop-up menu
    properties.preset = presets[1]["value"]
    properties:addObserver( 'presetFolder', function( properties, key, newValue )
    myLogger:info("Observer - get preset list" )
    currentPresetFolder = properties.presetFolder
    presets = getPresets ( currentPresetFolder )
    myLogger:info(presets)
    myLogger:info("Observer - Preset table: " .. inspect ( presets ) )
    --     Set the new value
    properties.preset = presets[1]["value"]
    myLogger:info("Observer: " .. presets[1]["title"] )
    end )
    --     myLogger:info("presetFolder = " .. properties.presetFolder )
    --     myLogger:info("preset = " .. properties.preset )
    local contents = f:column { -- create view hierarchy
    fill_horizontal = 1,
    spacing = f:control_spacing(),
    bind_to_object = properties, -- default bound table is the one we made
    f:group_box {
    title = "Preset folders",
    fill_horizontal = 1,
    spacing = f:control_spacing(),
    f:popup_menu {
    value = bind 'presetFolder', -- current value bound to same key as static text
    items = presetFolders
    f:static_text {
    fill_horizontal = 1,
    title = bind 'presetFolder', -- bound to same key as current selection
    f:group_box {
    title = "Presets",
    fill_horizontal = 1,
    spacing = f:control_spacing(),
    f:popup_menu {
    value = bind 'preset', -- current value bound to same key as static text
    items = presets
    --     items = getPresets ( currentPresetFolder )
    f:static_text {
    fill_horizontal = 1,
    title = bind 'preset', -- bound to same key as current selection
    local result = LrDialogs.presentModalDialog( -- invoke the dialog
    title = "Select preset",
    contents = contents,
    end
    end
    -- Now display the dialogs
    ChoosePreset()

    That should work because you are likely to be creating a new table each time computeNewItems() executes..
    Sometime the bind function doesn't recognise whether the contents of a table bound to a property changes. So if you use something like this:
    local myItems = computeNewItems() -- compute array of tables with title and value members
    properties['myPresetItems'] = myItems --  assign to bound member of property table.
    it will work the first time. If you then do this:
    myItems = computeNewItems() -- compute array of tables with title and value members but using existing variable
    properties['myPresetItems'] = myItems --  assign to bound member of property table. Change might not be noticed by bind.
    In this instance you would need to reassign the same value again. i.e.
    properties['myPresetItems'] = myItems --  assign to bound member of property table again to force bind to check for table values.
    Setting a property with the same value twice seems to trick bind into checking to see whether you have bound a table. I'm not sure whether this trick is only required on some versions of LR (e.g. LR 2) or only on one of the platforms, but even if it isn't required in LR 5 it will help improve your backwards compatibility and it shouldn't cause any harm to continue using it in LR 5.
    Matt

  • Need help with connectivity

    I recently have been trying to get ahold of tech support for issues with my note 3 and wifes moto x. We are able to call out but the reception is horrible on the other end. People are not able to hear what we say. I currently have the network extender but it does not seem to be working. I'm hoping I can get a response on here since I cant get ahold of anyone on the phone and my cell phones are my only way of communication. I'm not sure how to reach this forum from my mobile device so I will try to find this post here or can be contacted directly at (removed) since internet use is the only way i'm being able to use my device at the moment.
    >> Personal information removed to comply with the Verizon Wireless Terms of Service <<
    Message was edited by: Verizon Moderator

    Hi Zhoffmann,
    If you are currently having issues with an iPhone that is displaying "Searching..." in the upper left hand corner, you may find the following article helpful:
    iPhone: Troubleshooting No Service
    http://support.apple.com/kb/ts4429
    Regards,
    - Brenden

  • Need help with connecting a display

    My brother no longer wants his TV so I thought that maybe I could connect it to my iMac.
    He has a Mini Display port to HDMI cord and it worked between his MacBook Pro and the TV downstairs, not sure on any other TVs.
    The TV in question is a Samsung LE19R. I tried connecting it and it said "Not compatible in this mode" (Or something like that).
    So I tried fiddling with the settings, try changing the mode, nothing.
    Considering that the TV downstairs is by Sony, I thought I'd try my TV (As it's a Sony as well; KDL-19S5700), just to see. Doesn't work either.
    Pretty much just wanted to try this for the fun of it, but not permenantly because there's no where near enough room n my desk, so I was thinking it could perhaps be a future configuration if I rearrange a few things. I'm going to get a job and save up for a Mac Pro. This will take some time and tere'll probably be a new Mac Pro on the market or something else, but it would take too much time to save up for a monitor as well, so I culd use my brother's if I do manage to save up.
    So it's nothing too important, but it would be nice to try it. Any suggestions?

    Checking the manual of the Samsung, it seems to mention that you can't connect a PC via HDMI.
    I don't know why the Samsung manual would say that. If it supports HDMI (at the proper version level) then I would think it wouldn't know where the signal is coming from.  Maybe it has something to do with the EDID info (or lack of it) from the TV.
    Not sure about the Sony though.
    I have a Sony 32XBR6 hooked to my machine via HDMI and it works great (for full disclosure here, I have connected to a mac pro)
    On the iMac, I can't change the refresh rate on the secondary monitor; it's stuck at 60Hz, but I live in a PAL region, so the TV is 50Hz. Could that be the problem?
    Not sure about the refresh rate for PAL.  Just try whatever refreh rates the Displays offers to fish for one that would work.
    Also I'm sure the TV is 720p, but when I clicked "Mirror Monitors", the iMac display changed to something else, which wasn't 720p.
    You don't want to use mirrored with this arrangement.  With mirrored all the screens would have a size determined by the smallest screen.

Maybe you are looking for

  • Certain number not receiving text messages

    I've been having a problem with my phone where a single number will not receive any text messages sent from my number. I receive any texts from him without any issue, and we can both call each other as well. I am on Verizon, an iphone 5 with the late

  • How can i change the color of the text bubble in Preview?

    Is it possible to change the colour of the text bubble in Preview?  In the Help section it seems to indicate you can but following the directions only puts a border around the bubble in the colour you have chosen.  The interior colour of the bubble d

  • Creation of a standard account

    Hi everybody, It's my 1st post here. I have a Mac mini Server with Mac OS X Server 10.6.3. created an Administrator account during the set up process and everything run smooth. Now I would like to create a plain standard account in order to use the M

  • Buffer error when loading from EAS??

    All, We're on essbase 7.1.2 and having trouble loading an ASO cube thru eas. We keep getting error 1270040: Data load buffer [2] does not exist. I did some research on this and it should only happen when running thru MaxL, not in EAS. From what I rea

  • Rule Based ATP- Error in calling up function 'BAPI_APOATP_CHECK' in APO ser

    Hi Experts I hae configured Rule Based ATP with Multi-Level ATP check. I have completed all configuration required for Rule Based ATP but still facing an error " Error in calling up function 'BAPI_APOATP_CHECK' in APO server 'SC5CLNT001': Check instr