If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Ok:

// call find_moves, the method returns the pointer to an array of Move
// object pointers so the variable we store that pointer in has to be declared as
// an array of Move object pointers:
Move [] moveArray=find_moves();
// we select one of the Move object pointers from that array (index 2 in this case)
// just to illustrate...
Move aMove=moveArray[2];
// we peint out thanl Move object using its toString() method
System.out.println(aMove.toString());
// we get the position of that Move object
int aPosition=aMove.getPosition();
// we get the value of that Move object
int aValue=aMove.getValue();

Printing the Move array out:

A java array has no automatic handling that gives you a nice list of its
its elements, so if you code:

System.out.println(moveArray);

you will only get the value of the address (pointer) to that array printed out.

is the pointer to the Move object at index k, and since
the toString method is defined for the Move class the
System.out.println(moveArray[k]); will use the toString method of that
Move object. This is because the System.out.println method always calls
an objects toString method. If there are no such method the
System.out.println will use the toString method of java.lang.Object, which is
the ancestor of all java classes, wether they like it or not , and the
toString methof of java.lang.Object return a string representation of the
object's address.

PS: Move[] aMove would confuse me too, as i would hesitate to name anarray consisting of Move objects aMove....

PSPS: I must stop using i as index in my examples, it just makes everything italic

If the Move class is in the same file as the array_test, and the java file is
named array_test.java it cannot be declared as public,
unless you place the public static void main(String [] args)inside the Move class' body.But: the way you have done it, Move is an inner class of array_test, like:

Thanks for the tips, I have used it all and your help has been tremendous. There is one thing that is still puzzling me.

Im trying to create the original array again thats going to contain a list of moves eg
(2-7, 1-6) (moves can be more than one eg checkers)and most the time i get non static method find moves cannot be referenced from static context.

When you do it from the public static void main(String [] args) method
you are in effect "outside" the array_test class.
You have to invoke the method find_moves via the object pointer of the
array_test instance, mytest, that you have already created, like:

Wow

I have never seen that one ...????????? Also, I have always thought that
typecasting pointers from Object arrays to other arrays was plain stuff. I
am really confused now, and the exception you got looks like a Java VM
bug ....

Anyway, I have kicked the code around and it behaves well now....(knock on wood)..

Btw: why do the toArray() to get an array ?, why not pass back the arraylist
itself and forget the Move[] moves array ?

The reason for this

This is all for a artificial intelligence robot that I have to create for a checkers assignment. I was wondering, if you had some free time and didnt mind helping me through it, I would be most grateful.

Id like to send you some code for the referee and humanPlayer classes and Im busy working on working out all legal moves to place into a minimax alogorith to produce an robot player.

Im now trying to figure out how to implment this array into a minimax tree and return a result that can be used in the getMove() method from the driver class?????