Implement board state read functions
This commit is contained in:
parent
74b5b87771
commit
5563d3d615
46
board.c
46
board.c
@ -87,3 +87,49 @@ board_unmark (
|
||||
elem->potential &= (1 << value) ^ 0x1FF;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
board_has_value (
|
||||
struct board *board,
|
||||
board_pos x,
|
||||
board_pos y
|
||||
)
|
||||
{
|
||||
if (is_in_bounds (x, y))
|
||||
{
|
||||
return BOARD_ELEM (board, x, y)->has_value;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
element_value
|
||||
board_get_value (
|
||||
struct board *board,
|
||||
board_pos x,
|
||||
board_pos y
|
||||
)
|
||||
{
|
||||
if (is_in_bounds (x, y))
|
||||
{
|
||||
return BOARD_ELEM (board, x, y)->value;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
board_is_marked (
|
||||
struct board *board,
|
||||
board_pos x,
|
||||
board_pos y,
|
||||
element_value value
|
||||
)
|
||||
{
|
||||
if (is_in_bounds (x, y) && is_valid_value (value))
|
||||
{
|
||||
return BOARD_ELEM (board, x, y)->potential & (1 << value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
38
board.h
38
board.h
@ -83,3 +83,41 @@ board_unmark (
|
||||
board_pos y,
|
||||
element_value value
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Get whether or not an element has a decided value
|
||||
*/
|
||||
bool
|
||||
board_has_value (
|
||||
struct board *board,
|
||||
board_pos x,
|
||||
board_pos y
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Get definite value of a board element
|
||||
*
|
||||
* NOTE: Getting the definite value of an element without a value is undefined
|
||||
*/
|
||||
element_value
|
||||
board_get_value (
|
||||
struct board *board,
|
||||
board_pos x,
|
||||
board_pos y
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* Get whether or not a board element is marked with a particular value
|
||||
*
|
||||
* NOTE: Getting the mark state of an element with a value is undefined
|
||||
*/
|
||||
bool
|
||||
board_is_marked (
|
||||
struct board *board,
|
||||
board_pos x,
|
||||
board_pos y,
|
||||
element_value value
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user