1.设置一个活动的block,从红方块出发,随机寻找兰方块,直到找到位置才停止.
2. 部分代码
#include "tree.h"
#include "global.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
struct Tree_Node
{
NODE_ID id;
POS pos;
short status;
TREE_NODE *left_node;
TREE_NODE *right_node;
TREE_NODE *up_node;
TREE_NODE *below_node;
};
TREE_NODE * new_node()
{
TREE_NODE *t;
t=(TREE_NODE *)malloc(sizeof(TREE_NODE));
t->below_node=NULL;
t->left_node=NULL;
t->right_node=NULL;
t->up_node=NULL;
return t;
}
void create_tree()
{
TREE_NODE *t;
for(int i=0; i<N; i++)
for(int j=0; j<M; j++)
{
t=new_node();
t->pos.i=i;
t->pos.j=j;
t->id=getID(i,j); //maping the code from MAP[][] to tree_ node[][]
tree_node[i]