$botsCount)){ error(400,"wrong parameters"); die; } } return array('bot1' => $_POST['bot1'],'bot2' => $_POST['bot2']); } function generate_numeric_select($start,$end,$selected,$name,$id){ $out="'.$i.''; } }else{ for($i=$start; $i < $selected; $i++ ){ $out.=''; } $out.=''; for($i=$selected + 1; $i <= $end; $i++ ){ $out.=''; } } return $out.""; } function get_IA_Response($iaUrl,$postParams){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $iaUrl); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $postParams); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); return htmlentities($output); } function is_it_possible_to_place_ships_on_grid($gridWidth,$gridHeight,$nbShipsSize1,$nbShipsSize2,$nbShipsSize3,$nbShipsSize4,$nbShipsSize5,$nbShipsSize6){ //return false or true } function place_ship_on_map($x1,$y1,$x2,$y2,$map){ if ((($x1 <> $x2) && ($y1 <> $y2)) OR (!isset($map[$y1][$x1])) OR (!isset($map[$y2][$x2]))){ return false; } if($x1 == $x2){ //horizontal ship if($y1 <= $y2 ){ $start=$y1; $end=$y2; }else{ $start=$y2; $end=$y1; } for($i = $start; $i <= $end; $i++){ if($map[$i][$x1]==0){ $map[$i][$x1]=1; }else{ return false; } } return $map; } if($y1 == $y2){ //vertical ship if( $x1 <= $x2){ $start=$x1; $end=$x2; }else{ $start=$x2; $end=$x1; } for( $i = $start; $i <= $end; $i++){ if( $map[$y1][$i] == 0){ $map[$y1][$i]=1; }else{ return false; } } return $map; } }