IAS/StupidIAconnectFour.php

23 lines
415 B
PHP
Raw Normal View History

2016-05-31 13:10:01 +02:00
<?php
2016-06-02 23:29:30 +02:00
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
2016-05-31 13:10:01 +02:00
/*
* stupid IA for battle ship
* choose by random a free column
*/
$in=file_get_contents('php://input');
$params=json_decode($in, TRUE);
$grid=$params['grid'];
$colAvailable=array();
for($i=0;$i<7;$i++){
if($grid[5][$i] == ""){
$colAvailable[]=$i;
}
}
shuffle($colAvailable);
echo $colAvailable[0];
die;