Japster
Member
Looking at this recursion thread, as I'm having a VERY strange recursion issue.... Our recursive routine always returns a string value, and this works fine in VM, but screws up (even when only running 1 iteration/level of recursion) using YYC. I literally check the values are strings just prior to calling itself, and once called, suddenly the returned value is no longer a string? - If anyone, maybe that genius @YellowAfterlife can help out with info or just plain something daft we're doing (we're currently leaning towards it being a YYC compiler or code creation issue, as out of ideas - assigned the value separately, performed the splice function outside of the call, remmed out chunks of code, but all to no avail!
We've even swapped around IDE versions and runtimes, just in case, but no joy...
The recursive routine (btw, 'state' is a string, initally passed in via the calling routine as "" / empty) is as follows:-
...and the debug output is:-
Again, any light shed on this with a view to resolving it would be most appreciated!
Thanks all!
Den / Japster
We've even swapped around IDE versions and runtimes, just in case, but no joy...
The recursive routine (btw, 'state' is a string, initally passed in via the calling routine as "" / empty) is as follows:-
Code:
/// GridSolver_SolveRecursive (solver,playableCoordinates,state,playablePieces,recDepth)
/// @param solver
/// @param playableCoordinates
/// @param state
/// @param playablePieces
/// @param recDepth
var solver = argument[0];
var playableCoordinates = argument[1];
var state = argument[2];
var playablePieces = argument[3];
var recDepth = argument[4];
//show_debug_message("state : "+state+".");
//show_debug_message("String Length : "+string(string_length(state)));
var randomPieces = Array_Shuffle(playablePieces);
if (string_length(state) >= (min(5,floor(Total_Tiles/4))))
return state;
//if (string_length(state) > floor(CurrentPlayableTileCount/4)){
// return state;
//}
var bestSolution = state;
var subSolution = "";
for (var shapeIndex = 0; shapeIndex < array_length_1d(randomPieces); shapeIndex++)
{
var shapeNumber = randomPieces[shapeIndex];
for (var coordinateIndex = 0; coordinateIndex < array_length_1d(playableCoordinates); coordinateIndex++)
{
var coordData = playableCoordinates[coordinateIndex];
var xx = coordData[Coordinate_PROPS_X];
var yy = coordData[Coordinate_PROPS_Y];
for (var rotation = 0; rotation < UniqueRotations[shapeNumber]; rotation++)
{
var shapeData = ShapeData_Create(shapeNumber,rotation);
var offsetPieceCoordinates = ShapeData_GetOffsetCoordinates(shapeData,xx,yy);
if GridSolver_CellsAreAvailable(solver,offsetPieceCoordinates)
{
GridSolver_SetCellsAvailability(solver,offsetPieceCoordinates,false);
var t_state = state + string(shapeNumber);
show_debug_message("1 state is string : "+string(is_string(state)));
show_debug_message("1 argument is string : "+string(is_string(state+string(shapeNumber))));
show_debug_message("1 subSolution is string : "+string(is_string(subSolution)));
show_debug_message("1 bestSolution is string : "+string(is_string(bestSolution)));
var t_result = GridSolver_SolveRecursive(
solver,
Array_Splice(playableCoordinates,coordinateIndex,1),
state + string(shapeNumber),
playablePieces,
recDepth+1);
var subSolution = t_result;
show_debug_message("2 state is string : "+string(is_string(state)));
show_debug_message("2 argument is string : "+string(is_string(state+string(shapeNumber))));
show_debug_message("2 subSolution is string : "+string(is_string(subSolution)));
show_debug_message("2 bestSolution is string : "+string(is_string(bestSolution)));
GridSolver_SetCellsAvailability(solver,offsetPieceCoordinates,true);
show_debug_message("3 state is string : "+string(is_string(state)));
show_debug_message("3 argument is string : "+string(is_string(state+string(shapeNumber))));
show_debug_message("3 subSolution is string : "+string(is_string(subSolution)));
show_debug_message("3 bestSolution is string : "+string(is_string(bestSolution)));
if (string_length(subSolution) > string_length(bestSolution))
{
bestSolution = subSolution;
if (string_length(bestSolution) >= (min(5,floor(Total_Tiles/4))))
{
return bestSolution;
}
}
}
}
}
}
return bestSolution;
Code:
Total memory used = 34236847(0x020a69af) bytes
**********************************.
Entering main loop.
**********************************.
Received stats and achievements from Steam
Resizing swap chain...Resizing window...
state : .
String Length : 0
1 state is string : 1
1 argument is string : 1
1 subSolution is string : 1
1 bestSolution is string : 1
state : 3.
String Length : 1
1 state is string : 1
1 argument is string : 1
1 subSolution is string : 1
1 bestSolution is string : 1
state : 32.
String Length : 2
2 state is string : 1
2 argument is string : 1
2 subSolution is string : 0
2 bestSolution is string : 1
3 state is string : 1
3 argument is string : 1
3 subSolution is string : 0
3 bestSolution is string : 1
ERROR!!! :: ############################################################################################
FATAL ERROR in
action number 1
of Mouse Event for Left Pressed
for object Steam_Set:
string_length argument 1 incorrect type (undefined) expecting a String (YYGS)
############################################################################################
--------------------------------------------------------------------------------------------
called from - gml_Script_GridSolver_SolveRecursive (line 75)
called from - gml_Script_GridSolver_SolveRecursive (line 55)
called from - gml_Script_GridSolver_Solve (line 12)
called from - gml_Object_Steam_Set_Mouse_4 (line 27)
Again, any light shed on this with a view to resolving it would be most appreciated!
Thanks all!
Den / Japster
Last edited: