It is strange, I coded my pig game here in c++ which once the user or computer reaches 100 he wins. But the problem is if I keep rolling and I go past 100 I don’t win unless I hold after I get there. And the computer if it gets close to 100 around 80 to 100 it will just say it wins. I don’t understand whats going on here and what the problem is? I did everything right! Or am I missing something?
How can I fix this issue where once I reach 100 rolling or holding on the users end that it just wins and doesn’t go past 100 so if I hold at 100+ it tells me I win. How can I go about making it so the computer only wins when it actually gets to 100 or past it automatically?
Try it this way :
and
changes made :
ifcondition was altered due to flaw in logic.Ifcondition,if((humanTotalScore < 100) && (computerTotalScore < 100))was moved into thedo-whileloop. Since it have to be updated each time anyone plays.int computerTurn(int& computerTotalScore)was altered,In some placescomputerScorewas used instead ofcomputerTotalScore