2024-11-13 20:05:16 +00:00
|
|
|
//
|
|
|
|
// Created by DH10MBO on 13.11.2024.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "Mastermind.h"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <ostream>
|
|
|
|
#include <random>
|
|
|
|
|
2024-11-13 20:11:45 +00:00
|
|
|
#include "../Aufg4/CrimeStats.h"
|
|
|
|
|
2024-11-13 20:05:16 +00:00
|
|
|
int getRandomNumberInRange(int min, int max) {
|
|
|
|
static std::mt19937 generator(static_cast<unsigned int>(time(nullptr)));
|
|
|
|
std::uniform_int_distribution<int> distribution(min, max);
|
|
|
|
|
|
|
|
int randomNumber = distribution(generator);
|
|
|
|
|
|
|
|
return randomNumber;
|
|
|
|
}
|
|
|
|
|
|
|
|
void printAllStringsInVector(std::vector<std::string> &strings) {
|
|
|
|
std::cout << "[";
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < strings.size() - 1; i++) {
|
|
|
|
std::cout << strings[i] << ", ";
|
|
|
|
}
|
|
|
|
std::cout << strings[i] << "]" << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> generateSecretCode(int digits, int optionsPerDigit) {
|
|
|
|
std::vector<std::string> secretCode;
|
|
|
|
|
|
|
|
for (int i = 0; i < digits; i++) {
|
|
|
|
int digit = getRandomNumberInRange(0, optionsPerDigit);
|
|
|
|
secretCode.push_back(std::to_string(digit));
|
|
|
|
std::cout << "Secret Code was set as " << digit << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
return secretCode;
|
|
|
|
}
|
|
|
|
|
2024-11-13 20:11:45 +00:00
|
|
|
std::vector<std::string> getCodeGuessFromConsole() {
|
|
|
|
std::cout << "Have a Guess! :" << std::endl;
|
|
|
|
|
|
|
|
std::string input;
|
|
|
|
std::cin >> input;
|
|
|
|
|
|
|
|
std::vector<std::string> guess;
|
|
|
|
|
|
|
|
split(input, ' ', guess);
|
|
|
|
|
|
|
|
return guess;
|
|
|
|
}
|
2024-11-13 20:05:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Aufg5Main() {
|
|
|
|
// generateSecretCode(1,1);
|
|
|
|
|
|
|
|
std::vector<std::string> SecretCode = generateSecretCode(4, 4);
|
|
|
|
|
|
|
|
printAllStringsInVector(SecretCode);
|
|
|
|
|
2024-11-13 20:11:45 +00:00
|
|
|
std::vector<std::string> guess = getCodeGuessFromConsole();
|
|
|
|
|
|
|
|
printAllStringsInVector(guess);
|
|
|
|
|
2024-11-13 20:05:16 +00:00
|
|
|
|
|
|
|
}
|