function comp_logic($computer_squars, $player_squars, $wins, $av_squares, $wins_left) { // $pick = check_if_computer_can_win($computer_squars,$wins_left,$av_squares); // if($pick !== false){ // return $pick; // } $pick = stop_player_from_winning($player_squars, $wins, $av_squares); var_dump($pick); if ($pick !== false) { return $pick; } // if ($pick === false){ // $maxs = possible_wins($wins_left,$av_squares); // return $av_squares[$maxs[0]]; // } }
function comp_logic($wins_left, $av_squares, $computer_squars, $player_squars, $wins) { // first process: See if comp can win!! $pick = check_if_computer_can_win($computer_squars, $wins_left); if ($pick !== false) { return $pick; } // second process: Stop player form winning!! $pick = stop_player_from_winning($player_squars, $wins); if ($pick !== false) { return $pick; } // third process: Get array of possible wins!! if ($pick === false) { $maxs = possible_wins($wins_left, $av_squares); return $av_squares[$maxs[0]]; } // fouth process: pick from winning array with values occupied!! }