/*
Alex Drikos, Yazhou Liu, Terence Nguyen, Dante Sangoi
11/13/2023
Summative Unit Project
Attempting to create minesweeper
*/
/*
NOTES AND TO DO LIST
--> USE # FOR CLOSED AND - FOR OPEN
--> USE LETTERS AND NUMBERS FOR ROWS AND COLUMNS
--> USE FUNCTION TO CONVERT LETTERS TO NUMBERS
--> NEED RNG TO PLACE BOMBS
--> CHECK IF SPOT ALREADY HAS BOMBS
--> FUNCTION FOR CHECKING ADJACENT SQUARES FOR BOMBS
SCENES
--> GAME
--> HELP SCREEN
LATER
--> FLAGGING
--> IF HAVE TIME, CREATE A BIGGER BOARD
*/
// VARIABLE DECLARATION
int randint;
int randint2;
int choice;
String inputX;
String inputY;
String inputCell;
String mainBoard[8][8] = { // [y][x]
//0 1 2 3 4 5 6 7
{"#", "#", "#", "#", "#", "#", "#", "#"}, // A 0
{"#", "#", "#", "#", "#", "#", "#", "#"}, // B 1
{"#", "#", "#", "#", "#", "#", "#", "#"}, // C 2
{"#", "#", "#", "#", "#", "#", "#", "#"}, // D 3
{"#", "#", "#", "#", "#", "#", "#", "#"}, // E 4
{"#", "#", "#", "#", "#", "#", "#", "#"}, // F 5
{"#", "#", "#", "#", "#", "#", "#", "#"}, // G 6
{"#", "#", "#", "#", "#", "#", "#", "#"} // H 7
};
String bombBoard[8][8] = { // [y][x]
//0 1 2 3 4 5 6 7
{"00", "10", "20", "30", "40", "50", "60", "70"}, // A 0
{"10", "11", "12", "13", "14", "15", "16", "17"}, // B 1
{"20", "21", "22", "23", "24", "25", "26", "27"}, // C 2
{"30", "31", "32", "33", "34", "35", "36", "37"}, // D 3
{"40", "41", "42", "43", "44", "45", "46", "47"}, // E 4
{"50", "51", "52", "53", "54", "55", "56", "57"}, // F 5
{"60", "61", "62", "63", "64", "65", "66", "67"}, // G 6
{"70", "71", "72", "73", "74", "75", "76", "77"} // H 7
};
// CUSTOM FUNCTIONS
// Prints the board
void printBoard() {
for (int y=0;y<8;y++) {
for (int x=0;x<8;x++) {
Serial.print(mainBoard[y][x]+" ");
}
Serial.println();
}
// REVEALING BOMB BOARD FOR CONVENIENCE SAKE
for (int y=0;y<8;y++) {
for (int x=0;x<8;x++) {
Serial.print(bombBoard[y][x]+" ");
}
Serial.println();
}
}
// Generate Mines
void generateBombs(int x, int y) {
for (int i=0;i<10;i++) {
randint = random(0,8);
randint2 = random(0,8);
while (randint == x) {
randint = random(0,8);
}
while (randint2 == y) {
randint2 = random(0,8);
}
bombBoard[randint][randint2] = "XX";
}
}
// Finds bombs in adjacent tiles
void findAdjacent(int x, int y) { // a and b, row and column, letter and number
// Have nested for loop that counts all around the inputted coordinate
int count; // checks amt of bombs around
if (bombBoard[y][x]=="XX") {
revealBombs();
}
else {
//check adjacent
if (x > 0 && x < 7) {
if (y > 0 && y < 7) {
// checks all around
}
else if (y == 7) {
// no check bottom
}
else if (y == 0) {
// no check top
}
}
else if (x == 7) {
// no check right
if (y == 7) {
// no check right bottom
}
else if (y == 0) {
// no check right top
}
}
else if (x == 0) {
// no check left
if (y == 7) {
// no check left bottom
}
else if (y == 0) {
// no check left top
}
}
}
}
void revealBombs() {
// help
}
void setup()
{
Serial.begin(9600);
randomSeed(analogRead(0));
while(choice!=2){
Serial.println("WELCOME TO BOMB SWEEPER(TM): HELP SCREEN(1) PLAY GAME(2)");
while(Serial.available()==0){}
choice=Serial.parseInt();
if(choice==1){
Serial.println("-----HOW TO PLAY-----");
Serial.println("In Bomb Sweeper there is a grid full of hidden mines that are revealed by adjacent tiles");
Serial.println("The tiles that are directly next to mines will display the number of mines that they are close to");
Serial.println("The objective is to remove every non bomb space");
Serial.println("IF YOU CLICK ON A BOMB YOU WILL DIE");
}
}
if(choice==2){
Serial.println("Hello i am under da water pleas help me");
delay(500);
Serial.print("Enter X Coordinate (0-7): ");
while(Serial.available()==0){}
inputX=Serial.parseInt();
Serial.println(inputX);
delay(250);
Serial.print("Enter Y Coordinate (0-7): ");
while(Serial.available()==0){}
inputY=Serial.parseInt();
Serial.println(inputY);
//generateBombs(inputX, inputY);
//printBoard();
inputCell = inputY + inputX;
Serial.println(inputCell);
}
} // setup end
void loop()
{
}