include/utilities.h

Functions

Name
void print_play(play_t * play)prints the content of a play for debugging purposes
bool is_duplicate(play_t * play1, play_t * play2)tests if two plays are identical
bool validity_play(play_t * play, bool player)tests if a play is valid
tree_t * create_tree(play_t * play, int value, int depth)creats a tree
void free_tree(tree_t * tree)frees a tree
void append_tree(tree_t * tree, play_t * play, int value, int depth)adds a node to the linked list tree
void fill_play_buffer(play_t * play)fills the buffer of a play
void cell_belongs_to_player(board_t * board, tree_t * tree, play_t * play, cell_t * cell, bool * visited, bool player)part of the traversal_rec function, case where the following cell of a play belongs to the player
void cell_does_not_belongs_to_player(board_t * board, tree_t * tree, play_t * play, cell_t * cell, bool * visited, bool player)part of the traversal_rec function, case where the following cell of a play does not belong to the player
void traversal_rec(board_t * board, tree_t * tree, play_t * play, cell_t * cell, bool * visited, bool player)recursively generates plays
tree_t * gen_plays(board_t * board, int depth, bool player)generates all valid plays available given a board and a player

Functions Documentation

function print_play

void print_play(
    play_t * play
)

prints the content of a play for debugging purposes

function is_duplicate

bool is_duplicate(
    play_t * play1,
    play_t * play2
)

tests if two plays are identical

function validity_play

bool validity_play(
    play_t * play,
    bool player
)

tests if a play is valid

function create_tree

tree_t * create_tree(
    play_t * play,
    int value,
    int depth
)

creats a tree

function free_tree

void free_tree(
    tree_t * tree
)

frees a tree

function append_tree

void append_tree(
    tree_t * tree,
    play_t * play,
    int value,
    int depth
)

adds a node to the linked list tree

function fill_play_buffer

void fill_play_buffer(
    play_t * play
)

fills the buffer of a play

function cell_belongs_to_player

void cell_belongs_to_player(
    board_t * board,
    tree_t * tree,
    play_t * play,
    cell_t * cell,
    bool * visited,
    bool player
)

part of the traversal_rec function, case where the following cell of a play belongs to the player

function cell_does_not_belongs_to_player

void cell_does_not_belongs_to_player(
    board_t * board,
    tree_t * tree,
    play_t * play,
    cell_t * cell,
    bool * visited,
    bool player
)

part of the traversal_rec function, case where the following cell of a play does not belong to the player

function traversal_rec

void traversal_rec(
    board_t * board,
    tree_t * tree,
    play_t * play,
    cell_t * cell,
    bool * visited,
    bool player
)

recursively generates plays

function gen_plays

tree_t * gen_plays(
    board_t * board,
    int depth,
    bool player
)

generates all valid plays available given a board and a player

Source code

/* name : main.h
 * authors : eloi petit, matheo thomas, domitille vale
 * date : 18-06-24
 */

#ifndef UTILITIES_H
#define UTILITIES_H

#include "algos.h"
#include "init.h"


/* Functions definitions */

void print_play(play_t *play);

bool is_duplicate(play_t * play1, play_t * play2);

bool validity_play(play_t * play, bool player);

tree_t * create_tree(play_t * play, int value, int depth);

void free_tree(tree_t * tree);

void append_tree(tree_t * tree, play_t * play, int value, int depth);

void fill_play_buffer(play_t * play);

void cell_belongs_to_player(board_t * board, tree_t * tree, play_t * play, cell_t * cell, bool * visited, bool player);

void cell_does_not_belongs_to_player(board_t * board, tree_t * tree, play_t * play, cell_t * cell, bool * visited, bool player);

void traversal_rec(board_t * board, tree_t * tree, play_t * play, cell_t * cell, bool * visited, bool player);

tree_t * gen_plays(board_t * board, int depth, bool player);


#endif