Realization of guessing numbers, backgammon and minesweeping games in c language

foreword

When we have learned the c language to a certain extent, have you ever thought about what else to do besides brushing the questions? Of course, the Internet information is very developed now, and I have seen more people who have a certain interest in games! We usually play games developed by others, so have we ever thought that one day we will be able to develop some small games written by our own programming? Compared with if you can write it yourself, you will definitely feel that you have a little sense of accomplishment, hahahahaha, yes, I just learned that I can't help but want to share these small games with you.

1. Guess the number game

The implementation of this game is actually relatively simple, as long as you have a clear understanding of the cycle, you can get started.
First of all, let's make a game menu similar to the following code:
insert image description here
the implementation code is:

void menu() {
    
    
	printf("******************\n");
	printf("**1.play  0.exit**\n");
	printf("******************\n");
}

Because this menu needs to pop up when you run it, so we call our menu function menu() in the main function here. In addition to the menu, we need to determine whether to play the game or exit the game through the player's choice, so we A switch is used here to select the corresponding next operation by inputting a number, and this operation process does not say that it only plays once, so we use a loop, that is, a do while statement, because you need to make a choice as soon as you enter the menu .
The effect achieved is:
insert image description here
insert image description here

The implementation code is as follows:

int main() {
    
    
	int input = 0;
	srand((unsigned int)time(NULL));
	do
	{
    
    
		menu();
		printf("请选择>:\n");
		scanf("%d", &input);
		switch (input)
		{
    
    
		case 1:
			game();
			break;
		case 0:
			printf("退出游戏\n");
			break;
		default:
			printf("选择错误\n");
			break;

		}
	} while (input);

		return 0;
}

The next step is to realize the content of the game. Here we will make a number guessing game from 1 to 100, which will not be too difficult. In the above code, we saw a srand((unsigned int)time(NULL)); Does it feel a little strange, it doesn't matter, to realize our game, we need to use a random number, and in order to get a random Number, here we think of a timestamp to achieve the purpose of generating random numbers.
insert image description here
This is a usage of rand to generate random numbers.
Let’s take a look at an effect we want to achieve. The process of the game
insert image description here
achieves such an effect, which is your guess After a number, it will prompt you to compare the size of the number you want to guess with the number you entered to achieve a narrowing effect, thereby increasing the probability of guessing.
The implementation code of the game content is as follows:

void game() {
    
    
	int ret = 0;
	int guess = 0;
	ret = rand() % 100 + 1;
	while (1) {
    
    
		printf("请猜数字:>");
		scanf("%d", &guess);
		if (guess > ret) {
    
    
			printf("猜大了\n");
		
		}
		else if (guess<ret) {
    
    
			printf("猜小了\n");

		}
		else
		{
    
    
			printf("恭喜你,猜对了!\n");
			break;
		}
	}

2. Backgammon

Like the previous game, start writing from the menu function.
insert image description hereChoose 0 to exit, choose 1 to start playing the game.
insert image description here
insert image description here
Here I created two .c files (test.c and game.c), and a .h header file (game.h) to declare the functions that need to be used
.
1. First create a 3*3 two-dimensional array to store data;
2. Then we start to analyze the chessboard. To achieve the same effect as above, we can analyze the chessboard. First, initialize the chessboard and give each element of the two-dimensional array Set it as a space, the purpose is to occupy the position, and then replace it with other chess pieces when you need to play chess later;
3. After the chessboard is initialized successfully, we need to implement the function of the chess player's operation. We specially pass A function for a player to play chess is implemented, and the chess board is printed after the player plays chess;
4. After the player function is successfully implemented, we also implement a function for the computer to play chess. We use the random number rand again for the computer to play chess. The purpose of using it is to let the computer randomly generate the coordinates (effective coordinates) on a chessboard, and then place the chess pieces at the specified position, and then print the chessboard again; 5. The last step is that the player and the computer play chess
. To judge winning or losing, so we are finally implementing a function to judge winning or losing

test.c

#include"game.h"

void game()
{
    
    
	//需要一个3*3的二维数组存放数据
	char board[3][3] = {
    
     0 };
	//初始化棋盘
	InitBoard(board,ROW,COL);
	//打印棋盘
	DisplayBoard(board, ROW, COL);
	char ret = 0;
	while (1)
	{
    
    
			//玩家下棋
			PlayerMove(board, ROW, COL);
			// 打印棋盘
			DisplayBoard(board, ROW, COL);
			// 判断输赢
			ret = IsWin(board, ROW, COL);
			if (ret != 'C')
			{
    
    
				break;
			}
			//电脑下棋
			ComputerMove(board, ROW, COL);
			//打印棋盘
			DisplayBoard(board, ROW, COL);
			//判断输赢
			IsWin(board, ROW, COL);
			ret = IsWin(board, ROW, COL);
			if (ret != 'C')
			{
    
    
				break;
			}
		}
		
        if (ret == '*')
		{
    
    
		printf("恭喜你获胜啦!\n");
		
		}
	else if (ret == '#')
		{
    
    
		printf("电脑获胜\n");
		}
	else
		{
    
    
		printf("平局\n");
		}

}
void menu()
{
    
    
	printf("**************************\n");
	printf("********* 1.play *********\n");
	printf("********* 0.exit *********\n");
	printf("**************************\n");
}


int main()
{
    
    
	srand((unsigned int)time(NULL));
	int input = 0;
	do {
    
    
		menu();
		printf("请选择:>");
		scanf("%d", &input);
		switch (input)
		{
    
    
		case 1:
			game();
			break;
		case 0:
			printf("退出游戏!");
			break;
		default:
			printf("选择错误,请重新输入!");
			break;
		}
	} while (input);
	return 0;
}

game.h

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#define ROW 3
#define COL 3

//初始化棋盘
void InitBoard(char board[ROW][COL], int row, int col);
//打印棋盘
void DisplayBoard(char board[ROW][COL], int row, int col);
//玩家下棋
void PlayerMove(char board[ROW][COL], int row, int col);
//电脑下棋
void ComputerMove(char board[ROW][COL], int row, int col);
//判断输赢
char IsWin(char board[ROW][COL], int row, int col);

game.c

#include"game.h"
//头文件中对应的函数实现
void InitBoard(char board[ROW][COL], int row, int col)
{
    
    
	int i = 0;
	for (i = 0; i < row; i++)
	{
    
    
		int j = 0;
		for (j = 0; j < col; j++)
		{
    
    
			board[i][j] = ' ';
		}
	}
	//memset(&board[0][0], " ", row * col * sizeof(board[0][0]));
}

void DisplayBoard(char board[ROW][COL], int row, int col)
{
    
    
	int i = 0;
	int j = 0;
	for (i = 0; i < row; i++)
	{
    
    
		int j = 0;
		for (j = 0; j < col; j++)
		{
    
    
			printf(" %c ", board[i][j]);
			if (j < col - 1)
			{
    
    
				printf("|");
			}
		}
		printf("\n");
		if (i < row - 1)
		{
    
     
			int j = 0;
			for (j = 0; j <col ; j++)
			{
    
    
				printf("---");
				if (j < col - 1)
				{
    
    
					printf("|");
				}
			}

			
		}
		printf("\n");
	}
}

 void PlayerMove(char board[ROW][COL], int row, int col)
{
    
    
	int x = 0;
	int y = 0;
	printf("玩家下棋:>\n");
	while (1)
	{
    
    
		
		printf("请输入坐标:");
		scanf("%d %d", &x, &y);
		if ((x >= 1 && x <= row) && (y >= 1 && y <= col) )	
		{
    
    
			if (board[x - 1][y - 1] == ' ')
			{
    
    
				board[x - 1][y - 1] = '*';
				break;
			}
			else
				printf("该坐标已经被占用,请重新输入\n");
		}
		else
		{
    
    
			printf("非法坐标,请重新输入\n");
		}
		
	}
}

 void ComputerMove(char board[ROW][COL], int row, int col)
 {
    
    
	 int x = 0;
	 int y = 0;
	 printf("电脑下棋:>\n");
	 while (1)
	 {
    
    
		 x = rand() % 3; 
		 y = rand() % 3;
		 if (board[x][y] == ' ')
		 {
    
    
			 board[x][y] = '#';
			 break;
		 }
	 }

 }


 char IsWin(char board[ROW][COL],int row,int col)
 {
    
    
	 int i = 0;
	 for (i = 0; i < row; i++)
	 {
    
    
		 if (board[i][0] == board[i][1] && board[i][1] == board[i][2] && board[i][0] != ' ')
		 {
    
    
			 return board[i][0];
		 }
	 }
	 for (i = 0; i < col; i++)
	 {
    
    
		 if (board[0][i] == board[1][i] && board[1][i] == board[2][i] && board[1][i] != ' ')
		 {
    
    
			 return board[1][i];
		 }
	 }
	 if (board[0][0] == board[1][1] && board[1][1] == board[2][2] && board[0][0] != ' ')
	 {
    
    
		 return board[0][0];
	 }
	 if (board[0][2] == board[1][1] && board[2][0] == board[1][1] && board[1][1] != ' ')
	 {
    
    
		 return board[1][1];
	 }
	
	 for (i = 0; i < row; i++)
	 {
    
    
		 int j = 0;
		 for (j = 0; j < col; j++)
		 {
    
    
			 if (board[i][j] == ' ')
			 {
    
    
				 return 'C';
			 }
		 }
	 }
	 return 'Q';

	
 }

The game of backgammon is realized

3. Minesweeper

Everyone must know how to play minesweeper, so you should be familiar with the rules of the game. The previous writing here is a bit similar to the above-mentioned backgammon, that is, the game rules achieve different effects
:
insert image description here
insert image description here

1. In this game, we also start by laying out the chessboard. We have created two 11 11 chessboards here, one for mine clearance and one for mine burying. The coordinates of 9 9 are valid, and there are many outside The displayed position is used to display the coordinates, which is convenient for players to find the designated position that needs to be cleared.
2. We also need to have a function to initialize the mine-clearing board and a function to initialize the mine-burying board.
3. We also need a function to print the board. Every time we check the board, we need to print the board. Print out Lei’s chessboard to let him know where mines are buried.
4. Finally, we need a function to arrange mines. We need to use random numbers here, so we need to use rand. The usage has been given to everyone earlier. I found it, so I won’t go into details.
Code arrangement:
test.c

#include"game.h"



void menu()
{
    
    
	printf("**************************\n");
	printf("******* 0.退出游戏 *******\n");
	printf("******* 1.扫雷游戏 *******\n");
	printf("**************************\n");
}

void game()
{
    
    
	//建立两个数组分别存放数据
	char mine[ROWS][COLS] = {
    
     0 };//用来存放布置雷的信息的数组
	char show[ROWS][COLS] = {
    
     0 };//用来存放排查雷的信息的数组
	//初始化排查雷的棋盘
	InitBoard(mine, ROWS, COLS,'0');
	//初始化布置雷的棋盘
	InitBoard(show, ROWS, COLS, '*');
	//打印棋盘
	PrintBoard(show, ROW, COL);
	//布置雷
	SetMine(mine, ROW, COL);
	PrintBoard(mine, ROW, COL);

	//排雷
	RemoveMine(mine,show,ROW,COL);

}
int main()
{
    
    

	srand((unsigned int)time(NULL));
	int input = 0;
	do
	{
    
    
		menu();
		printf("请选择:>");
		scanf("%d", &input);
		switch (input)
		{
    
    
		case 0:
			printf("退出游戏!\n");
			break;
		case 1:
			game();
			break;
		default:
			printf("选择错误,请重新输入!\n");
		}
	}while (input);
	return 0;
}

game.h

#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define ROW  9
#define COL 9
#define ROWS ROW+2
#define COLS COL+2
#define EASY_COUNT 10
//初始化排雷界面
void InitBoard(char arr[ROWS][COLS], int rows, int cols,char set);

//打印棋盘
void PrintBoard(char arr[ROWS][COLS], int row, int col);

//布置雷
void SetMine(char arr[ROWS][COLS], int row, int col);
//排查雷
void RemoveMine(char mine[ROWS][COLS],char show[ROWS][COLS],  int row, int col);

game.c

#define _CRT_SECURE_NO_WARNINGS 1
#include"game.h"

void InitBoard(char arr[ROWS][COLS], int rows, int cols,char set)
{
    
    
	int i = 0;
	int j = 0;
	for (i = 0; i < rows; i++)
	{
    
    
		int j = 0;
		for (j = 0; j < cols; j++)
		{
    
    
			arr[i][j] = set;
		}
	}
}

void PrintBoard(char arr[ROWS][COLS], int row, int col)
{
    
    
	int i = 0;
	int j = 0;
	printf("******* 排雷 *******\n");
	for (i = 0; i <= col; i++)
	{
    
    
		printf("%d ", i);
	}
	printf("\n");
	for (i = 1; i <= row; i++)
	{
    
    
		printf("%d ", i);
		for (j = 1; j <= col; j++)
		{
    
    
			printf("%c ", arr[i][j]);
		}
		printf("\n");
	}
	
}

void SetMine(char arr[ROWS][COLS], int row, int col)
{
    
    
	int count = EASY_COUNT;
	while (count)
	{
    
    
		int x = rand() % row + 1;
		int y = rand() % col + 1;
		if (arr[x][y] == '0')
		{
    
    
			arr[x][y] = '1';
			count--;
		}
	}

}

//统计雷的个数
int MineCount(char mine[ROWS][COLS], int x, int y)
{
    
    
	return (mine[x - 1][y - 1] + mine[x - 1][y] +
		mine[x - 1][y + 1] + mine[x][y - 1] +
		mine[x + 1][y - 1] + mine[x + 1][y] +
		mine[x + 1][y + 1] + mine[x][y + 1] - 8 * '0');
}
void RemoveMine(char mine[ROWS][COLS],char show[ROWS][COLS], int row, int col)
{
    
    
	int x = 0;
	int y = 0;
	int safe = 0;
	while (safe<row*col-EASY_COUNT)
	{
    
    
		printf("请输入你要排查的坐标:>");
		scanf("%d %d", &x, &y);
		if (x >= 1 && x <= row && y >= 1 && y <= col)
		{
    
    
			if (show[x][y] == '*')
			{
    
    
				if (mine[x][y] == '1')
				{
    
    
					printf("很遗憾,你被炸死\n");
					PrintBoard(mine, ROW, COL);
					break;
				}
				else
				{
    
    
					//如果该坐标不是雷,就要统计该坐标周围有几个雷
					int count = MineCount(mine, x, y);
					show[x][y] = count + '0';
					PrintBoard(show, ROW, COL);
					safe++;
				}

			}
			else
			{
    
    
				printf("该坐标已经排查,请重新输入!\n");
			}
		}
		else
		{
    
    
			printf("你输入的坐标非法,请重新输入!\n");
		}
	}


}

Three tours in one

Through the implementation of the above three games, we found a lot of reality, so on the premise of understanding how to write each game, I integrated the above three games into one project, and then put the three games separately. Go inside the menu.

The menu becomes like this:
insert image description here

Well, arrange the code directly:
test.c

#include<stdio.h>
#include"game2.h"
#include"game3.h"
void menu()
{
    
    
	printf("**************************\n");
	printf("******* 1.猜数字   *******\n");
	printf("******* 2.三子棋   *******\n");
	printf("******* 3.扫雷     *******\n");
	printf("******* 0.退出游戏 *******\n");
	printf("**************************\n");
}

void game1()
{
    
    
	int num = 0;
	int ret = rand() % 100 + 1;//得到一个1-100的随机数 
	while (1)
	{
    
    
		printf("请猜该数字:>");
		scanf("%d", &num);
		if (num > ret)
		{
    
    
			printf("猜大了!\n");
		}
		else if (num < ret)
		{
    
    
			printf("猜小了!\n");
		}
		else
		{
    
    
			printf("恭喜你!猜对了!\n");
			break;
		}
	}

}
void game2()
{
    
    
	//需要一个3*3的二维数组存放数据
	char board[3][3] = {
    
     0 };
	//初始化棋盘
	initBoard(board,Row,Col);
	//打印棋盘
	DisplayBoard(board, Row, Col);
	char ret = 0;
	while (1)
	{
    
    
		//玩家下棋
		PlayerMove(board, Row, Col);
		// 打印棋盘
		DisplayBoard(board, Row, Col);
		// 判断输赢
		ret = IsWin(board, Row, Col);
		if (ret != 'C')
		{
    
    
			break;
		}
		//电脑下棋
		ComputerMove(board, Row, Col);
		//打印棋盘
		DisplayBoard(board, Row, Col);
		//判断输赢
		IsWin(board, Row, Col);
		ret = IsWin(board, Row, Col);
		if (ret != 'C')
		{
    
    
			break;
		}
	}

	if (ret == '*')
	{
    
    
		printf("恭喜你获胜啦!\n");

	}
	else if (ret == '#')
	{
    
    
		printf("电脑获胜\n");
	}
	else
	{
    
    
		printf("平局\n");
	}

}
void game3()
{
    
    
	//建立两个数组分别存放数据
	char mine[ROWS][COLS] = {
    
     0 };//用来存放布置雷的信息的数组
	char show[ROWS][COLS] = {
    
     0 };//用来存放排查雷的信息的数组
	//初始化排查雷的棋盘
	InitBoard(mine, ROWS, COLS, '0');
	//初始化布置雷的棋盘
	InitBoard(show, ROWS, COLS, '*');
	//打印棋盘
	PrintBoard(show, ROW, COL);
	//布置雷
	SetMine(mine, ROW, COL);
	PrintBoard(mine, ROW, COL);

	//排雷
	RemoveMine(mine, show, ROW, COL);

}
int main()
{
    
    

	srand((unsigned int)time(NULL));
	int input = 0;
	do
	{
    
    
		menu();
		printf("请选择:>");
		scanf("%d", &input);
		switch (input)
		{
    
    
		case 0:
			printf("退出游戏!\n");
			break;
		case 1:
			game1();
			break;
		case 2:
			game2();
			break;
		case 3:
			game3();
		default:
			printf("选择错误,请重新输入!\n");
		}
	} while (input);
	return 0;
}

game2.h

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#define Row 3
#define Col 3

//初始化棋盘
void initBoard(char board[Row][Col], int row, int col);
//打印棋盘
void DisplayBoard(char board[Row][Col], int row, int col);

void PlayerMove(char board[Row][Col], int row, int col);

void ComputerMove(char board[Row][Col], int row, int col);

char IsWin(char board[Row][Col], int row, int col);

game3. h


#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define ROW  9
#define COL 9
#define ROWS ROW+2
#define COLS COL+2
#define EASY_COUNT 10
//初始化排雷界面
void InitBoard(char arr[ROWS][COLS], int rows, int cols, char set);

//打印棋盘
void PrintBoard(char arr[ROWS][COLS], int row, int col);

//布置雷
void SetMine(char arr[ROWS][COLS], int row, int col);
//排查雷
void RemoveMine(char mine[ROWS][COLS], char show[ROWS][COLS], int row, int col);

game2.c

#include"game2.h"

void initBoard(char board[Row][Col], int row, int col)
{
    
    
	int i = 0;
	for (i = 0; i < row; i++)
	{
    
    
		int j = 0;
		for (j = 0; j < col; j++)
		{
    
    
			board[i][j] = ' ';
		}
	}
	//memset(&board[0][0], " ", row * col * sizeof(board[0][0]));
}

void DisplayBoard(char board[Row][Col], int row, int col)
{
    
    
	int i = 0;
	int j = 0;
	for (i = 0; i < row; i++)
	{
    
    
		int j = 0;
		for (j = 0; j < col; j++)
		{
    
    
			printf(" %c ", board[i][j]);
			if (j < col - 1)
			{
    
    
				printf("|");
			}
		}
		printf("\n");
		if (i < row - 1)
		{
    
    
			int j = 0;
			for (j = 0; j < col; j++)
			{
    
    
				printf("---");
				if (j < col - 1)
				{
    
    
					printf("|");
				}
			}


		}
		printf("\n");
	}
}

void PlayerMove(char board[Row][Col], int row, int col)
{
    
    
	int x = 0;
	int y = 0;
	printf("玩家下棋:>\n");
	while (1)
	{
    
    

		printf("请输入坐标:");
		scanf("%d %d", &x, &y);
		if ((x >= 1 && x <= row) && (y >= 1 && y <= col))
		{
    
    
			if (board[x - 1][y - 1] == ' ')
			{
    
    
				board[x - 1][y - 1] = '*';
				break;
			}
			else
				printf("该坐标已经被占用,请重新输入\n");
		}
		else
		{
    
    
			printf("非法坐标,请重新输入\n");
		}

	}
}

void ComputerMove(char board[Row][Col], int row, int col)
{
    
    
	int x = 0;
	int y = 0;
	printf("电脑下棋:>\n");
	while (1)
	{
    
    
		x = rand() % 3;
		y = rand() % 3;
		if (board[x][y] == ' ')
		{
    
    
			board[x][y] = '#';
			break;
		}
	}

}


char IsWin(char board[Row][Col], int row, int col)
{
    
    
	int i = 0;
	for (i = 0; i < row; i++)
	{
    
    
		if (board[i][0] == board[i][1] && board[i][1] == board[i][2] && board[i][0] != ' ')
		{
    
    
			return board[i][0];
		}
	}
	for (i = 0; i < col; i++)
	{
    
    
		if (board[0][i] == board[1][i] && board[1][i] == board[2][i] && board[1][i] != ' ')
		{
    
    
			return board[1][i];
		}
	}
	if (board[0][0] == board[1][1] && board[1][1] == board[2][2] && board[0][0] != ' ')
	{
    
    
		return board[0][0];
	}
	if (board[0][2] == board[1][1] && board[2][0] == board[1][1] && board[1][1] != ' ')
	{
    
    
		return board[1][1];
	}

	for (i = 0; i < row; i++)
	{
    
    
		int j = 0;
		for (j = 0; j < col; j++)
		{
    
    
			if (board[i][j] == ' ')
			{
    
    
				return 'C';
			}
		}
	}
	return 'Q';


}

game3. c

#include"game3.h"

void InitBoard(char arr[ROWS][COLS], int rows, int cols, char set)
{
    
    
	int i = 0;
	int j = 0;
	for (i = 0; i < rows; i++)
	{
    
    
		int j = 0;
		for (j = 0; j < cols; j++)
		{
    
    
			arr[i][j] = set;
		}
	}
}

void PrintBoard(char arr[ROWS][COLS], int row, int col)
{
    
    
	int i = 0;
	int j = 0;
	printf("******* 排雷 *******\n");
	for (i = 0; i <= col; i++)
	{
    
    
		printf("%d ", i);
	}
	printf("\n");
	for (i = 1; i <= row; i++)
	{
    
    
		printf("%d ", i);
		for (j = 1; j <= col; j++)
		{
    
    
			printf("%c ", arr[i][j]);
		}
		printf("\n");
	}

}

void SetMine(char arr[ROWS][COLS], int row, int col)
{
    
    
	int count = EASY_COUNT;
	while (count)
	{
    
    
		int x = rand() % row + 1;
		int y = rand() % col + 1;
		if (arr[x][y] == '0')
		{
    
    
			arr[x][y] = '1';
			count--;
		}
	}

}

//统计雷的个数
int MineCount(char mine[ROWS][COLS], int x, int y)
{
    
    
	return (mine[x - 1][y - 1] + mine[x - 1][y] +
		mine[x - 1][y + 1] + mine[x][y - 1] +
		mine[x + 1][y - 1] + mine[x + 1][y] +
		mine[x + 1][y + 1] + mine[x][y + 1] - 8 * '0');
}
void RemoveMine(char mine[ROWS][COLS], char show[ROWS][COLS], int row, int col)
{
    
    
	int x = 0;
	int y = 0;
	int safe = 0;
	while (safe < row * col - EASY_COUNT)
	{
    
    
		printf("请输入你要排查的坐标:>");
		scanf("%d %d", &x, &y);
		if (x >= 1 && x <= row && y >= 1 && y <= col)
		{
    
    
			if (show[x][y] == '*')
			{
    
    
				if (mine[x][y] == '1')
				{
    
    
					printf("很遗憾,你被炸死\n");
					PrintBoard(mine, ROW, COL);
					break;
				}
				else
				{
    
    
					//如果该坐标不是雷,就要统计该坐标周围有几个雷
					int count = MineCount(mine, x, y);
					show[x][y] = count + '0';
					PrintBoard(show, ROW, COL);
					safe++;
				}

			}
			else
			{
    
    
				printf("该坐标已经排查,请重新输入!\n");
			}
		}
		else
		{
    
    
			printf("你输入的坐标非法,请重新输入!\n");
		}
	}


}

Summarize

Well, that’s all for Xiaobai’s sharing today. In fact, some parts of the code of these games can still be optimized. For example, there are still some deficiencies in the minesweeping area. If you are interested, you can follow up.

Guess you like

Origin blog.csdn.net/weixin_63181097/article/details/129291356