Just trying to get used to writing programs in C so have written this program to find valid Knights Tours on a 8x8 board. I guess my queries are more focused on my use of the language and how I could or should do things better. A little about the code. It is a C implementation based on something I wrote previously in python. It uses Warnsdoff's heuristic to try to find a knights tour on a 8x8 board. This rule follows that you should choose the square with the least available of successor squares as your next move. This is implemented by a non recursive function that loops until it can find no more successor nodes or the tour has reached the length of completion. Finding the successor nodes is achieved by the NodeSuccessor function which loops through possible moves defined in the array Deltas which is filtered by the already visited squares and the dimensions of the board. The SelectedNode function then pics optimal solution by counting the number of successors for each node then in case of a draw taking into account the distance from the center. Draws after this are dismissed as equally good and the first one to be assigned. In this case I have not incorporated backtracking and though I haven't tested it rigorously previous a previous implementation of similar design found a valid tour from any start position 99% of the time for any MxN board >= 6 where M and N are both even. But maybe to focus more on my use of the language C. Being used to more high level languages what could I be doing better here. Are my choice of data structures ok? Should I be doing anything different in the case of handling memory? - Here I have just set a fixed size for the VECTOR.nodes and PATH.Path lengths as i concluded that I don't want a path bigger than 64 and the available successor nodes can only go up to 8. I haven't utilised pointers at all, is there any need to in this case? I'm just trying to get a feel for the best practices. #include <stdio.h>#include <math.h>typedef struct { int x; int y; } VECTOR;typedef struct { VECTOR nodes[8]; int length; } NODE_LIST;typedef struct {    VECTOR path[64];    int pathLength;    int success;} PATH;const VECTOR Deltas[8] = {{-2, 1}, {-2,-1}, {-1,-2}, { 1,-2},  /* possible moves a knight  */                          { 2,-1}, { 2, 1}, { 1, 2}, {-1, 2}}; /* can make in vector space.*/PATH KnightsTour(VECTOR start);VECTOR SelectedNode(NODE_LIST nodelist, PATH tour);NODE_LIST NodeSuccessors(VECTOR node, PATH path);int NodeNotInPath(VECTOR node, PATH path);float EuclideanDistance(VECTOR node);int main(){    VECTOR start = {3,3};    PATH tour = KnightsTour(start);    if (tour.success)    {        printf(Success!\n);        for (int i = 0; i < tour.pathLength; i++)        {            printf([%d, %d], , tour.path[i].x,  tour.path[i].y);        }    }    else    {        printf(Failed! \n);    }    printf(\n%d \n, tour.pathLength);}PATH KnightsTour(VECTOR start){    /* takes start co-ordinates and try's to find a valid     tour else fails */    VECTOR node = start;    PATH tour;    tour.pathLength = 0;    tour.success = 0;    while (!tour.success)    {        tour.path[tour.pathLength] = node;        tour.pathLength++;        if (tour.pathLength >= 64)        {            tour.success = 1; /* found a tour; set exit condition */            continue;        }        NODE_LIST successors = NodeSuccessors(node, tour);        if (successors.length != 0)            node = SelectedNode(successors, tour);        else            break; /* failed to find a tour no valid successors */    }    return tour;}VECTOR SelectedNode(NODE_LIST nodelist, PATH tour){    /* Following Warnsdoff's rule this function searches for the      node that has the least number of successor nodes then incase of a     draw tries to tiebreak on distance from the center of the board     if this tiebreaks also the first added is selected.      */    int bestNode = 8; // max amount of possible successor nodes.    float currentFurthest = 0;    VECTOR selectedNode = {-1, -1}; // init incase of fail.    for (int n = 0; n < nodelist.length; n++)    {        int len = NodeSuccessors(nodelist.nodes[n], tour).length;        if (len <= bestNode)        {            if (len == bestNode){                int eucDist = EuclideanDistance(nodelist.nodes[n]);                if (eucDist > currentFurthest)                {                     bestNode = len;                    currentFurthest = eucDist;                    selectedNode = nodelist.nodes[n];                }            }            else            {                bestNode = len;                selectedNode = nodelist.nodes[n];            }        }    }    return selectedNode;}NODE_LIST NodeSuccessors(VECTOR node, PATH path){    /* Returns available move nodes from the current position. */    NODE_LIST successors;    int count = 0;    for (int i = 0; i < 8; i++)    {        VECTOR N = {node.x + Deltas[i].x, node.y + Deltas[i].y};        if ((N.x <  8) && (N.y <  8) &&            (N.x >= 0) && (N.y >= 0) && NodeNotInPath(N, path))        {            successors.nodes[count] = N;            count++;        }    }    successors.length = count;    return successors;}int NodeNotInPath(VECTOR node, PATH path){    /* Searches for a node a given path and returns 0 if found else 1 */    for (int i = 0; i < path.pathLength; i++)    {        if ((path.path[i].x == node.x) && (path.path[i].y == node.y))            return 0;    }    return 1;}float EuclideanDistance(VECTOR node) {    /* returns approx Euclidean distance^2 from the center of the board     basically the hypotenuse of a triangle */    float center = 7.0 / 2;    return (pow((node.x - center), 2) + pow((node.y - center), 2));}
Non-recursive Knights Tour implementation in C using Warnsdoff's rule
beginner;algorithm;c;chess