8 Puzzle Code Example Share

CORE SOURCE CODE solving 8 Puzzle AI problems written in MS Visual MFC C++.

COMPLETE Full set of working SOURCE CODE for the working MFC C++ program, SPEED UP your learning process,
just 4.99 USD. Email / Paypal to ahyeek@gmail.com

Full working program can be downloaded to TRY out: AI 8-puzzle (8 Puzzle) solver

Thursday, October 22, 2009

Full working source code in C# WPF Version of 8 Puzzle Solver

Full working source code in C# WPF Version of 8 Puzzle now also available!
Paypal 4.99usd to ahyeek@gmail.com to get the package.

Friday, May 9, 2008

8 Puzzle Code - TreeNode.h

First of all, we create a TreeNode class for storing puzzle state. Below is the code store in TreeNode.h.

#ifndef _TREENODE_H
#define _TREENODE_H

#define SIZE 9
class TreeNode{
public:
UINT fn, gn, hn; //For A* algorithm use.
UINT h; //Heuristic value.
char state[SIZE]; //Current puzzle state.

TreeNode* parent;
TreeNode* child1;
TreeNode* child2;
TreeNode* child3;
TreeNode* child4;

TreeNode(){
parent=NULL;
child1=NULL;
child2=NULL;
child3=NULL;
child4=NULL;
}

void setState(char *p){
for(int v=0; v<SIZE; v++) state[v]=*(p+v);
}
};
#endif