Beispiel #1
0
int32 processAStarPath(neighbourList* f_aStarPathList_pst)
{
	int32 moveResult_i32 = 0x00;

	if(!isNeighbourListEmpty(f_aStarPathList_pst))
	{
		neighbourListNode* nextMove_pst = NULL;

		neighbourListNode* neighbour_pst = f_aStarPathList_pst->head;

		for (; neighbour_pst != NULL; neighbour_pst = nextMove_pst)
		{
			nextMove_pst = neighbour_pst->next;

			node* moveNode_pst = neighbour_pst ->neighbourNode_pst;

			coordinates moveNodeCoord_st =  getNodeCoordinates(moveNode_pst);

			moveResult_i32 = Robot_Move(moveNodeCoord_st.x_Coordinate_i32, moveNodeCoord_st.y_Coordinate_i32);

			if (ROBOT_FAIL == moveResult_i32)
			{
				return moveResult_i32;
			}
		}
	}

	return moveResult_i32;
}
Beispiel #2
0
short findWay(short nodes[][3]){
	printf("FIND WAY\n");
	short x = position[0];
	short y = position[1];
	short r, i;
	i = 0;
	r = rand() % 4;

	for (i=0;i<4;i++){
		if ((nodes[r][0] != 0 || nodes[r][1] != 0) && nodes[r][2] != 1){
			if (Robot_Move(x + nodes[r][0], y + nodes[r][1]) == 2){
					tokenCount++;//Move! :-D
				}
				position[0] = x + nodes[r][0];
				position[1] = y + nodes[r][1];
				if (tokenCount == 3){
					map[x][y + 6][1] = 2;
				}
				printf("position= %d;%d\n", position[0],position[1]);
				return 0;
		}
		r = (r + 1) %4;
	}

	/*if(((nodes[0][2] == 1 && nodes[1][2] == 1) && nodes[2][2] ==1) && nodes[3][2] ==1){
		return 1;
	} else if(nodes[0][0] != 0 && nodes[0][2] != 1){ //Existiert dieser?
		Robot_Move(x + nodes[0][0], y + nodes[0][1]);//Move! :-D
		position[0] = x + nodes[0][0];
		position[1] = y + nodes[0][1];
		printf("position= %d;%d\n", position[0],position[1]);
		return 0;
	} else if(nodes[1][1] != 0 && nodes[1][2] != 1){ //Existiert dieser?
		Robot_Move(x + nodes[1][0], y + nodes[1][1]);//Move! :-D
		position[0] = x + nodes[1][0];
		position[1] = y + nodes[1][1];
		printf("position= %d;%d\n", position[0],position[1]);
		return 0;
	} else if(nodes[2][0] && nodes[2][2] != 1){ //Existiert dieser?
		Robot_Move(x + nodes[2][0], y + nodes[2][1]);//Move! :-D
		position[0] = x + nodes[2][0];
		position[1] = y + nodes[2][1];
		printf("position= %d;%d\n", position[0],position[1]);
		return 0;
	} else if(nodes[3][1] != 0 && nodes[3][2] != 1){ //Existiert dieser?
		Robot_Move(x + nodes[3][0], y + nodes[3][1]);//Move! :-D
		position[0] = x + nodes[3][0];
		position[1] = y + nodes[3][1];
		printf("position= %d;%d\n", position[0],position[1]);
		return 0;
	}*/
	printf("RETURN 1\n");
	return 1;
}