Results 1 to 3 of 3

Thread: queens program

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Posts
    90

    queens program

    I have to make a program taht alows me to place 8 queens on a chest board with out having them kill on another with there repective movements.

    i need to do this program by keeping trake of the movements with a multy bimentional array which i hav no idea how to do. also i have to make a program that runs through all the posible cobination of how the queen can be put on the board and some how show the qween position on an apolet.

    but frist i would to know how i ould go about drawing a cheast board on and applet.

    i have just started java and would really apercheat the help.

    thanx
    CaM

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Posts
    90
    how do you make a multy dimentional array and compare the different part of the array to each other
    CaM

  3. #3
    Addicted Member MethadoneBoy's Avatar
    Join Date
    Oct 2001
    Location
    Preferably somewhere between Keira Knightley and Diane Kruger but I'm not fussy
    Posts
    180
    To make a multi-dimensional array, you do as follows:

    Code:
    int x = 8;
    int y = 8;
    
    private int[][] ArrayName = new int [x][y];
    Comparing positions in the array would probably look something like:

    Code:
    int firstpositionx = 3;
    int firstpositiony = 4;
    int secondpositionx = 5;
    int secondpositiony = 2;
    
    if ( isWithin ( firstpositionx, firstpositiony, secondpositionx,  secondpositiony ) ) return true;
    else return false;
    You could then write a method isWithin ( int a, int b, int c, int d ) which would then take the first two integers a and b, to find a position in the array and then take integers c and d to find a second position. It would then check to see if the first position is within two spaces of the second position.

    Code for a basic chess game can be found in a lot of Java books, I'm sure. Make sure you can program the actual game itself before you bother with graphics.

    Hope this helps
    "'Oh, hello Mr. Crick! What do you think of Jeffrey Archer?' Clip-clip-clip! Oh, come on! Who are you kidding? You wait til I'm mayor, you'll see how tough I am! Christ almighty...."

Posting Permissions

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



Click Here to Expand Forum to Full Width