I have managed to 'debug' this problem, but have no idea why it was failing in the first place...
In my Minesweeper game I retrieved the x, y, z values of the cube chosen (stored in a type), then used these to check for mines, neighbours or removable status. If I use the retrieved values I get intermitent failures. If I use the values directly from the type it works.
The two debuglog lines eventually allowed me to pinpoint the problem... they don't always match !!!
and the type is...
Can anyone shed any light on what is going on here ? Is it a problem with using the same list of types with a recursive routine ?
In my Minesweeper game I retrieved the x, y, z values of the cube chosen (stored in a type), then used these to check for mines, neighbours or removable status. If I use the retrieved values I get intermitent failures. If I use the values directly from the type it works.
The two debuglog lines eventually allowed me to pinpoint the problem... they don't always match !!!
;=============================================================================================== Function CheckPicked() xmouse = MouseX() ymouse = MouseY() ;chosenX = chosenY = chosenZ = -1 chosen = CameraPick(camera, xmouse, ymouse) For clear.GRIDPOSITION = Each GRIDPOSITION clear\peeked = False Next If chosen <> 0 Then Local possible.GRIDPOSITION For clicked.GRIDPOSITION = Each GRIDPOSITION If clicked\shapehandle = chosen Then possible = clicked EndIf Next Local chosenX = possible\x Local chosenY = possible\y Local chosenZ = possible\x DebugLog "X, Y, Z, in loop === " + possible\x + " " + possible\y + " " + possible\z + " peeked value = " + possible\peeked + " neighbours = " + possible\neighbours DebugLog "X, Y, Z, in loop === " + chosenX + " " + chosenY + " " + chosenZ + " peeked value = " + possible\peeked + " neighbours = " + possible\neighbours If possible\hasmine > 0 Then EntityColor possible\shapehandle, 255, 255, 0 Else If possible\neighbours = 0 Then ;clickedmine = Reveal( chosenX, chosenY, chosenZ) clickedmine = Reveal( possible\x, possible\y, possible\z) Else EntityColor possible\shapehandle, 0, 255, 0 EndIf ; no neighbours EndIf ; doesnt have a mine EndIf ; found the clicked mine End Function ;=============================================================================================== Function Reveal(theX, theY, theZ) ;DebugLog "theX : " + theX + " theY : " + theY + " theZ : " + theZ Local thecube.GRIDPOSITION = LocateMine(theX, theY, theZ) If thecube\peeked = True Then Return False EndIf thecube\peeked = True If thecube\neighbours = 0 Then EntityColor thecube\shapehandle, 255, 0, 255 If theX > 0 Then Reveal (theX-1, theY, theZ) EndIf If theX < fieldsize-1 Then Reveal (theX+1, theY, theZ) EndIf If theY > 0 Then Reveal (theX, theY-1, theZ) EndIf If theY < fieldsize-1 Then Reveal (theX, theY+1, theZ) EndIf If theZ > 0 Then Reveal (theX, theY, theZ-1) EndIf If theZ < fieldsize-1 Then Reveal (theX, theY, theZ+1) EndIf EndIf ; check neighbours Return thecube\neighbours End Function ;===============================================================================================
and the type is...
;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Type GRIDPOSITION Field x Field y Field z Field hasmine Field isflagged Field iscleared Field shapehandle Field spinrate# Field neighbours Field peeked End Type ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Can anyone shed any light on what is going on here ? Is it a problem with using the same list of types with a recursive routine ?