2016-05-11 10:33:32 +02:00
|
|
|
<?php
|
2016-05-11 14:49:38 +02:00
|
|
|
/*
|
|
|
|
* stupid IA for battle ship
|
|
|
|
* choose by random a free column
|
|
|
|
*/
|
2016-05-29 21:22:41 +02:00
|
|
|
$in=file_get_contents('php://input');
|
|
|
|
$params=json_decode($in, TRUE);
|
|
|
|
$grid=$params['grid'];
|
2016-05-11 14:49:38 +02:00
|
|
|
$colAvailable=array();
|
|
|
|
|
|
|
|
for($i=0;$i<7;$i++){
|
2016-05-11 14:52:26 +02:00
|
|
|
if($grid[5][$i] == ""){
|
2016-05-11 14:49:38 +02:00
|
|
|
$colAvailable[]=$i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
shuffle($colAvailable);
|
2016-05-11 14:53:10 +02:00
|
|
|
echo $colAvailable[0];
|
2016-05-11 14:49:38 +02:00
|
|
|
die;
|