docs: add comments

This commit is contained in:
snsd0805 2023-05-23 23:26:03 +08:00
parent 0451f068de
commit f0c16c48a7
Signed by: snsd0805
GPG Key ID: 569349933C77A854

25
main.c
View File

@ -7,13 +7,25 @@ void reset(short* board){
Reset the game, clear the chessboard. Reset the game, clear the chessboard.
Args: Args:
- short *board (array's address): chessboard's status
Results:
- None, set all blocks on the chessboard to zero.
*/ */
for (short i=0; i<9; i++) for (short i=0; i<9; i++)
board[i] = 0; board[i] = 0;
} }
void show(short *board){ void show(short *board){
/*
Print the chessboard on the console.
Args:
- short *board (array's address): chessboard's status
Results:
- None. Only printing.
*/
short loc; short loc;
printf("┼───┼───┼───┼\n"); printf("┼───┼───┼───┼\n");
for (short i=0; i<3; i++){ for (short i=0; i<3; i++){
@ -34,6 +46,17 @@ void show(short *board){
} }
void get_available_actions(short *board, short *result, short *length){ void get_available_actions(short *board, short *result, short *length){
/*
Save all available actions into the "result" array.
Args:
- short *board (array's address): chessboard's status
- short *result (array's address): To save all available actions.
- short *length (integer's pointer): To save the number of available actions.
Results:
- None. All available actions are saved into "result" and the number of actions is saved in "length"
*/
short index = 0; short index = 0;
for (int i=0; i<9; i++) for (int i=0; i<9; i++)
if (board[i] == 0) if (board[i] == 0)