static void CopyObject1(Node1 Obj1, Node1 Obj2) { Obj1.OwnIndex = Obj2.OwnIndex; Obj1.ParentIndex = Obj2.ParentIndex; for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { Obj1.State[i][j] = Obj2.State[i][j]; } } Obj1.BlankXcoordinate = Obj2.BlankXcoordinate; Obj1.BlankYcoordinate = Obj2.BlankYcoordinate; Obj1.Direction = Obj2.Direction; Obj1.Child1Index = Obj2.Child1Index; Obj1.Child2Index = Obj2.Child2Index; Obj1.Child3Index = Obj2.Child3Index; Obj1.Child4Index = Obj2.Child4Index; }
static int CreateChildNodes1(Node1[] Array, Node1 Parent, Node1 Goal, int NextIndex) { int Index = NextIndex; if (CheckUpDirection1(Parent)) { Array[Index] = new Node1( Parent.State, Parent.BlankXcoordinate, Parent.BlankYcoordinate, Index, Parent.OwnIndex, 'U'); ExchangeUp1(Array[Index]); Array[Index].BlankXcoordinate--; boolean cond = CompareNodes1(Array[Index], Array[Parent.ParentIndex]); if (cond == false) { Array[Index] = null; // --Index; } else { PrintNode1(Array[Index]); Parent.Child1Index = Index; ++Index; } } if (CheckDownDirectionDirection1(Parent)) { Array[Index] = new Node1( Parent.State, Parent.BlankXcoordinate, Parent.BlankYcoordinate, Index, Parent.OwnIndex, 'D'); ExchangeDown1(Array[Index]); Array[Index].BlankXcoordinate++; boolean cond = CompareNodes1(Array[Index], Array[Parent.ParentIndex]); if (cond == false) { Array[Index] = null; // --Index; } else { PrintNode1(Array[Index]); Parent.Child2Index = Index; ++Index; } } if (CheckRightDirection1(Parent)) { Array[Index] = new Node1( Parent.State, Parent.BlankXcoordinate, Parent.BlankYcoordinate, Index, Parent.OwnIndex, 'R'); ExchangeRight1(Array[Index]); Array[Index].BlankYcoordinate++; boolean cond = CompareNodes1(Array[Index], Array[Parent.ParentIndex]); if (cond == false) { Array[Index] = null; // --Index; } else { PrintNode1(Array[Index]); Parent.Child3Index = Index; ++Index; } } if (CheckLeftDirection1(Parent)) { Array[Index] = new Node1( Parent.State, Parent.BlankXcoordinate, Parent.BlankYcoordinate, Index, Parent.OwnIndex, 'L'); ExchangeLeft1(Array[Index]); Array[Index].BlankYcoordinate--; boolean cond = CompareNodes1(Array[Index], Array[Parent.ParentIndex]); if (cond == false) { Array[Index] = null; // --Index; } else { PrintNode1(Array[Index]); Parent.Child4Index = Index; ++Index; } } return Index; }