資源簡介
八數碼 C實現。A*,逆轉棋子,棋子與目標局不符總數,棋子移動到目標局所需步數總數等等
代碼片段和文件信息
#include?
#include?
#include?
#include?
void?Copy_node(struct?node?*p1struct?node?*p2);
void?Calculate_f(int?deepthstruct?node?*pint?way);
void?Add_to_open(struct?node?*p);
void?Add_to_closed(struct?node?*p);
void?Remove_p(struct?node?*namestruct?node?*p);
int?Test_A_B(struct?node?*p1struct?node?*p2);
struct?node?*?Solution_Astar(struct?node?*pint?way);
void?Expand_n(struct?node?*pint?way);
struct?node?*?Search_A(struct?node?*namestruct?node?*temp);
void?Print_result(struct?node?*p);
/*?定義8數碼的節點狀態?*/
typedef?struct?node
{
??int?s[3][3];?//當前8數碼的狀態
??int?i_0;???//當前空格所在行號
??int?j_0;???//當前空格所在列號
??int?f;?????//當前代價值
??int?d;?????//當前節點深度
??int?h;?????//啟發信息,采用數碼“不在位”距離和
??struct?node?*father;?//指向解路徑上該節點的父節點
??struct?no
評論
共有 條評論