$board_status_current = substr_replace($board_status_current, '7', -4, 1);
} elseif ($x == 'g') {
    $board_status_current = substr_replace($board_status_current, '7', -3, 1);
} elseif ($x == 'h') {
    $board_status_current = substr_replace($board_status_current, '7', -2, 1);
} elseif ($x == 'i') {
    $board_status_current = substr_replace($board_status_current, '7', -1, 1);
}
$game_over = game_over_check($board_status_current);
if ($game_over == '1') {
    $vtrain = '-100';
    weight_update_cpu1($vtrain, $w1, $w2, $w3, $w4, $w5, $w6, $w7, $w8, $w9, $w10);
    $sql = "TRUNCATE TABLE gamemoves";
    mysql_query($sql, $db) or die(mysql_error($db));
    exit('User WON!!');
} elseif ($game_over == '2') {
    $vtrain = '100';
    weight_update_cpu1($vtrain, $w1, $w2, $w3, $w4, $w5, $w6, $w7, $w8, $w9, $w10);
    $sql = "TRUNCATE TABLE gamemoves";
    mysql_query($sql, $db) or die(mysql_error($db));
    exit('CPU WON!!');
} elseif ($game_over == '3') {
    $vtrain = '0';
    weight_update_cpu1($vtrain, $w1, $w2, $w3, $w4, $w5, $w6, $w7, $w8, $w9, $w10);
    $sql = "TRUNCATE TABLE gamemoves";
    mysql_query($sql, $db) or die(mysql_error($db));
    exit('GAME DRAW!!');
} else {
    $link = 'home.php?board_status_current=' . $board_status_current;
    redirect($link);
}
        $userwon++;
        continue;
    } elseif ($game_over == '2') {
        $vtrain = '100';
        weight_update($vtrain, $w1, $w2, $w3, $w4, $w5, $w6, $w7, $w8, $w9, $w10);
        weight_update_cpu1($vtrain, $w1c, $w2c, $w3c, $w4c, $w5c, $w6c, $w7c, $w8c, $w9c, $w10c);
        $sql = "TRUNCATE TABLE gamemoves";
        mysql_query($sql, $db) or die(mysql_error($db));
        $sql = "TRUNCATE TABLE gamemovescpu1";
        mysql_query($sql, $db) or die(mysql_error($db));
        $cpuwon++;
        continue;
    } elseif ($game_over == '3') {
        $vtrain = '0';
        weight_update($vtrain, $w1, $w2, $w3, $w4, $w5, $w6, $w7, $w8, $w9, $w10);
        weight_update_cpu1($vtrain, $w1c, $w2c, $w3c, $w4c, $w5c, $w6c, $w7c, $w8c, $w9c, $w10c);
        $sql = "TRUNCATE TABLE gamemoves";
        mysql_query($sql, $db) or die(mysql_error($db));
        $sql = "TRUNCATE TABLE gamemovescpu1";
        mysql_query($sql, $db) or die(mysql_error($db));
        $gamedraw++;
        continue;
    }
    // for loop end
}
echo 'Total Games : ' . $count;
?>
<br /> <?php 
echo 'Draw Games : ' . $gamedraw;
?>
<br /> <?php