Classes | Defines | Functions | Variables

path.c File Reference

#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>

Classes

struct  Coords
 A set of coordinates. More...

Defines

#define COLS   10
 The number of columns.
#define ROWS   10
 The number of rows.
#define START_X   0
 The starting X position.
#define START_Y   0
 The starting Y positoin.
#define ENABLE_CHECK   1
 Enables checking for blocked spaces.
#define DELTA_SIZE   8
 The number of legal moves.

Functions

int is_available (const int **table, struct Coords table_size, struct Coords pos)
 Determines the availability of a postion on the board.
int is_blocked (const int **table, struct Coords table_size, const struct Coords *delta, int delta_size, struct Coords pos)
 Determines whether or not a position on the board is boxed in.
int path_iter (int **table, struct Coords table_size, const struct Coords *delta, int delta_size, struct Coords pos, int moves, int *iter)
 An iteration of the pathfinder algorithm.
int path_find (int **table, struct Coords table_size, const struct Coords *delta, int delta_size, struct Coords pos, int *iter)
 Finds a path.
int main ()

Variables

struct Coords delta []
 The default set of legal moves.

Detailed Description

Author:
Jonathan Lamothe

Function Documentation

int is_available ( const int **  table,
struct Coords  table_size,
struct Coords  pos 
)

Determines the availability of a postion on the board.

Parameters:
table A pointer to the table of values.
table_size Indicates the size of the table.
pos The position being checked.
Returns:
1 if the position is available; 0 otherwise.
int is_blocked ( const int **  table,
struct Coords  table_size,
const struct Coords delta,
int  delta_size,
struct Coords  pos 
)

Determines whether or not a position on the board is boxed in.

Parameters:
table A pointer to the table of values.
table_size Indicates the size of the table.
delta A pointer to the list of legal moves.
delta_size The number of legal moves.
pos The position being checked.
Returns:
1 if the position is boxed in; 0 otherwise.
int path_find ( int **  table,
struct Coords  table_size,
const struct Coords delta,
int  delta_size,
struct Coords  pos,
int *  iter 
)

Finds a path.

Parameters:
table A pointer to the table of values.
table_size Indicates the size of the table.
delta A pointer to the list of legal moves.
delta_size The number of legal moves.
pos The initial position on the table.
iter A pointer to the iteration count (NULL if not available).
Returns:
1 if a path was found; 0 otherwise.
int path_iter ( int **  table,
struct Coords  table_size,
const struct Coords delta,
int  delta_size,
struct Coords  pos,
int  moves,
int *  iter 
)

An iteration of the pathfinder algorithm.

Parameters:
table A pointer to the table of values.
table_size Indicates the size of the table.
delta A pointer to the list of legal moves.
delta_size The number of legal moves.
pos The current position on the table.
moves The number of moves successfully completed.
iter A pointer to the iteration count (NULL if not available).
Returns:
1 if a path was found; 0 otherwise.

Variable Documentation

struct Coords delta[]
Initial value:
 {
  { 1, 2 },
  { 2, 1 },
  { -1, 2 },
  { -2, 1 },
  { 1, -2 },
  { 2, -1 },
  { -1, -2 },
  { -2, -1 }
}

The default set of legal moves.

 All Classes Files Functions Variables Defines