コード例 #1
0
ファイル: solver_3.go プロジェクト: 42MrPiou42/N-puzzle
func (Svr *Solver) Move_right() {
	nRelative := (Svr.closeList.Back()).Value.(*Node)

	if nRelative.status == LEFT {
		return
	}
	nNode := new(Node)
	nNode.StateBoard = Get_StateBoard(Svr.nbrRow)
	nNode.status = RIGHT
	i, j := manhattan_3.Get_positionValue(nRelative.StateBoard, 0, Svr.nbrRow)
	if j == Svr.nbrRow-1 {
		return
	}
	Copy_Tab(nNode.StateBoard, nRelative.StateBoard, Svr.nbrRow)
	nNode.StateBoard[i][j] = nRelative.StateBoard[i][j+1]
	nNode.StateBoard[i][j+1] = 0
	Svr.AddNode(nNode, nRelative)
}
コード例 #2
0
ファイル: solver_3.go プロジェクト: 42MrPiou42/N-puzzle
func (Svr *Solver) Move_top() {
	nRelative := (Svr.closeList.Back()).Value.(*Node)

	if nRelative.status == BOTTOM {
		return
	}
	nNode := new(Node)
	nNode.StateBoard = Get_StateBoard(Svr.nbrRow)
	nNode.status = TOP
	i, j := manhattan_3.Get_positionValue(nRelative.StateBoard, 0, Svr.nbrRow)
	if i == 0 {
		return
	}
	Copy_Tab(nNode.StateBoard, nRelative.StateBoard, Svr.nbrRow)
	nNode.StateBoard[i][j] = nRelative.StateBoard[i-1][j]
	nNode.StateBoard[i-1][j] = 0
	Svr.AddNode(nNode, nRelative)
}