I want to add some randomness to this game. Does anyone know how I could have the players character be different each game or possibly show up on different parts of the board? The top half of my code is below. Any help would be great thanks!
#include <iostream>
using std::endl;
using std::cout;
using std::cin;
#include <string>
using std::string;
No, it's entirely possible to generate a random maze; there's plenty of ways to do that. If you're interested I can provide an example program that does this.
OP, you can use code like this:
1 2 3 4 5 6 7 8
# include <string>
# include <random>
/* List of possible characters: */
staticconst std::string chset =
"0123456789!@#$%^&*ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
auto r_char = [=, r_gen{std::mt19937{std::random_device{}()}}] () mutable {
return chset[std::uniform_int_distribution<>{0, chset.size() - 1}(r_gen)];
}
And then you can call r_char() to get a random (draw with replacement) character from the character set: constchar me{r_char()};
If you want a strictly different character (draw with no replacement) each time, I like to use this code to generate grab-bags:
No, it's entirely possible to generate a random maze; there's plenty of ways to do that. If you're interested I can provide an example program that does this.
Yeah, I would be glad to. I wonder how people like you can actually make this entirely possible.