I am working on the game of nim. In my code it does not get to the winner output of my game.
#include <iostream>
#include <math.h>
#include <time.h>
using namespace std;
int main()
{
int init_size, first_turn, AI, play_turn, comp_turn,count;
srand(time(NULL));
init_size = rand() % 100 + 10;
first_turn = rand() % 1 + 0;
AI = rand() % 1 + 0;
while (init_size != 0)
{
if (first_turn == 1)
{
play_turn = rand() % (init_size / 2) + 1;
init_size = init_size - play_turn;
first_turn = 0;
count = 1;
}
if (first_turn == 0)
{
comp_turn = rand() % (init_size / 2) + 1;
init_size = init_size - comp_turn;
first_turn = 1;
count = 0;
}
}
if (count == 1)
{
cout << "Player Wins" << endl;
}
if (count == 0)
{
cout << "Computer Wins" << endl;
}
return 0;
}