Code: Select all
int function_CPU(int &choice , int &cpu_random_play, int &result,int &down, int &yards_gained, int &yards_to_go) {
// want this function to keep to looping and the cpu keep calling plays until downs > 4 -- with a pause in between
// so the end user can see what the cpu is calling
do {
//have CPU call a random play from the list -- not dependent on down and distance or offense/defense attribution
srand((unsigned)time(NULL));
//generate random 1 or 2 -- either qb sneak or off guard run
cpu_random_play = rand() % 2 + 1;
//calls this function which has a menu to a choose but then stops at the cin prompt
//from within that function
//for the player 1 function works perfectly but when the cpu is trying to access cin, prompt is
//waiting for user input and doesnt get the cpu input
playbook(playbook_choice);
//??? How to make the CPU automatically select a play!!!!!!!!
if (cpu_random_play == 1) {
//chooses the play 1 from the playbook menu
playbook_choice = 1;
playbook_qb_sneak(result, down, yards_gained, yards_to_go);
}
if (cpu_random_play == 2) {
//chooses the play 2 from the playbook menu
playbook_choice = 2;
off_guard_run(result, down, yards_gained, yards_to_go);
}
}while (player_control = 2 && down <= 4);
return choice, cpu_random_play, result,down, yards_gained,yards_to_go;