0-99 in all 3 directions |
const int x_dim = 100;
srand( time( null ) )
#include <iostream> #include <cstdlib> #include <cmath> #include <ctime> using namespace std; int main (void) { cout << "In this computer game, you are to locate a bomb and defuse it." << endl; cout << "You are required to guess until you find the bombs. You have 20 tries." << endl; cout << "You have a bomb detector with you that reports a signal from 0 - 1000." << endl; cout << "The signal will be greater the closer you are and each try will take 10 seconds to complete." << endl; cout << "The program is created by mahmad33." << endl; srand ( time ( NULL ) ); const int initialTries = 20; const int x_dim = 100; const int y_dim = 100; const int z_dim = 100; int xBomb, yBomb, zBomb; double xGuess; bool Won = false; bool Repeat = false; xBomb = rand() % 100; yBomb = rand() % 100; zBomb = rand() % 100; signal = 1000 * ( 1 - ) if ( xGuess == xBomb || xGuess == yBomb || xGuess == zBomb) { Won = true } else { Repeat = true } while ( Repeat ) { } else ( Won ) { return 0; } return 0; } |
|
|
Signal = 1000 * (1- ( sqrt ( Summation of i = x,y,z(iGuess - iBomb)^2) / 100 radical 3)
i
.i = x,y,z(iGuess - iBomb)^2) / 100 radical 3
100 radical 3
Perhaps it means the cube root of 100? See for example https://www.mathsisfun.com/definitions/radical.htmlThey have 20 tries(200 seconds) |
int time_remaining = 200; // number of seconds left
#include <iostream> #include <cstdlib> #include <cmath> #include <ctime> using namespace std; int main (void) { cout << "In this computer game, you are to locate a bomb and defuse it." << endl; cout << "You are required to guess until you find the bombs. You have 20 tries." << endl; cout << "You have a bomb detector with you that reports a signal from 0 - 1000." << endl; cout << "The signal will be greater the closer you are and each try will take 10 seconds to complete." << endl; cout << "The program is created by mahmad33." << endl; srand ( time ( NULL ) ); const int initialTries = 20; int remainingTries; const int x_dim = 100; const int y_dim = 100; const int z_dim = 100; int xBomb, yBomb, zBomb, seconds; double xGuess, zGuess, yGuess, a, b, c, d, e, f, g, h, j, i, signal; seconds = remainingTries * 10; bool Won = false; bool Repeat = false; bool Tryagain = false; char choice; xBomb = rand() % x_dim; yBomb = rand() % y_dim; zBomb = rand() % z_dim; a = (xGuess - xBomb); b = (yGuess - yBomb); c = (zGuess - zBomb); d = pow(a, 2.0); e = pow(b, 2.0); f = pow(c, 2.0); i = (a + b + c); g = (100 * sqrt(3)); h = sqrt(i); j = ( h / g ); signal = 1000 * ( 1 - j ); if ( initialTries == 20 ) { Tryagain == false; remainingTries == initialTries; } while (Tryagain == false) { for (remainingTries == initialTries; remainingTries > 0; --remainingTries ) { // Enter guesses and if wrong then V. If guesses are right, set Won to true. cout << "Enter your guess for xBomb." << endl; cin >> xGuess; cout << "Enter your guess for yBomb." << endl; cin >> yGuess; cout << "Enter your guess for zBomb." << endl; cin >> zGuess; cout << "The bomb detector detects a signal at:" << signal << endl; if ( xGuess == xBomb && xGuess == yBomb && xGuess == zBomb) { Won = true; } else { Repeat = true; } while ( Repeat && remainingTries > 0 ) { cout << "You fucked up. You have " << seconds << "seconds left!" << endl; remainingTries == --remainingTries; break; } if ( Won ) { cout << "Congratulations!!! You won!! Would you like to try again? [Y/N]?" << endl; cin >> choice; if (choice == 'y' || 'Y') { Tryagain = false; } else if (choice == 'n' || 'N') { cout << "Goodbye! Try again soon!" << endl; Tryagain = true; } else if (choice != 'n' || 'N' || 'y' || 'Y') { cout << "Invalid character. Program will exit."; Tryagain = true; } } } } system ("pause"); return 0; } |
Still need help with the signal. |
You have a bomb detector with you that reports a signal from 0 - 1000. The signal will be greater the closer you are |
Signal = 1000 * (1- ( sqrt ( Summation of i = x,y,z(iGuess - iBomb)^2) / 100 radical 3)
1000 * (1- ( sqrt ( Summation of i = x,y,z(iGuess - iBomb)^2) / 100 radical 3))
(1- ( sqrt ( Summation of i = x,y,z(iGuess - iBomb)^2) / 100 radical 3))
sqrt ( Summation of i = x,y,z(iGuess - iBomb)^2) / 100 radical 3
sqrt ( (xBomb - xGuess)2 + (yBomb - yGuess)2 + (zBomb - zGuess)2 ) / cube_root(x_dim * y_dim * z_dim)
100 * sqrt(3)