Results 1 to 2 of 2
  1. #1
    MuslimCoder is offline Senior Member
    Join Date
    Jan 2009
    Rep Power

    Smile Artificial intelligence coding problems


    I am having problem coding a class in ont of ai packages we are suppose to create for our project, it is suppose to be a tic tac toe game and this class in particular deals everything to do with the state including making a move, checking if the current state is a win state etc.

    i created some methods to help me determine the win states , they are the neighbour methods, each time a person makes a move it find the North, North East , East .... neighbours of the move to see if they are same, if they are same it ends the game , determines the winner.

    The noeighbours work find but the problem is checking them, it always seems to return true . here is a code peak...

    Java Code:
    //checks a the values in a given set of poitn to see if they are same and returns true if they are 
        //else it returns false
        public boolean areSame(Vector<Point> nbrs)
          Point p1, p2;
          int v1, v2;
          boolean b = true; // b starts with true because we need it for and operations which would determine 
          System.out.printf("no. of elements", nbrs.size() );
         for(int i = 1; i < nbrs.size() - 1 ; ++i)
            p1 = nbrs.elementAt(i);       v1 = board[(int)p1.getX()] [(int)p1.getY()];
            p2 = nbrs.elementAt(i + 1);   v2 = board[(int)p2.getX()] [(int)p2.getY()];
            System.out.printf("v1: %d , v2: %d", v1,v2);
            b = b && (v1 == v2); // get the and of the last value(or first) with that of the next
          }//this part of the code is only reached when all are same so we can return true
        return b;

  2. #2
    FlyNn is offline Senior Member
    Join Date
    Feb 2010
    Rep Power


    I've been working on a little tic-tac-toe game myself for the last two days. I am about to write some sort off code that can "play against" me just by looking for what fields are taken and what fields the opponent needs to get to win the game. Depending of the results received, rules for the code will determine the best proposition for the next move. I assume it will not be much of AI anyway. I am not 100% sure what you are asking though
    Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

Similar Threads

  1. Need help coding
    By ace_03 in forum New To Java
    Replies: 2
    Last Post: 11-25-2009, 05:16 PM
  2. Coding help
    By Java_Fanatic in forum New To Java
    Replies: 7
    Last Post: 10-15-2009, 04:37 AM
  3. Better coding
    By tomiu in forum New To Java
    Replies: 1
    Last Post: 04-09-2009, 07:19 PM
  4. Socket coding
    By Neptunes07 in forum New To Java
    Replies: 1
    Last Post: 03-05-2009, 08:53 PM
  5. coding help
    By accies76 in forum New To Java
    Replies: 5
    Last Post: 11-12-2008, 08:15 PM

Posting Permissions

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