Untitled7 - Arup Guha Program Description Implements a...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// 9/27/00 // Program Description : Implements a simplified version of the game // minesweeper. The user must clear off squares // one by one, and is not allowed to mark bombs. // Any time the user hits a bomb, they lose, just // like the original game. Play will halt if all // non-bomb squares have been cleared, and the player // is declared the winner in this situation. / // Edited on 5/28/08 to change language from C++ to C. / #include <stdio.h> #include <math.h> #include <stdlib.h> #include <time.h> # const int SIDE = 8; // side length of the board const int NUMBOMBS = 10; // number of bombs on the board const double EPSILON = 0.001; // Tolerance so adjacent bombs get counted properly. void printboard(char[][SIDE]); int numberbombs(int,int,int[][2]); int domove(char[][SIDE], char[][SIDE], int[][2], int, int, int*); void getbombs(int[][2]); void getmove(int*, int*); int valid(int,int); i int main() { int gameover = 0; // used to check if the game is over or not char uncovered_board[SIDE][SIDE]; // board that stores the location of all // the bombs and numbers of adjacent bombs. char current_board[SIDE][SIDE]; // stores the current board as it should be // printed out. int totalmoves; // stores the total moves left for the user before they win. int i,j; int x,y; int listbombs[NUMBOMBS][2]; // stores (x,y) coordinates of all bombs. srand(time(0)); // Seed the random number generator. // Initialize the current board. for (i=0;i<SIDE;i++) { for (j=0;j<SIDE;j++) { current_board[i][j] = '_'; uncovered_board[i][j] = '_'; } } // Randomly choose where the bombs will go. getbombs(listbombs);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 07/12/2009.

Page1 / 5

Untitled7 - Arup Guha Program Description Implements a...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online