# This might help

Moderator

FUNCTION mapToBoard% (x AS INTEGER, y AS INTEGER)
'x must be from 1 to 9
'y must be from 1 to 9

'make sure the coordinates will map
IF (x < 3 AND y < 3) OR (x > 5 AND y < 3) OR (x < 3 AND y > 5) OR (x > 5 AND y > 5) THEN
mapToBoard% = -1
'map position
'last 3 lines
ELSEIF y% >= 6 THEN
mapToBoard% = (y% - 6) * 3 + (9 * 4) + (x% - 3)
'middle 3 lines
ELSEIF y% >= 3 THEN
mapToBoard% = (y% - 3) * 9 + (9 * 1) + (x% - 0)
'top 3 lines
ELSE
mapToBoard% = (y% - 0) * 3 + (9 * 0) + (x% - 3)
END IF
END FUNCTION

Call the function with the 9x9 grid coordinates of the marble and it will give you the number of that marble position in English reading order. Here's the way I got the 9x9 grid coordinates and my call to the function:
mxp% = FIX((mx - 148) / 37)
myp% = FIX((my - 47) / 37)
LOCATE 3, 1:  PRINT "mxp="; mxp%; " myp="; myp%
mcnt = mapToBoard%(mxp%, myp%)
LOCATE 2, 1:  PRINT "mcnt="; mcnt

PhyloGenesis

 This message has been edited by PhyloGenesis on Apr 16, 2010 11:54 PM

Posted on Apr 16, 2010, 11:53 PM

 Response Title Author and Date Incidentally, I have this Peg Solitaire brute-force solver (URL*) PhyloGenesis on Apr 17