How can I use a rand function that generates a random enumerated variable? This is what I so far have (it's spitting out garbage numbers):
enum pieces { FLAG = 'F', BOMB = 'B', MARSHAL = '1', GENERAL = '2', COLONEL =
'3', MAJOR = '4', CAPTAIN = '5', LIEUTENANT = '6', SERGEANT =
'7', MINER = '8', SPY = 'S' };
int gamePieces[12] = { FLAG, BOMB, MARSHAL, GENERAL, COLONEL, MAJOR,
CAPTAIN, LIEUTENANT, SEGEANT, MINOR, SPY };
int rand_piece = (rand()& gamePieces[12];
Aucun commentaire:
Enregistrer un commentaire