Create a static member in your class which is a bool type 2D array (call it say,current_pos) of 8X8 elements.
Each time you assign a Position to the object, be sure to mark the current_pos[x][y]=TRUE;
So, now you can keep track of what all postition are been ocupied.
Hence, as soon as your random() generates a new position, check whether that position is already occupied or not. If it is, tell him to generate another number and so on.
Since the array will be a static member, its value will be same for all the object of the class.
Last edited by siddhant3s; Mar 1st, 2009 at 9:37 am.
Reputation Points: 1486
Solved Threads: 140
Practically a Posting Shark
Offline 816 posts
since Oct 2007