aboutsummaryrefslogtreecommitdiff
path: root/voerbak/win.h
blob: ec816b0ff8e6dd9f353d18974802d90a5a7b6a9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#pragma once
#include <stdbool.h>

#include "voerbak.h"
#include "board.h"

/**
 * @brief Get length of longest streak with same color from `pos` in direction `direction`
 *
 * @param b Board to check
 * @param pos Position to check win position from (position of last dropped disc)
 * @param direction Direction offset to step forward to
 * @param d_index Index of direction in directions array (defined in `checkWin()`)
 * @param currentLength Current length of same color 'streak'
 *
 * @return Length of longest streak with same color from `pos` in direction `direction`
 */
int winCheckRecursive(Board*, int, int, int, int);

/**
 * @brief Check for winning position from position `pos`
 *
 * @param b Board to check
 * @param pos Position to check win position from (position of last dropped disc)
 *
 * @return `true` if game was won by the color that's in `b->board[pos]`
 */
bool checkWin(Board*, int);