Test
- User
Test
- Assistant
I'm an AI, so I don't take tests. However, I can assist you with any questions or information you need. Let me know how I can help you.
- User
Write minesweeper in c console version
- Assistant
Here is a basic Minesweeper game in C for the console. Please consider this code as a starting point, as there is room for improvements, optimizations, and error handling.
#include <stdio.h> #include <stdlib.h> #include <time.h> #define BOARD_SIZE 9 #define NUM_MINES 10 void print_board(char** board, int revealed); int check_adjacent_mines(char** board, int x, int y); void generate_mines(char** board); int main() { char** board = (char**)malloc(BOARD_SIZE * sizeof(char*)); for (int i = 0; i < BOARD_SIZE; i++) { board[i] = (char*)malloc(BOARD_SIZE * sizeof(char)); } for (int i = 0; i < BOARD_SIZE; i++) { for (int j = 0; j < BOARD_SIZE; j++) { board[i][j] = '-'; } } print_board(board, 0); generate_mines(board); return 0; } void print_board(char** board, int revealed) { printf(" "); for (int i = 0; i < BOARD_SIZE; i++) { printf("%d ", i); } printf("\n"); for (int i = 0; i < BOARD_SIZE; i++) { printf("%d ", i); for (int j = 0; j < BOARD_SIZE; j++) { if (revealed) { printf("%c ", board[i][j]); } else { printf("- "); } } printf("\n"); } } int check_adjacent_mines(char** board, int x, int y) { int count = 0; for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { int newX = x + i; int newY = y + j; if (newX >= 0 && newX < BOARD_SIZE && newY >= 0 && newY < BOARD_SIZE) { if (board[newX][newY] == '*') { count++; } } } } return count; } void generate_mines(char** board) { srand(time(0)); for (int i = 0; i < NUM_MINES; i++) { int x = rand() % BOARD_SIZE; int y = rand() % BOARD_SIZE; if (board[x][y] == '*') { i--; continue; } board[x][y] = '*'; } print_board(board, 1); } - User
Add all game mechanics
- Assistant
- User
Add mines flagging
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.