commit
4889e67f61
|
@ -108,6 +108,7 @@ pre{
|
||||||
font-family: Consolas, "Times New Roman", Verdana;
|
font-family: Consolas, "Times New Roman", Verdana;
|
||||||
border-left: 4px solid #CCC;
|
border-left: 4px solid #CCC;
|
||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
|
white-space: normal;
|
||||||
}
|
}
|
||||||
.podium{list-style-type:none;padding: 5px 20px 5px 0;}
|
.podium{list-style-type:none;padding: 5px 20px 5px 0;}
|
||||||
.podium li{padding: 5px 20px 5px 0;}
|
.podium li{padding: 5px 20px 5px 0;}
|
||||||
|
|
11
lang/en.php
11
lang/en.php
|
@ -1,5 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
$lang = array(
|
$lang = array(
|
||||||
'lang' => 'en',
|
'lang' => 'en',
|
||||||
|
|
||||||
|
|
11
lang/fr.php
11
lang/fr.php
|
@ -1,5 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
$lang = array(
|
$lang = array(
|
||||||
'lang' => 'fr',
|
'lang' => 'fr',
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,16 @@
|
||||||
<article>
|
<article>
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
echo '<h2>A props de '.htmlentities($_GET['params']).'</h2><p>Inscrit le '.$theBot['date_inscription'].'</p><p>'.$theBot['description'].'</p>
|
echo '<h2>A props de '.htmlentities($_GET['params']).'</h2><p>Inscrit le '.$theBot['date_inscription'].'</p><p>'.$theBot['description'].'</p>
|
||||||
<p><i><a href="/p/editBot/'.$theBot['id'].'">Si vous êtes le propriétaire de ce bot, vous pouvez le modifier</a></i></p>';
|
<p><i><a href="/p/editBot/'.$theBot['id'].'">Si vous êtes le propriétaire de ce bot, vous pouvez le modifier</a></i></p>';
|
||||||
?>
|
?>
|
||||||
|
|
10
src/act.php
10
src/act.php
|
@ -1,4 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
//Del unvalidated bots
|
//Del unvalidated bots
|
||||||
mysqli_query($lnMysql, "DELETE FROM bots WHERE active='0' AND TIMESTAMPDIFF(DAY, NOW(), date_inscription) > 2");
|
mysqli_query($lnMysql, "DELETE FROM bots WHERE active='0' AND TIMESTAMPDIFF(DAY, NOW(), date_inscription) > 2");
|
||||||
|
|
|
@ -1,6 +1,17 @@
|
||||||
<article>
|
<article>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
//<?php echo xd_check_input(0);<input type="hidden" name="act" value="addBot"/>
|
//<?php echo xd_check_input(0);<input type="hidden" name="act" value="addBot"/>
|
||||||
|
|
||||||
if((isset($_POST['xd_check'])) && ($_POST['act'] == "addBot")){
|
if((isset($_POST['xd_check'])) && ($_POST['act'] == "addBot")){
|
||||||
|
|
|
@ -20,305 +20,357 @@ switch ($_POST['act']){
|
||||||
session_unset();
|
session_unset();
|
||||||
$_SESSION['xd_check']=$xd;
|
$_SESSION['xd_check']=$xd;
|
||||||
|
|
||||||
//verifier parametres POST
|
//verifier parametres POST
|
||||||
$postParamsWanted=array(
|
$postParamsWanted=array(
|
||||||
// key,min,max
|
// key,min,max
|
||||||
array('gridWidth',1,100),
|
array('gridWidth',1,100),
|
||||||
array('gridHeight',1,100),
|
array('gridHeight',1,100),
|
||||||
array('nbShip1',0,10),
|
array('nbShip1',0,10),
|
||||||
array('nbShip2',0,10),
|
array('nbShip2',0,10),
|
||||||
array('nbShip3',0,10),
|
array('nbShip3',0,10),
|
||||||
array('nbShip4',0,10),
|
array('nbShip4',0,10),
|
||||||
array('nbShip5',0,10),
|
array('nbShip5',0,10),
|
||||||
array('nbShip6',0,10)
|
array('nbShip6',0,10)
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($postParamsWanted as $p){
|
foreach($postParamsWanted as $p){
|
||||||
if(!isset($_POST[$p[0]])){
|
if(!isset($_POST[$p[0]])){
|
||||||
error (500,'missing parameter 1');
|
error (500,'missing parameter 1');
|
||||||
die;
|
die;
|
||||||
}else{
|
}else{
|
||||||
$value=$_POST[$p[0]];
|
$value=$_POST[$p[0]];
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
(!is_numeric($value))
|
(!is_numeric($value))
|
||||||
OR ($value < $p[1])
|
OR ($value < $p[1])
|
||||||
OR ($value > $p[2])
|
OR ($value > $p[2])
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
error(500,'wrong parameters '.$p[0]);
|
error(500,'wrong parameters '.$p[0]);
|
||||||
die;
|
die;
|
||||||
}
|
|
||||||
$postValues[$p[0]]=$value;
|
|
||||||
|
|
||||||
}
|
|
||||||
//check if bots exists
|
|
||||||
$bot1Exists = false;
|
|
||||||
$bot2Exists = false;
|
|
||||||
foreach($bots as $bot){
|
|
||||||
if($bot['id'] == $_POST['bot1']){
|
|
||||||
|
|
||||||
$bot1 = $bot;
|
|
||||||
$_SESSION['bot1']=$bot;
|
|
||||||
$bot1Exists =true;
|
|
||||||
}
|
|
||||||
if($bot['id'] == $_POST['bot2']){
|
|
||||||
$bot2 = $bot;
|
|
||||||
$_SESSION['bot2']=$bot;
|
|
||||||
$bot2Exists =true;
|
|
||||||
}
|
|
||||||
if ($bot1Exists && $bot2Exists){
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((!$bot1Exists) OR (!$bot2Exists)){
|
|
||||||
error (500,"missing parameter 2");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_it_possible_to_place_ships_on_grid($postValues['gridWidth'],$postValues['gridHeight'],$postValues['nbShip1'],$postValues['nbShip2'],$postValues['nbShip3'],$postValues['nbShip4'],$postValues['nbShip5'],$postValues['nbShip6'])){
|
|
||||||
error (404,"grid is too little for these ships");
|
|
||||||
}
|
|
||||||
|
|
||||||
//vars checked, lets init the initGame
|
|
||||||
|
|
||||||
$_SESSION['matchId']=get_unique_id();
|
|
||||||
|
|
||||||
|
|
||||||
for($player = 1; $player <= 2; $player++){
|
|
||||||
|
|
||||||
if($player==1){
|
|
||||||
$opponentName=$bot2['name'];
|
|
||||||
$currentBot=$bot1;
|
|
||||||
}else{
|
|
||||||
$opponentName=$bot1['name'];
|
|
||||||
$currentBot=$bot2;
|
|
||||||
}
|
|
||||||
|
|
||||||
$botParamsToSend=array(
|
|
||||||
'game' => 'Battleship',
|
|
||||||
'match_id' => $_SESSION['matchId']."-1",
|
|
||||||
'act' => 'init',
|
|
||||||
'opponent' => $opponentName,
|
|
||||||
'width' => $postValues['gridWidth'],
|
|
||||||
'height' => $postValues['gridHeight'],
|
|
||||||
'ship1' => $postValues['nbShip1'],
|
|
||||||
'ship2' => $postValues['nbShip2'],
|
|
||||||
'ship3' => $postValues['nbShip3'],
|
|
||||||
'ship4' => $postValues['nbShip4'],
|
|
||||||
'ship5' => $postValues['nbShip5'],
|
|
||||||
'ship6' => $postValues['nbShip6']
|
|
||||||
|
|
||||||
);
|
|
||||||
$anwserPlayer=get_IA_Response($currentBot['url'],$botParamsToSend);
|
|
||||||
$boatsPlayer = json_decode( html_entity_decode($anwserPlayer));
|
|
||||||
if(!$boatsPlayer){
|
|
||||||
echo $currentBot['name']." a fait une réponse non conforme, il perd.".$anwserPlayer;
|
|
||||||
if($player==1){
|
|
||||||
save_battle('Battleship',$bot1['name'],$bot2['name'],2);
|
|
||||||
}else{
|
|
||||||
save_battle('Battleship',$bot1['name'],$bot2['name'],1);
|
|
||||||
}
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
|
|
||||||
//init grid
|
|
||||||
for($y = 0; $y < $postValues['gridHeight']; $y++){
|
|
||||||
for($x = 0; $x < $postValues['gridWidth']; $x++){
|
|
||||||
$grid[$player][$y][$x]=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//vérifier si'il y a le bon nombre de bateaux et les placer
|
|
||||||
$nbBoatsIwant=array(0,$postValues['nbShip1'],$postValues['nbShip2'],$postValues['nbShip3'],
|
|
||||||
$postValues['nbShip4'],$postValues['nbShip5'],$postValues['nbShip6']);
|
|
||||||
|
|
||||||
foreach($boatsPlayer as $boat){
|
|
||||||
list($startCoord,$endCoord) = explode("-",$boat);
|
|
||||||
list($xStart,$yStart)=explode(",",$startCoord);
|
|
||||||
list($xEnd,$yEnd)=explode(",",$endCoord);
|
|
||||||
if($xStart == $xEnd){
|
|
||||||
$long=abs($yStart - $yEnd) +1;
|
|
||||||
}else{
|
|
||||||
$long=abs($xStart - $xEnd) +1;
|
|
||||||
}
|
|
||||||
$nbBoatsIwant[$long]-=1;
|
|
||||||
$grid[$player]=place_ship_on_map($xStart,$yStart,$xEnd,$yEnd,$grid[$player]);
|
|
||||||
if(!$grid[$player]){
|
|
||||||
echo $currentBot['name']." n'a pas placé correctement ses bateaux. Certains se chevauchent. Il perd.";
|
|
||||||
if($player==1){
|
|
||||||
save_battle('Battleship',$bot1['name'],$bot2['name'],2);
|
|
||||||
}else{
|
|
||||||
save_battle('Battleship',$bot1['name'],$bot2['name'],1);
|
|
||||||
}
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
//remember each cases of each boats
|
|
||||||
$boatListOfCases=array();
|
|
||||||
if($xStart == $xEnd){
|
|
||||||
if($yStart <= $yEnd ){
|
|
||||||
$start=$yStart;
|
|
||||||
$end=$yEnd;
|
|
||||||
}else{
|
|
||||||
$start=$yEnd;
|
|
||||||
$end=$yStart;
|
|
||||||
}
|
}
|
||||||
for($i = $start; $i <= $end; $i++){
|
$postValues[$p[0]]=$value;
|
||||||
$boatListOfCases[]=$xStart.",".$i;
|
}
|
||||||
}
|
if(($_POST['fullLogs'] <> 'true') && ($_POST['fullLogs'] <> 'false')){
|
||||||
}else{
|
error(500, 'wrong POST parameters');
|
||||||
if($xStart <= $xEnd ){
|
die;
|
||||||
$start=$xStart;
|
}
|
||||||
$end=$xEnd;
|
if($_POST['fullLogs'] == 'true'){
|
||||||
}else{
|
$wantFullLogs = true;
|
||||||
$start=$xEnd;
|
|
||||||
$end=$xStart;
|
|
||||||
}
|
|
||||||
for($i = $start; $i <= $end; $i++){
|
|
||||||
$boatListOfCases[]=$i.",".$yStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
$_SESSION['ships'][$player][]=$boatListOfCases;
|
|
||||||
}
|
|
||||||
foreach($nbBoatsIwant as $nb){
|
|
||||||
if($nb <> 0){
|
|
||||||
echo $currentBot['name']." n'a pas placé le bon nombre de bateaux. Il perd.";
|
|
||||||
if($player==1){
|
|
||||||
save_battle('Battleship',$bot1['name'],$bot2['name'],2);
|
|
||||||
}else{
|
|
||||||
save_battle('Battleship',$bot1['name'],$bot2['name'],1);
|
|
||||||
}
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$_SESSION['ship1']=$postValues['nbShip1'];
|
|
||||||
$_SESSION['ship2']=$postValues['nbShip2'];
|
|
||||||
$_SESSION['ship3']=$postValues['nbShip3'];
|
|
||||||
$_SESSION['ship4']=$postValues['nbShip4'];
|
|
||||||
$_SESSION['ship5']=$postValues['nbShip5'];
|
|
||||||
$_SESSION['ship6']=$postValues['nbShip6'];
|
|
||||||
$_SESSION['strikes'][1]=array();
|
|
||||||
$_SESSION['strikes'][2]=array();
|
|
||||||
$_SESSION['width']=$postValues['gridWidth'];
|
|
||||||
$_SESSION['height']=$postValues['gridHeight'];
|
|
||||||
echo json_encode($grid); die;
|
|
||||||
|
|
||||||
die;
|
|
||||||
|
|
||||||
break;
|
|
||||||
case "fight":
|
|
||||||
|
|
||||||
if(count($_SESSION['strikes'][1]) == count($_SESSION['strikes'][2])){
|
|
||||||
//player 1 has to fight
|
|
||||||
$currentPlayer=1;
|
|
||||||
$currentBot=$_SESSION['bot1'];
|
|
||||||
$opponent=2;
|
|
||||||
$opponentName=$_SESSION['bot2']['name'];
|
|
||||||
}else{
|
}else{
|
||||||
//it's player2
|
$wantFullLogs = false;
|
||||||
$currentPlayer=2;
|
|
||||||
$currentBot=$_SESSION['bot2'];
|
|
||||||
$opponentName=$_SESSION['bot1']['name'];
|
|
||||||
$opponent=1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$botParamsToSend=array(
|
//check if bots exists
|
||||||
'game' => 'Battleship',
|
$bot1Exists = false;
|
||||||
'match_id' => $_SESSION['matchId']."-".$currentPlayer,
|
$bot2Exists = false;
|
||||||
'act' => 'fight',
|
foreach($bots as $bot){
|
||||||
'opponent' => $opponentName,
|
if($bot['id'] == $_POST['bot1']){
|
||||||
'width' => $_SESSION['width'],
|
|
||||||
'height' => $_SESSION['height'],
|
|
||||||
'ship1' => $_SESSION['ship1'],
|
|
||||||
'ship2' => $_SESSION['ship2'],
|
|
||||||
'ship3' => $_SESSION['ship3'],
|
|
||||||
'ship4' => $_SESSION['ship4'],
|
|
||||||
'ship5' => $_SESSION['ship5'],
|
|
||||||
'ship6' => $_SESSION['ship6'],
|
|
||||||
'your_strikes' => json_encode($_SESSION['strikes'][$currentPlayer]),
|
|
||||||
'his_strikes' => json_encode($_SESSION['strikes'][$opponent])
|
|
||||||
|
|
||||||
);
|
$bot1 = $bot;
|
||||||
$anwserPlayer=get_IA_Response($currentBot['url'],$botParamsToSend);
|
$_SESSION['bot1']=$bot;
|
||||||
|
$bot1Exists =true;
|
||||||
|
}
|
||||||
|
if($bot['id'] == $_POST['bot2']){
|
||||||
|
$bot2 = $bot;
|
||||||
|
$_SESSION['bot2']=$bot;
|
||||||
|
$bot2Exists =true;
|
||||||
|
}
|
||||||
|
if ($bot1Exists && $bot2Exists){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((!$bot1Exists) OR (!$bot2Exists)){
|
||||||
|
error (500,"missing parameter 2");
|
||||||
|
}
|
||||||
|
|
||||||
if(!preg_match('/^[0-9]+,[0-9]+$/',$anwserPlayer)){
|
|
||||||
echo json_encode(array(
|
|
||||||
'target' => '',
|
|
||||||
'log' => $currentBot['name']." a fait une réponse non conforme, il perd.".$anwserPlayer
|
|
||||||
));
|
|
||||||
save_battle('Battleship',$_SESSION['bot1']['name'],$_SESSION['bot2']['name'],$opponent);
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
list($x,$y)=explode(",",$anwserPlayer);
|
|
||||||
|
|
||||||
//check if shot is under map's limits
|
if(!is_it_possible_to_place_ships_on_grid($postValues['gridWidth'],$postValues['gridHeight'],
|
||||||
if(($x >= $_SESSION['width']) OR ($y >= $_SESSION['height'])){
|
$postValues['nbShip1'],$postValues['nbShip2'],$postValues['nbShip3'],
|
||||||
echo json_encode(array(
|
$postValues['nbShip4'],$postValues['nbShip5'],$postValues['nbShip6']))
|
||||||
'target' => '',
|
{
|
||||||
'log' => $currentBot['name']." a fait un tir en dehors des limites de la carte. ".$x.",".$y." C'est interdit par les conventions de Geneve. Il perd"
|
error (404,"grid is too little for these ships");
|
||||||
));
|
}
|
||||||
save_battle('Battleship',$_SESSION['bot1']['name'],$_SESSION['bot2']['name'],$opponent);
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
|
|
||||||
//put previous strikes in a one dimmension array ;
|
//******vars checked, lets init the initGame *******
|
||||||
$previousStrikes=array();
|
|
||||||
foreach( $_SESSION['strikes'][$currentPlayer] as $strikes){
|
|
||||||
$previousStrikes[]=$strikes['target'];
|
|
||||||
}
|
|
||||||
|
|
||||||
//do this strike hit a boat?
|
$_SESSION['matchId']=get_unique_id();
|
||||||
$continue=1;
|
$grid['logs'] = array();
|
||||||
$result='';
|
|
||||||
|
|
||||||
for( $shipIndex = 0; $shipIndex < count( $_SESSION['ships'][$opponent]); $shipIndex ++){
|
for($player = 1; $player <= 2; $player++){
|
||||||
$ennemyBoat = $_SESSION['ships'][$opponent][$shipIndex];
|
|
||||||
|
|
||||||
if(in_array($x.",".$y, $ennemyBoat)){
|
if($player==1){
|
||||||
$result='hit';
|
$opponentName=$bot2['name'];
|
||||||
//sunk?
|
$currentBot=$bot1;
|
||||||
$sunk=true;
|
}else{
|
||||||
foreach($ennemyBoat as $boatCase){
|
$opponentName=$bot1['name'];
|
||||||
if((!in_array($boatCase,$previousStrikes)) && ($boatCase <> $x.",".$y)) {
|
$currentBot=$bot2;
|
||||||
$sunk=false;
|
}
|
||||||
break;
|
|
||||||
}
|
$botParamsToSend=array(
|
||||||
|
'game-id' => $_SESSION['matchId'],
|
||||||
|
'game' => 'battleship',
|
||||||
|
'action' => 'init',
|
||||||
|
'players' => 2,
|
||||||
|
'player-index' => $player -1,
|
||||||
|
'board' => array(
|
||||||
|
'opponent' => $opponentName,
|
||||||
|
'width' => $postValues['gridWidth'],
|
||||||
|
'height' => $postValues['gridHeight'],
|
||||||
|
'ship1' => $postValues['nbShip1'],
|
||||||
|
'ship2' => $postValues['nbShip2'],
|
||||||
|
'ship3' => $postValues['nbShip3'],
|
||||||
|
'ship4' => $postValues['nbShip4'],
|
||||||
|
'ship5' => $postValues['nbShip5'],
|
||||||
|
'ship6' => $postValues['nbShip6']
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$anwserPlayerJson=get_IA_Response($currentBot['url'],$botParamsToSend);
|
||||||
|
if($wantFullLogs){
|
||||||
|
$fullLogs='Arena send to '.$currentBot['name'].'<em>'.htmlentities($anwserPlayerJson['messageSend']).'</em><br/>
|
||||||
|
HTTP status: <em>'.htmlentities($anwserPlayerJson['httpStatus']).'</em><br/>
|
||||||
|
Bot anwser: <em>'.htmlentities($anwserPlayerJson['response']).'</em><br/>';
|
||||||
|
}else{
|
||||||
|
$fullLogs="";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!isset($anwserPlayerJson['responseArr']['boats'])){
|
||||||
|
|
||||||
|
echo $fullLogs.$currentBot['name']." a fait une réponse non conforme, il perd 1.";
|
||||||
|
if($player==1){
|
||||||
|
save_battle('Battleship',$bot1['name'],$bot2['name'],2);
|
||||||
|
}else{
|
||||||
|
save_battle('Battleship',$bot1['name'],$bot2['name'],1);
|
||||||
|
}
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
|
||||||
|
$boatsPlayer = $anwserPlayerJson['responseArr']['boats'];
|
||||||
|
|
||||||
|
//init grid
|
||||||
|
for($y = 0; $y < $postValues['gridHeight']; $y++){
|
||||||
|
for($x = 0; $x < $postValues['gridWidth']; $x++){
|
||||||
|
$grid[$player][$y][$x]=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//vérifier si'il y a le bon nombre de bateaux et les placer
|
||||||
|
$nbBoatsIwant=array(0,$postValues['nbShip1'],$postValues['nbShip2'],$postValues['nbShip3'],
|
||||||
|
$postValues['nbShip4'],$postValues['nbShip5'],$postValues['nbShip6']);
|
||||||
|
|
||||||
|
foreach($boatsPlayer as $boat){
|
||||||
|
list($startCoord,$endCoord) = explode("-",$boat);
|
||||||
|
list($xStart,$yStart)=explode(",",$startCoord);
|
||||||
|
list($xEnd,$yEnd)=explode(",",$endCoord);
|
||||||
|
if($xStart == $xEnd){
|
||||||
|
$long=abs($yStart - $yEnd) +1;
|
||||||
|
}else{
|
||||||
|
$long=abs($xStart - $xEnd) +1;
|
||||||
|
}
|
||||||
|
$nbBoatsIwant[$long]-=1;
|
||||||
|
$grid[$player]=place_ship_on_map($xStart,$yStart,$xEnd,$yEnd,$grid[$player]);
|
||||||
|
if(!$grid[$player]){
|
||||||
|
echo $currentBot['name']." n'a pas placé correctement ses bateaux. Certains se chevauchent. Il perd.";
|
||||||
|
if($player==1){
|
||||||
|
save_battle('Battleship',$bot1['name'],$bot2['name'],2);
|
||||||
|
}else{
|
||||||
|
save_battle('Battleship',$bot1['name'],$bot2['name'],1);
|
||||||
|
}
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
//remember each cases of each boats
|
||||||
|
$boatListOfCases=array();
|
||||||
|
if($xStart == $xEnd){
|
||||||
|
if($yStart <= $yEnd ){
|
||||||
|
$start=$yStart;
|
||||||
|
$end=$yEnd;
|
||||||
|
}else{
|
||||||
|
$start=$yEnd;
|
||||||
|
$end=$yStart;
|
||||||
|
}
|
||||||
|
for($i = $start; $i <= $end; $i++){
|
||||||
|
$boatListOfCases[]=$xStart.",".$i;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if($xStart <= $xEnd ){
|
||||||
|
$start=$xStart;
|
||||||
|
$end=$xEnd;
|
||||||
|
}else{
|
||||||
|
$start=$xEnd;
|
||||||
|
$end=$xStart;
|
||||||
|
}
|
||||||
|
for($i = $start; $i <= $end; $i++){
|
||||||
|
$boatListOfCases[]=$i.",".$yStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$_SESSION['ships'][$player][]=$boatListOfCases;
|
||||||
|
}
|
||||||
|
foreach($nbBoatsIwant as $nb){
|
||||||
|
if($nb <> 0){
|
||||||
|
echo $fullLogs.$currentBot['name']." n'a pas placé le bon nombre de bateaux. Il perd.";
|
||||||
|
if($player==1){
|
||||||
|
save_battle('Battleship',$bot1['name'],$bot2['name'],2);
|
||||||
|
}else{
|
||||||
|
save_battle('Battleship',$bot1['name'],$bot2['name'],1);
|
||||||
|
}
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$grid['logs'][] = $fullLogs.$currentBot['name']." put his ships on the map.";
|
||||||
|
}
|
||||||
|
$_SESSION['ship1']=$postValues['nbShip1'];
|
||||||
|
$_SESSION['ship2']=$postValues['nbShip2'];
|
||||||
|
$_SESSION['ship3']=$postValues['nbShip3'];
|
||||||
|
$_SESSION['ship4']=$postValues['nbShip4'];
|
||||||
|
$_SESSION['ship5']=$postValues['nbShip5'];
|
||||||
|
$_SESSION['ship6']=$postValues['nbShip6'];
|
||||||
|
$_SESSION['strikes'][1]=array();
|
||||||
|
$_SESSION['strikes'][2]=array();
|
||||||
|
$_SESSION['width']=$postValues['gridWidth'];
|
||||||
|
$_SESSION['height']=$postValues['gridHeight'];
|
||||||
|
echo json_encode($grid); die;
|
||||||
|
|
||||||
|
die;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "fight":
|
||||||
|
if(($_POST['fullLogs'] <> 'true') && ($_POST['fullLogs'] <> 'false')){
|
||||||
|
error(500, 'wrong POST parameters');
|
||||||
|
die;
|
||||||
}
|
}
|
||||||
if($sunk){
|
if($_POST['fullLogs'] == 'true'){
|
||||||
$result="hit and sunk";
|
$wantFullLogs = true;
|
||||||
//remove the ship
|
}else{
|
||||||
unset($_SESSION['ships'][$opponent][$shipIndex]);
|
$wantFullLogs = false;
|
||||||
$_SESSION['ships'][$opponent] = array_values($_SESSION['ships'][$opponent]);
|
|
||||||
//var_dump($_SESSION['ships'][$opponent]);
|
|
||||||
//win the game?
|
|
||||||
if(count($_SESSION['ships'][$opponent]) == 0){
|
|
||||||
$result="hit sunk and win";
|
|
||||||
$continue=0;
|
|
||||||
save_battle('Battleship',$_SESSION['bot1']['name'],$_SESSION['bot2']['name'],$currentPlayer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
if(!isset($fullLogs)){
|
||||||
}
|
$fullLogs = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
//remember this shot
|
if(count($_SESSION['strikes'][1]) == count($_SESSION['strikes'][2])){
|
||||||
$_SESSION['strikes'][$currentPlayer][]=array(
|
//player 1 has to fight
|
||||||
'target' => $x.",".$y,
|
$currentPlayer=1;
|
||||||
'result' => $result
|
$currentBot=$_SESSION['bot1'];
|
||||||
);
|
$opponent=2;
|
||||||
|
$opponentName=$_SESSION['bot2']['name'];
|
||||||
|
}else{
|
||||||
|
//it's player2
|
||||||
|
$currentPlayer=2;
|
||||||
|
$currentBot=$_SESSION['bot2'];
|
||||||
|
$opponentName=$_SESSION['bot1']['name'];
|
||||||
|
$opponent=1;
|
||||||
|
}
|
||||||
|
|
||||||
//send message for the arena's ajax web page
|
$botParamsToSend=array(
|
||||||
echo json_encode(array(
|
'game' => 'Battleship',
|
||||||
'opponent'=> $opponent,
|
'game-id' => $_SESSION['matchId'],
|
||||||
'target' => $x.",".$y,
|
'action' => 'play-turn',
|
||||||
'log' => $currentBot['name']." tire en ".$x.",".$y." ".$result,
|
'player-index' => $currentPlayer - 1,
|
||||||
'continue' => $continue
|
'board' => array(
|
||||||
));
|
'opponent' => $opponentName,
|
||||||
|
'width' => $_SESSION['width'],
|
||||||
|
'height' => $_SESSION['height'],
|
||||||
|
'ship1' => $_SESSION['ship1'],
|
||||||
|
'ship2' => $_SESSION['ship2'],
|
||||||
|
'ship3' => $_SESSION['ship3'],
|
||||||
|
'ship4' => $_SESSION['ship4'],
|
||||||
|
'ship5' => $_SESSION['ship5'],
|
||||||
|
'ship6' => $_SESSION['ship6'],
|
||||||
|
'your_strikes' => $_SESSION['strikes'][$currentPlayer],
|
||||||
|
'his_strikes' => $_SESSION['strikes'][$opponent]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$anwserPlayer=get_IA_Response($currentBot['url'],$botParamsToSend);
|
||||||
|
$anwserPlayerJson=$anwserPlayer['responseArr'];
|
||||||
|
if($wantFullLogs){
|
||||||
|
$fullLogs.='Arena send to '.$currentBot['name'].'<em>'.htmlentities($anwserPlayer['messageSend']).'</em><br />
|
||||||
|
HTTP status: <em>'.htmlentities($anwserPlayer['httpStatus']).'</em><br />
|
||||||
|
Bot anwser: <em>'.htmlentities($anwserPlayer['response']).'</em><br />';
|
||||||
|
}else{
|
||||||
|
$fullLogs.="";
|
||||||
|
}
|
||||||
|
|
||||||
die;
|
|
||||||
break;
|
if ((!isset($anwserPlayerJson['play']))
|
||||||
default:
|
OR (!preg_match('/^[0-9]+,[0-9]+$/',$anwserPlayerJson['play']))){
|
||||||
break;
|
echo json_encode(array(
|
||||||
|
'target' => '',
|
||||||
|
'logs' => $fullLogs.$currentBot['name']." a fait une réponse non conforme, il perd."));
|
||||||
|
save_battle('Battleship',$_SESSION['bot1']['name'],$_SESSION['bot2']['name'],$opponent);
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
list($x,$y)=explode(",",$anwserPlayerJson['play']);
|
||||||
|
|
||||||
|
//check if shot is under map's limits
|
||||||
|
if(($x >= $_SESSION['width']) OR ($y >= $_SESSION['height'])){
|
||||||
|
echo json_encode(array(
|
||||||
|
'target' => '',
|
||||||
|
'logs' => $fullLogs.$currentBot['name']." a fait un tir en dehors des limites de la carte. ".$x.",".$y." C'est interdit par les conventions de Geneve. Il perd"
|
||||||
|
));
|
||||||
|
save_battle('Battleship',$_SESSION['bot1']['name'],$_SESSION['bot2']['name'],$opponent);
|
||||||
|
die;
|
||||||
|
}
|
||||||
|
|
||||||
|
//put previous strikes in a one dimmension array ;
|
||||||
|
$previousStrikes=array();
|
||||||
|
foreach( $_SESSION['strikes'][$currentPlayer] as $strikes){
|
||||||
|
$previousStrikes[]=$strikes['target'];
|
||||||
|
}
|
||||||
|
|
||||||
|
//do this strike hit a boat?
|
||||||
|
$continue=1;
|
||||||
|
$result='';
|
||||||
|
|
||||||
|
for( $shipIndex = 0; $shipIndex < count( $_SESSION['ships'][$opponent]); $shipIndex ++){
|
||||||
|
$ennemyBoat = $_SESSION['ships'][$opponent][$shipIndex];
|
||||||
|
|
||||||
|
if(in_array($x.",".$y, $ennemyBoat)){
|
||||||
|
$result='hit';
|
||||||
|
//sunk?
|
||||||
|
$sunk=true;
|
||||||
|
foreach($ennemyBoat as $boatCase){
|
||||||
|
if((!in_array($boatCase,$previousStrikes)) && ($boatCase <> $x.",".$y)) {
|
||||||
|
$sunk=false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($sunk){
|
||||||
|
$result="hit and sunk";
|
||||||
|
//remove the ship
|
||||||
|
unset($_SESSION['ships'][$opponent][$shipIndex]);
|
||||||
|
$_SESSION['ships'][$opponent] = array_values($_SESSION['ships'][$opponent]);
|
||||||
|
//var_dump($_SESSION['ships'][$opponent]);
|
||||||
|
//win the game?
|
||||||
|
if(count($_SESSION['ships'][$opponent]) == 0){
|
||||||
|
$result="hit sunk and win";
|
||||||
|
$continue=0;
|
||||||
|
save_battle('Battleship',$_SESSION['bot1']['name'],$_SESSION['bot2']['name'],$currentPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//remember this shot
|
||||||
|
$_SESSION['strikes'][$currentPlayer][]=array(
|
||||||
|
'target' => $x.",".$y,
|
||||||
|
'result' => $result
|
||||||
|
);
|
||||||
|
|
||||||
|
//send message for the arena's ajax web page
|
||||||
|
echo json_encode(array(
|
||||||
|
'opponent'=> $opponent,
|
||||||
|
'target' => $x.",".$y,
|
||||||
|
'logs' => $fullLogs.$currentBot['name']." tire en ".$x.",".$y." ".$result,
|
||||||
|
'continue' => $continue
|
||||||
|
));
|
||||||
|
|
||||||
|
die;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
|
@ -1,173 +1,62 @@
|
||||||
<p>
|
<h1>Fonctionnement de la bataille navale</h1>
|
||||||
Battleship is played in two stages :
|
<p>Elle se joue en deux phases</p>
|
||||||
</p>
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Boats placement on maps</li>
|
<li>Placement des bateaux sur les maps</li>
|
||||||
<li>Shootout</li>
|
<li>Echange de tirs</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>
|
<h2>Communications entre l'arène et votre bot</h2>
|
||||||
At each turn, the arena made HTTP(s) queries containing POST parameters, to your bots.<br/>
|
<p>Pour communiquer, l'arène (le serveur hébergeant botsarena) fait des requetes http(s) de type POST vers les bots. Le message est dans le corps de la requête au format JSON.</p>
|
||||||
They must respond to the specifications below.
|
<p>Votre bot répond par un array au format JSON.</p>
|
||||||
</p>
|
<h3>Message d'initialisation de votre partie</h3>
|
||||||
<h2>Descriptif des paramètres envoyés par l'arène</h2>
|
l'arène envoie le message suivant:
|
||||||
<table class="tabledoc">
|
<pre>{"game-id":1609,"game":"battleship","action":"init","players":2,"player-index":0,"board":{"opponent":"stupidIA","width":"10","height":"10","ship1":"0","ship2":"1","ship3":"2","ship4":"1","ship5":"1","ship6":"0"}}</pre>
|
||||||
<tr>
|
<p>Si on décompose le tableau pour l'expliquer:</p>
|
||||||
<th>Parameter</th>
|
<ul>
|
||||||
<th>Description</th>
|
<li><em>game-id</em> string identifiant la partie.</li>
|
||||||
</tr>
|
<li><em>action</em> string identifiant la phase, <em>init</em> tout de suite, sera <em>play-turn</em> dans le châpitre suivant.</li>
|
||||||
<tr>
|
<li><em>game</em> string identifiant le jeu. Ici, ce sera forcément battleship. ça peut servir si vous donnez une seule URL pour plusieurs bots.</li>
|
||||||
<td>game</td>
|
<li><em>players</em> Int indiquant le nombre de joueurs dans la partie, toujours 2 à la bataille navale.</li>
|
||||||
<td>
|
<li><em>player-index</em> int, L'ordre de votre bot dans les tours de jeu. Le premier joueur a la valeur 0, le deuxième 1.</li>
|
||||||
String, will always "Battleship".<br/>
|
<li><em>board</em> un tableau vous donnant les parametres:
|
||||||
Can be used if your url is used for several games.
|
<ul>
|
||||||
</td>
|
<li><em>opponent</em> Chaîne de caractères identifiant votre adversaire.
|
||||||
</tr>
|
Ainsi, vous pouvez pousser le délire jusqu'à faire un algorythme qui s'adapte en fonction de l'adversaire et de l'historique des combats avec ce dernier. </li>
|
||||||
<tr>
|
<li><em>width</em> Entier, compris entre 1 et 100, bornes incluses, vous indique la largeur de la map.</li>
|
||||||
<td>match_id</td>
|
<li><em>height</em> Entier, compris entre 1 et 100, bornes incluses, vous indique la hauteur de la map.</li>
|
||||||
<td>
|
<li><em>ship1</em> Entier, compris entre 0 et 10, bornes incluses, vous indique le nombre de bateaux de longeur 1 case à placer.</li>
|
||||||
String. Match the following regular expression : ^[0-9]+-(1|2)$<br/>
|
<li><em>ship2</em> Entier, compris entre 0 et 10, bornes incluses, vous indique le nombre de bateaux de longeur 2 cases à placer.</li>
|
||||||
The first number (digits before the hyphen) identified the game.<br/>
|
<li>...</li>
|
||||||
The number after the hyphen indicates whether you are the first or second bot in the order to play.<br/>
|
<li><em>ship6</em> Entier, compris entre 0 et 10, bornes incluses, vous indique le nombre de bateaux de longeur 6 cases à placer.</li>
|
||||||
It will serve you if your AI makes statistics on games.
|
</ul>
|
||||||
</td>
|
</li>
|
||||||
</tr>
|
</ul>
|
||||||
<tr>
|
<p>Votre bot doit retourner le nom de votre bot et le placement de vos bateaux au format JSON:</p>
|
||||||
<td>act</td>
|
<pre>
|
||||||
<td>
|
{"name":"gnieark","boats":["4,2-4,6","3,3-3,0","2,3-2,1","7,9-5,9","6,8-6,7"]}
|
||||||
Can take two values :<br/>
|
</pre>
|
||||||
<ul>
|
<ul>
|
||||||
<li>"init" : We start the game, you must place your ships</li>
|
<li><em>name</em> Le nom de votre bot (actuellment non pris en compte par cette arène).</li>
|
||||||
<li>"fight" : You send a shot</li>
|
<li><em>boats</em> Tableau indiquant le placement de vos bateaux</li>
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>opponent</td>
|
|
||||||
<td>
|
|
||||||
String identifying your opponent.<br/>
|
|
||||||
So you can grow up delirium by developping an algorithm that adapts depending on the opponent and the history of fighting with it.
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>width</td>
|
|
||||||
<td>Integer, between 1 and 100, inclusive, indicates the width of the map.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>height</td>
|
|
||||||
<td>Integer, between 1 and 100, inclusive, indicates the height of the map.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>ship1</td>
|
|
||||||
<td>Integer, between 0 and 10, inclusive, indicates the number of boats with length of 1 box to set.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>ship2</td>
|
|
||||||
<td>Integer, between 0 and 10, inclusive, indicates the number of boats with length of 2 box to set.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>...</td>
|
|
||||||
<td>...</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>ship6</td>
|
|
||||||
<td>Integer, between 0 and 10, inclusive, indicates the number of boats with length of 6 box to set.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>your_strikes</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
String, representing an array in JSON format.<br/>
|
|
||||||
This parameter is only sent when the game is in shooting phase (act=fight).<br/>
|
|
||||||
It tells you the shots you've already made and their results.<br/>
|
|
||||||
In the first round of play, it is an empty array.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<i>[ ]</i>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
In the second round of game, it contains the previous shot and the result :
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<i>[{"target":"2,0","result":""}]</i>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
In the third round of play, the two previous shots :
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<i>[{"target":"2,0","result":"hit"},{"target":"5,1","result":"hit"}]</i>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Each shot is a sub array for which :
|
|
||||||
</p>
|
|
||||||
<ul>
|
|
||||||
<li>The index target indicates the coordinates of the target shooting x,y</li>
|
|
||||||
<li>
|
|
||||||
result may be :
|
|
||||||
<ul>
|
|
||||||
<li>Empty "" means that the shot did not hit anything</li>
|
|
||||||
<li>"hit" An enemy ship has been hit</li>
|
|
||||||
<li>"hit and sunk" An enemy ship was hit and sunk</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>his_strikes</td>
|
|
||||||
<td>Same except that this is the shot of the opponent.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<h2>What must return your bot</h2>
|
|
||||||
<h3>During initialization of the game</h3>
|
|
||||||
<p>
|
|
||||||
Lors de l'initialisation d'une partie StupidIA VS StupidsIA, l'arène a envoyé au bot les parametres POST suivants :
|
|
||||||
During initialization of part StupidIA VS StupidIA, the arena send to your bot the following parameters in POST :
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
game=Battleship&match_id=828-1&act=init&opponent=stupidIA&width=10&height=10&ship1=0&ship2=1&ship3=2&ship4=1&ship5=1&ship6=0
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
Or, more readable :
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
[game] => Battleship
|
|
||||||
[match_id] => 828-1
|
|
||||||
[act] => init
|
|
||||||
[opponent] => stupidIA
|
|
||||||
[width] => 10
|
|
||||||
[height] => 10
|
|
||||||
[ship1] => 0
|
|
||||||
[ship2] => 1
|
|
||||||
[ship3] => 2
|
|
||||||
[ship4] => 1
|
|
||||||
[ship5] => 1
|
|
||||||
[ship6] => 0
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
The HTTP page that must generate your bot contains the position of ships.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
You return a character string that is a JSON array with as many records as ships.<br/>
|
|
||||||
Each ship is defined by the coordinates of its ends.
|
|
||||||
</p>
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>The grid starts at the point 0,0.</li>
|
<h3>boats</h3>
|
||||||
<li>Integers, ordinate and abscissa, defining a point, are separated by a comma ",".</li>
|
<li>La grille commence au point 0,0.</li>
|
||||||
<li>The two points defining the ends a ship shall be separated by a hyphen "-".</li>
|
<li>Les entiers, ordonnée et abscisses, définissant un point, sont séparés d'une virgule ",".</li>
|
||||||
|
<li>Les deux points définissant les extrémités d'un navire sont séparés par un tiret "-".</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h4>Placement example of 5 boats with respective sizes 5, 4, 3, 3, 2 boxes :</h4>
|
<h4>Exemple de placement de 5 bateaux tailles respectives 5, 4, 3, 3, 2 cases :</h4>
|
||||||
<pre>
|
<pre>
|
||||||
["3,3-3,7","2,1-2,4","0,1-0,3","7,3-7,1","8,8-7,8"]
|
["3,3-3,7","2,1-2,4","0,1-0,3","7,3-7,1","8,8-7,8"]
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
Of course if your boat overlap, or if their number and length does not match the demand of the arena, you lose the game.
|
Bien évidemment si vos bateaux se chevauchent, ou si leur nombre et leur longueur ne correspond pas à la demande de l'arène, vous perdez la partie.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
The order of the boats does not matter.<br/>
|
L'ordre des bateaux n'a pas d'importance.<br/>
|
||||||
Similarly, for a boat, the order of its points does not matter either.
|
De la même manière, pour un bateau, l'ordre de ses points n'importe pas non plus.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Seen on the grid, the example above would be :
|
Vu sur la grille, l'exemple précédent donnerait :
|
||||||
</p>
|
</p>
|
||||||
<table class="battleshipGrid nofloat" id="tbl1">
|
<table class="battleshipGrid nofloat" id="tbl1">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -314,65 +203,70 @@
|
||||||
<td class="empty" id="bot1-9-9"></td>
|
<td class="empty" id="bot1-9-9"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<h3>During the fight</h3>
|
|
||||||
<p>
|
<h3>Message vous demandant de jouer (seulement un tour)</h3>
|
||||||
Examples of parameters sent by the arena.
|
<p>L'arène vous envoie par exemple le message suivant:</p>
|
||||||
</p>
|
<pre>{"game":"Battleship","game-id":1615,"action":"play-turn","player-index":1,"board":{"opponent":"stupidIA","width":"10","height":"10","ship1":"0","ship2":"1","ship3":"2","ship4":"1","ship5":"1","ship6":"0","your_strikes":[{"target":"4,3","result":""},{"target":"9,8","result":""}],"his_strikes":[{"target":"2,2","result":""},{"target":"0,6","result":""},{"target":"7,0","result":""}]}}</pre>
|
||||||
<h4>First round (your_strikes and his_strikes are empty)</h4>
|
<ul>
|
||||||
<pre>
|
<li><em>game-id</em> String identifiant la partie.</li>
|
||||||
[game] => Battleship
|
<li><em>action</em> String identifiant la phase, <em>play-turn</em> tout de suite, qui vous indique que vous devez jouer.</li>
|
||||||
[match_id] => 834-1
|
<li><em>game</em> String identifiant le jeu. Ici, ce sera forcément battleship. ça peut servir si vous donnez une seulle URL pour plusieurs bots.</li>
|
||||||
[act] => fight
|
<li><em>players</em> Int indiquant le nombre de joueurs dans la partie, toujours 2 à la bataille navale.</li>
|
||||||
[opponent] => stupidIA
|
<li><em>board</em> La carte je donne le détail ci dessous</li>
|
||||||
[width] => 10
|
<li><em>you</em> String, Votre caractère dans la grille</li>
|
||||||
[height] => 10
|
<li><em>player-index</em> Int, L'ordre de votre bot dans les tours de jeu. Le premier joueur a la valeur 0, le deuxième 1.</li>
|
||||||
[ship1] => 0
|
</ul>
|
||||||
[ship2] => 1
|
<h4>la map</h4>
|
||||||
[ship3] => 2
|
<p>Elle est représentée par les éléments d'écrits à l'étape précédente et par deux sous tableaux your_strikes et his strikes</p>
|
||||||
[ship4] => 1
|
<ul>
|
||||||
[ship5] => 1
|
<li><em>opponent</em> Chaîne de caractères identifiant votre adversaire.
|
||||||
[ship6] => 0
|
Ainsi, vous pouvez pousser le délire jusqu'à faire un algorythme qui s'adapte en fonction de l'adversaire et de l'historique des combats avec ce dernier. </li>
|
||||||
[your_strikes] => []
|
<li><em>width</em> Entier, compris entre 1 et 100, bornes incluses, vous indique la largeur de la map.</li>
|
||||||
[his_strikes] => []
|
<li><em>height</em> Entier, compris entre 1 et 100, bornes incluses, vous indique la hauteur de la map.</li>
|
||||||
</pre>
|
<li><em>ship1</em> Entier, compris entre 0 et 10, bornes incluses, vous indique le nombre de bateaux de longeur 1 case à placer.</li>
|
||||||
<h4>Second round</h4>
|
<li><em>ship2</em> Entier, compris entre 0 et 10, bornes incluses, vous indique le nombre de bateaux de longeur 2 cases à placer.</li>
|
||||||
<pre>
|
<li>...</li>
|
||||||
[game] => Battleship
|
<li><em>ship6</em> Entier, compris entre 0 et 10, bornes incluses, vous indique le nombre de bateaux de longeur 6 cases à placer.</li>
|
||||||
[match_id] => 834-1
|
<li><em>your_strikes</em> tableau vous indiquant vos tirs précédents et eur résultat</li>
|
||||||
[act] => fight
|
<li><em>his_strikes</em> Idem, mais pour l'adversaire. Si ce dernier tire selon un modèle prédisible, vous saurez comment comment placer vos bateaux lors de la prochaine partie</li>
|
||||||
[opponent] => stupidIA
|
</ul>
|
||||||
[width] => 10
|
<h4> your_strikes et his_strikes</h4>
|
||||||
[height] => 10
|
|
||||||
[ship1] => 0
|
<p>Chaîne de caractères représentant un array au format JSON.<br/>
|
||||||
[ship2] => 1
|
Ce parametre n'est envoyé que lors de la phase de tirs du jeu (act=fight).<br/>
|
||||||
[ship3] => 2
|
Il vous indique les tirs que vous avez déjà effectués et leur résultats.<br/>
|
||||||
[ship4] => 1
|
Lors du premier tour de jeu, il représente un array vide:
|
||||||
[ship5] => 1
|
</p>
|
||||||
[ship6] => 0
|
<pre>[ ]</pre>
|
||||||
[your_strikes] => [{"target":"4,6","result":""}]
|
<p>
|
||||||
[his_strikes] => [{"target":"7,8","result":""}]
|
Lors du deuxième tour de jeu, il contient le tir précédent et son résultat :
|
||||||
</pre>
|
</p>
|
||||||
<h4>Third round</h4>
|
<pre>[{"target":"2,0","result":""}]</pre>
|
||||||
<pre>
|
<p>
|
||||||
[game] => Battleship
|
Lors du troisième tour de jeu, les deux tirs précédents :
|
||||||
[match_id] => 834-1
|
</p>
|
||||||
[act] => fight
|
<pre>[{"target":"2,0","result":"hit"},{"target":"5,1","result":"hit"}]</pre>
|
||||||
[opponent] => stupidIA
|
<p>
|
||||||
[width] => 10
|
Chaque tir est un sous array pour lesquels:
|
||||||
[height] => 10
|
</p>
|
||||||
[ship1] => 0
|
<ul>
|
||||||
[ship2] => 1
|
<li>L'index target indique les coordonnées du tir x,y</li>
|
||||||
[ship3] => 2
|
<li>
|
||||||
[ship4] => 1
|
result peut être :
|
||||||
[ship5] => 1
|
<ul>
|
||||||
[ship6] => 0
|
<li>Vide "" signifie que le tir n'a rien touché</li>
|
||||||
[your_strikes] => [{"target":"4,6","result":""},{"target":"3,9","result":"hit"}]
|
<li>"hit" Un navire ennemi a été touché</li>
|
||||||
[his_strikes] => [{"target":"7,8","result":""},{"target":"7,8","result":""}]
|
<li>"hit and sunk" Un navire ennemi a été touché et coulé</li>
|
||||||
</pre>
|
</ul>
|
||||||
<h4>You simply need to return the address of the box where you want to shoot in the form of x,y</h4>
|
</li>
|
||||||
<pre>
|
</ul>
|
||||||
6,9
|
|
||||||
</pre>
|
<h3>Réponse de votre bot</h3>
|
||||||
<p>
|
<p>Il doit répondre par les coordonnées de la case dans laquelle il souhaite effectuer un tir.</p>
|
||||||
To shoot on the coordinates x=6 y=9
|
<pre>{"play":"1,8"}</pre>
|
||||||
</p>
|
<p>x,y</p>
|
||||||
|
<h2>Outils pour développer et tester votre bot</h2>
|
||||||
|
|
||||||
|
<h3>Script Botsarena en cours de développement</h3>
|
||||||
|
<h2>Faire entrer votre bot dans cette arène</h2>
|
||||||
|
<p>Le formulaire d'inscription de votre bot est sur la page d'accueil du site.</p>
|
|
@ -1,155 +1,45 @@
|
||||||
<p>
|
<h1>Fonctionnement de la bataille navale</h1>
|
||||||
La bataille navale se joue en deux phases :
|
<p>Elle se joue en deux phases</p>
|
||||||
</p>
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Placement des bateaux sur les maps</li>
|
<li>Placement des bateaux sur les maps</li>
|
||||||
<li>Echange de tirs</li>
|
<li>Echange de tirs</li>
|
||||||
</ul>
|
</ul>
|
||||||
<p>
|
<h2>Communications entre l'arène et votre bot</h2>
|
||||||
A chaque tour de jeu l'arène fait des requetes http(s) contenant des paramètres de type POST, vers vos bots.<br/>
|
<p>Pour communiquer, l'arène (le serveur hébergeant botsarena) fait des requetes http(s) de type POST vers les bots. Le message est dans le corps de la requête au format JSON.</p>
|
||||||
Ces derniers doivent répondre selon les spécifications ci dessous.
|
<p>Votre bot répond par un array au format JSON.</p>
|
||||||
</p>
|
<h3>Message d'initialisation de votre partie</h3>
|
||||||
<h2>Descriptif des paramètres envoyés par l'arène</h2>
|
l'arène envoie le message suivant:
|
||||||
<table class="tabledoc">
|
<pre>{"game-id":1609,"game":"battleship","action":"init","players":2,"player-index":0,"board":{"opponent":"stupidIA","width":"10","height":"10","ship1":"0","ship2":"1","ship3":"2","ship4":"1","ship5":"1","ship6":"0"}}</pre>
|
||||||
<tr>
|
<p>Si on décompose le tableau pour l'expliquer:</p>
|
||||||
<th>Paramètre</th>
|
<ul>
|
||||||
<th>Description</th>
|
<li><em>game-id</em> string identifiant la partie.</li>
|
||||||
</tr>
|
<li><em>action</em> string identifiant la phase, <em>init</em> tout de suite, sera <em>play-turn</em> dans le châpitre suivant.</li>
|
||||||
<tr>
|
<li><em>game</em> string identifiant le jeu. Ici, ce sera forcément battleship. ça peut servir si vous donnez une seule URL pour plusieurs bots.</li>
|
||||||
<td>game</td>
|
<li><em>players</em> Int indiquant le nombre de joueurs dans la partie, toujours 2 à la bataille navale.</li>
|
||||||
<td>
|
<li><em>player-index</em> int, L'ordre de votre bot dans les tours de jeu. Le premier joueur a la valeur 0, le deuxième 1.</li>
|
||||||
Chaîne de caractères, sera toujours "Battleship".<br/>
|
<li><em>board</em> un tableau vous donnant les parametres:
|
||||||
Peut servir si votre url sert à plusieurs jeux.
|
<ul>
|
||||||
</td>
|
<li><em>opponent</em> Chaîne de caractères identifiant votre adversaire.
|
||||||
</tr>
|
Ainsi, vous pouvez pousser le délire jusqu'à faire un algorythme qui s'adapte en fonction de l'adversaire et de l'historique des combats avec ce dernier. </li>
|
||||||
<tr>
|
<li><em>width</em> Entier, compris entre 1 et 100, bornes incluses, vous indique la largeur de la map.</li>
|
||||||
<td>match_id</td>
|
<li><em>height</em> Entier, compris entre 1 et 100, bornes incluses, vous indique la hauteur de la map.</li>
|
||||||
<td>
|
<li><em>ship1</em> Entier, compris entre 0 et 10, bornes incluses, vous indique le nombre de bateaux de longeur 1 case à placer.</li>
|
||||||
Chaîne de caractères. Répond à l'expression régulière suivante: ^[0-9]+-(1|2)$<br/>
|
<li><em>ship2</em> Entier, compris entre 0 et 10, bornes incluses, vous indique le nombre de bateaux de longeur 2 cases à placer.</li>
|
||||||
Le premier nombre (digits avant le tiret) identifie le match.<br/>
|
<li>...</li>
|
||||||
Le numéro après le tiret vous indique si vous êtes le bot 1 ou le bot 2 dans l'ordre de jeu.<br/>
|
<li><em>ship6</em> Entier, compris entre 0 et 10, bornes incluses, vous indique le nombre de bateaux de longeur 6 cases à placer.</li>
|
||||||
Ça vous servira si votre IA fait des statistiques sur les matchs.
|
</ul>
|
||||||
</td>
|
</li>
|
||||||
</tr>
|
</ul>
|
||||||
<tr>
|
<p>Votre bot doit retourner le nom de votre bot et le placement de vos bateaux au format JSON:</p>
|
||||||
<td>act</td>
|
<pre>
|
||||||
<td>
|
{"name":"gnieark","boats":["4,2-4,6","3,3-3,0","2,3-2,1","7,9-5,9","6,8-6,7"]}
|
||||||
Peut prendre deux valeurs :<br/>
|
</pre>
|
||||||
<ul>
|
<ul>
|
||||||
<li>"init" : On démarre la partie, vous devez placer vos bateaux</li>
|
<li><em>name</em> Le nom de votre bot (actuellment non pris en compte par cette arène).</li>
|
||||||
<li>"fight" : Vous envoyez un tir</li>
|
<li><em>boats</em> Tableau indiquant le placement de vos bateaux</li>
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>opponent</td>
|
|
||||||
<td>
|
|
||||||
Chaîne de caractères identifiant votre adversaire.<br/>
|
|
||||||
Ainsi, vous pouvez pousser le délire jusqu'à faire un algorythme qui s'adapte en fonction de l'adversaire et de l'historique des combats avec ce dernier.
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>width</td>
|
|
||||||
<td>Entier, compris entre 1 et 100, bornes incluses, vous indique la largeur de la map.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>height</td>
|
|
||||||
<td>Entier, compris entre 1 et 100, bornes incluses, vous indique la hauteur de la map.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>ship1</td>
|
|
||||||
<td>Entier, compris entre 0 et 10, bornes incluses, vous indique le nombre de bateaux de longeur 1 case à placer.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>ship2</td>
|
|
||||||
<td>Entier, compris entre 0 et 10, bornes incluses, vous indique le nombre de bateaux de longeur 2 cases à placer.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>...</td>
|
|
||||||
<td>...</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>ship6</td>
|
|
||||||
<td>Entier, compris entre 0 et 10, bornes incluses, vous indique le nombre de bateaux de longeur 6 cases à placer.</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>your_strikes</td>
|
|
||||||
<td>
|
|
||||||
<p>
|
|
||||||
Chaîne de caractères représentant un array au format JSON.<br/>
|
|
||||||
Ce parametre n'est envoyé que lors de la phase de tirs du jeu (act=fight).<br/>
|
|
||||||
Il vous indique les tirs que vous avez déjà effectués et leur résultats.<br/>
|
|
||||||
Lors du premier tour de jeu, il représente un array vide.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<i>[ ]</i>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Lors du deuxième tour de jeu, il contient le tir précédent et son résultat :
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<i>[{"target":"2,0","result":""}]</i>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Lors du troisième tour de jeu, les deux tirs précédents :
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<i>[{"target":"2,0","result":"hit"},{"target":"5,1","result":"hit"}]</i>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Chaque tir est un sous array pour lesquels:
|
|
||||||
</p>
|
|
||||||
<ul>
|
|
||||||
<li>L'index target indique les coordonnées du tir x,y</li>
|
|
||||||
<li>
|
|
||||||
result peut être :
|
|
||||||
<ul>
|
|
||||||
<li>Vide "" signifie que le tir n'a rien touché</li>
|
|
||||||
<li>"hit" Un navire ennemi a été touché</li>
|
|
||||||
<li>"hit and sunk" Un navire ennemi a été touché et coulé</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>his_strikes</td>
|
|
||||||
<td>Idem sauf qu'il s'agit du tir de l'adversaire.</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<h2>Ce que doit retourner votre bot</h2>
|
|
||||||
<h3>Lors de l'initialisation de la partie</h3>
|
|
||||||
<p>
|
|
||||||
Lors de l'initialisation d'une partie StupidIA VS StupidsIA, l'arène a envoyé au bot les parametres POST suivants :
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
game=Battleship&match_id=828-1&act=init&opponent=stupidIA&width=10&height=10&ship1=0&ship2=1&ship3=2&ship4=1&ship5=1&ship6=0
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
Soit, sous forme plus lisible :
|
|
||||||
</p>
|
|
||||||
<pre>
|
|
||||||
[game] => Battleship
|
|
||||||
[match_id] => 828-1
|
|
||||||
[act] => init
|
|
||||||
[opponent] => stupidIA
|
|
||||||
[width] => 10
|
|
||||||
[height] => 10
|
|
||||||
[ship1] => 0
|
|
||||||
[ship2] => 1
|
|
||||||
[ship3] => 2
|
|
||||||
[ship4] => 1
|
|
||||||
[ship5] => 1
|
|
||||||
[ship6] => 0
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
La page http que doit générer votre bot contient la position des navires.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Vous retournez une chaine de caractères qui est un tableau JSON ayant autant d'enregistrements que de navires.<br/>
|
|
||||||
Chaque navire est défini par les coordonnées de ses extrémités.
|
|
||||||
</p>
|
|
||||||
<ul>
|
<ul>
|
||||||
|
<h3>boats</h3>
|
||||||
<li>La grille commence au point 0,0.</li>
|
<li>La grille commence au point 0,0.</li>
|
||||||
<li>Les entiers, ordonnée et abscisses, définissant un point, sont séparés d'une virgule ",".</li>
|
<li>Les entiers, ordonnée et abscisses, définissant un point, sont séparés d'une virgule ",".</li>
|
||||||
<li>Les deux points définissant les extrémités d'un navire sont séparés par un tiret "-".</li>
|
<li>Les deux points définissant les extrémités d'un navire sont séparés par un tiret "-".</li>
|
||||||
|
@ -313,65 +203,70 @@
|
||||||
<td class="empty" id="bot1-9-9"></td>
|
<td class="empty" id="bot1-9-9"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<h3>Lors du combat</h3>
|
|
||||||
<p>
|
<h3>Message vous demandant de jouer (seulement un tour)</h3>
|
||||||
Voici quelques exemples des parametres envoyés par l'arène.
|
<p>L'arène vous envoie par exemple le message suivant:</p>
|
||||||
</p>
|
<pre>{"game":"Battleship","game-id":1615,"action":"play-turn","player-index":1,"board":{"opponent":"stupidIA","width":"10","height":"10","ship1":"0","ship2":"1","ship3":"2","ship4":"1","ship5":"1","ship6":"0","your_strikes":[{"target":"4,3","result":""},{"target":"9,8","result":""}],"his_strikes":[{"target":"2,2","result":""},{"target":"0,6","result":""},{"target":"7,0","result":""}]}}</pre>
|
||||||
<h4>Premier tour de jeu (your_strikes et his_strikes sont vides)</h4>
|
<ul>
|
||||||
<pre>
|
<li><em>game-id</em> String identifiant la partie.</li>
|
||||||
[game] => Battleship
|
<li><em>action</em> String identifiant la phase, <em>play-turn</em> tout de suite, qui vous indique que vous devez jouer.</li>
|
||||||
[match_id] => 834-1
|
<li><em>game</em> String identifiant le jeu. Ici, ce sera forcément battleship. ça peut servir si vous donnez une seulle URL pour plusieurs bots.</li>
|
||||||
[act] => fight
|
<li><em>players</em> Int indiquant le nombre de joueurs dans la partie, toujours 2 à la bataille navale.</li>
|
||||||
[opponent] => stupidIA
|
<li><em>board</em> La carte je donne le détail ci dessous</li>
|
||||||
[width] => 10
|
<li><em>you</em> String, Votre caractère dans la grille</li>
|
||||||
[height] => 10
|
<li><em>player-index</em> Int, L'ordre de votre bot dans les tours de jeu. Le premier joueur a la valeur 0, le deuxième 1.</li>
|
||||||
[ship1] => 0
|
</ul>
|
||||||
[ship2] => 1
|
<h4>la map</h4>
|
||||||
[ship3] => 2
|
<p>Elle est représentée par les éléments d'écrits à l'étape précédente et par deux sous tableaux your_strikes et his strikes</p>
|
||||||
[ship4] => 1
|
<ul>
|
||||||
[ship5] => 1
|
<li><em>opponent</em> Chaîne de caractères identifiant votre adversaire.
|
||||||
[ship6] => 0
|
Ainsi, vous pouvez pousser le délire jusqu'à faire un algorythme qui s'adapte en fonction de l'adversaire et de l'historique des combats avec ce dernier. </li>
|
||||||
[your_strikes] => []
|
<li><em>width</em> Entier, compris entre 1 et 100, bornes incluses, vous indique la largeur de la map.</li>
|
||||||
[his_strikes] => []
|
<li><em>height</em> Entier, compris entre 1 et 100, bornes incluses, vous indique la hauteur de la map.</li>
|
||||||
</pre>
|
<li><em>ship1</em> Entier, compris entre 0 et 10, bornes incluses, vous indique le nombre de bateaux de longeur 1 case à placer.</li>
|
||||||
<h4>Deuxième tour de jeu</h4>
|
<li><em>ship2</em> Entier, compris entre 0 et 10, bornes incluses, vous indique le nombre de bateaux de longeur 2 cases à placer.</li>
|
||||||
<pre>
|
<li>...</li>
|
||||||
[game] => Battleship
|
<li><em>ship6</em> Entier, compris entre 0 et 10, bornes incluses, vous indique le nombre de bateaux de longeur 6 cases à placer.</li>
|
||||||
[match_id] => 834-1
|
<li><em>your_strikes</em> tableau vous indiquant vos tirs précédents et eur résultat</li>
|
||||||
[act] => fight
|
<li><em>his_strikes</em> Idem, mais pour l'adversaire. Si ce dernier tire selon un modèle prédisible, vous saurez comment comment placer vos bateaux lors de la prochaine partie</li>
|
||||||
[opponent] => stupidIA
|
</ul>
|
||||||
[width] => 10
|
<h4> your_strikes et his_strikes</h4>
|
||||||
[height] => 10
|
|
||||||
[ship1] => 0
|
<p>Chaîne de caractères représentant un array au format JSON.<br/>
|
||||||
[ship2] => 1
|
Ce parametre n'est envoyé que lors de la phase de tirs du jeu (act=fight).<br/>
|
||||||
[ship3] => 2
|
Il vous indique les tirs que vous avez déjà effectués et leur résultats.<br/>
|
||||||
[ship4] => 1
|
Lors du premier tour de jeu, il représente un array vide:
|
||||||
[ship5] => 1
|
</p>
|
||||||
[ship6] => 0
|
<pre>[ ]</pre>
|
||||||
[your_strikes] => [{"target":"4,6","result":""}]
|
<p>
|
||||||
[his_strikes] => [{"target":"7,8","result":""}]
|
Lors du deuxième tour de jeu, il contient le tir précédent et son résultat :
|
||||||
</pre>
|
</p>
|
||||||
<h4>Troisième tour de jeu</h4>
|
<pre>[{"target":"2,0","result":""}]</pre>
|
||||||
<pre>
|
<p>
|
||||||
[game] => Battleship
|
Lors du troisième tour de jeu, les deux tirs précédents :
|
||||||
[match_id] => 834-1
|
</p>
|
||||||
[act] => fight
|
<pre>[{"target":"2,0","result":"hit"},{"target":"5,1","result":"hit"}]</pre>
|
||||||
[opponent] => stupidIA
|
<p>
|
||||||
[width] => 10
|
Chaque tir est un sous array pour lesquels:
|
||||||
[height] => 10
|
</p>
|
||||||
[ship1] => 0
|
<ul>
|
||||||
[ship2] => 1
|
<li>L'index target indique les coordonnées du tir x,y</li>
|
||||||
[ship3] => 2
|
<li>
|
||||||
[ship4] => 1
|
result peut être :
|
||||||
[ship5] => 1
|
<ul>
|
||||||
[ship6] => 0
|
<li>Vide "" signifie que le tir n'a rien touché</li>
|
||||||
[your_strikes] => [{"target":"4,6","result":""},{"target":"3,9","result":"hit"}]
|
<li>"hit" Un navire ennemi a été touché</li>
|
||||||
[his_strikes] => [{"target":"7,8","result":""},{"target":"7,8","result":""}]
|
<li>"hit and sunk" Un navire ennemi a été touché et coulé</li>
|
||||||
</pre>
|
</ul>
|
||||||
<h4>Vous devez tout simplement retourner l'adresse de la case sur laquelle vous souhaitez tirer sous forme de x,y</h4>
|
</li>
|
||||||
<pre>
|
</ul>
|
||||||
6,9
|
|
||||||
</pre>
|
<h3>Réponse de votre bot</h3>
|
||||||
<p>
|
<p>Il doit répondre par les coordonnées de la case dans laquelle il souhaite effectuer un tir.</p>
|
||||||
Pour tirer aux coordonnées x=6 y=9
|
<pre>{"play":"1,8"}</pre>
|
||||||
</p>
|
<p>x,y</p>
|
||||||
|
<h2>Outils pour développer et tester votre bot</h2>
|
||||||
|
|
||||||
|
<h3>Script Botsarena en cours de développement</h3>
|
||||||
|
<h2>Faire entrer votre bot dans cette arène</h2>
|
||||||
|
<p>Le formulaire d'inscription de votre bot est sur la page d'accueil du site.</p>
|
|
@ -76,18 +76,6 @@ function generate_numeric_select($start,$end,$selected,$name,$id){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 place_ship_on_map($x1,$y1,$x2,$y2,$map){
|
function place_ship_on_map($x1,$y1,$x2,$y2,$map){
|
||||||
if ((($x1 <> $x2) && ($y1 <> $y2))
|
if ((($x1 <> $x2) && ($y1 <> $y2))
|
||||||
OR (!isset($map[$y1][$x1]))
|
OR (!isset($map[$y1][$x1]))
|
||||||
|
|
|
@ -19,7 +19,7 @@ function createElem(type,attributes)
|
||||||
{elem.setAttribute(i,attributes[i]);}
|
{elem.setAttribute(i,attributes[i]);}
|
||||||
return elem;
|
return elem;
|
||||||
}
|
}
|
||||||
function fight(xd_check){
|
function fight(xd_check,fullLogs,gameId){
|
||||||
var xhr = Ajx();
|
var xhr = Ajx();
|
||||||
xhr.onreadystatechange = function(){if(xhr.readyState == 4){
|
xhr.onreadystatechange = function(){if(xhr.readyState == 4){
|
||||||
if(xhr.status == 200) {
|
if(xhr.status == 200) {
|
||||||
|
@ -34,11 +34,11 @@ function fight(xd_check){
|
||||||
document.getElementById( 'bot' + strike['opponent'] + '-' + coords[1] + '-' + coords[0]).innerHTML = "X";
|
document.getElementById( 'bot' + strike['opponent'] + '-' + coords[1] + '-' + coords[0]).innerHTML = "X";
|
||||||
}
|
}
|
||||||
var p=createElem("p");
|
var p=createElem("p");
|
||||||
p.innerHTML=strike['log'];
|
p.innerHTML=strike['logs'];
|
||||||
document.getElementById('logs').appendChild(p);
|
document.getElementById('logs').appendChild(p);
|
||||||
document.getElementById("logs").scrollTop=document.getElementById("logs").scrollHeight;
|
document.getElementById("logs").scrollTop=document.getElementById("logs").scrollHeight;
|
||||||
if( strike['continue'] == 1){
|
if( strike['continue'] == 1){
|
||||||
fight(xd_check);
|
fight(xd_check,fullLogs,gameId);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,11 +46,11 @@ function fight(xd_check){
|
||||||
}};
|
}};
|
||||||
xhr.open("POST", '/Battleship', true);
|
xhr.open("POST", '/Battleship', true);
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
xhr.send('act=fight&xd_check=' + xd_check);
|
xhr.send('act=fight&xd_check=' + xd_check + '&fullLogs=' + fullLogs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShip4,nbShip5,nbShip6,xd_check){
|
function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShip4,nbShip5,nbShip6,xd_check,fullLogs){
|
||||||
|
|
||||||
var shipsArea= parseInt(nbShip1) + 2 * parseInt(nbShip2) + 3 * parseInt(nbShip3) + 4 * parseInt(nbShip4) + 5 * parseInt(nbShip5) + 6 * parseInt(nbShip6);
|
var shipsArea= parseInt(nbShip1) + 2 * parseInt(nbShip2) + 3 * parseInt(nbShip3) + 4 * parseInt(nbShip4) + 5 * parseInt(nbShip5) + 6 * parseInt(nbShip6);
|
||||||
if(shipsArea > parseInt(gridWidth * gridHeight / 2) ){
|
if(shipsArea > parseInt(gridWidth * gridHeight / 2) ){
|
||||||
|
@ -131,10 +131,12 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var p=createElem("p");
|
for (var i = 0; i < grids['logs'].length; i++) {
|
||||||
p.innerHTML='players placed theirs ships';
|
var p = createElem("p");
|
||||||
document.getElementById('logs').appendChild(p);
|
p.innerHTML = grids['logs'][i];
|
||||||
fight(xd_check);
|
document.getElementById('logs').appendChild(p);
|
||||||
|
}
|
||||||
|
fight(xd_check,fullLogs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}};
|
}};
|
||||||
|
@ -152,6 +154,7 @@ function battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShi
|
||||||
+ '&nbShip5=' + nbShip5
|
+ '&nbShip5=' + nbShip5
|
||||||
+ '&nbShip6=' + nbShip6
|
+ '&nbShip6=' + nbShip6
|
||||||
+ '&xd_check=' + xd_check
|
+ '&xd_check=' + xd_check
|
||||||
|
+ '&fullLogs=' + fullLogs
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,10 +1,21 @@
|
||||||
<article>
|
<!--<article>
|
||||||
<h2>Cette arène est en cours de maintenance, elle sera de nouveau prête dans les prochains jours</h2>
|
<h2>Cette arène est en cours de maintenance, elle sera de nouveau prête dans les prochains jours</h2>
|
||||||
<p><img style="width: 100%;" src="/imgs/Arenes-Nimes.jpg" alt="travaux sur les arènes de Nimes"/></p>
|
<p><img style="width: 100%;" src="/imgs/Arenes-Nimes.jpg" alt="travaux sur les arènes de Nimes"/></p>
|
||||||
|
|
||||||
</article>
|
</article>-->
|
||||||
<?php
|
<?php
|
||||||
/*
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
|
|
||||||
require_once(__DIR__."/functions.php");
|
require_once(__DIR__."/functions.php");
|
||||||
|
|
||||||
$bots=get_Bots_Array('Battleship');
|
$bots=get_Bots_Array('Battleship');
|
||||||
|
@ -55,9 +66,7 @@ if(!$postParams){
|
||||||
?>
|
?>
|
||||||
</select></em>
|
</select></em>
|
||||||
</p>
|
</p>
|
||||||
<!-- battleship(bot1,bot2,gridWidth,gridHeight,nbShip1,nbShip2,nbShip3,nbShip4,nbShip5,nbShip6,xd_check) -->
|
<p><input type="checkbox" id="fullLogs"/><label for="fullLogs">view the full logs</label></p>
|
||||||
<p><label> </label><input type="button" value="<?php echo $lang['FIGHT']; ?>" onclick="battleship(document.getElementById('bot1').value,document.getElementById('bot2').value,getElementById('width').value,getElementById('height').value,getElementById('ship1').value,getElementById('ship2').value,getElementById('ship3').value,getElementById('ship4').value,getElementById('ship5').value,getElementById('ship6').value,'<?php echo xd_check_input(2); ?>');"></p>
|
<p><label> </label><input type="button" value="<?php echo $lang['FIGHT']; ?>" onclick="battleship(document.getElementById('bot1').value,document.getElementById('bot2').value,getElementById('width').value,getElementById('height').value,getElementById('ship1').value,getElementById('ship2').value,getElementById('ship3').value,getElementById('ship4').value,getElementById('ship5').value,getElementById('ship6').value,'<?php echo xd_check_input(2); ?>',document.getElementById('fullLogs').checked);"></p>
|
||||||
<div id="fightResult"></div>
|
<div id="fightResult"></div>
|
||||||
</article
|
</article>
|
||||||
*/
|
|
||||||
?>
|
|
|
@ -4,6 +4,7 @@ article p select {}
|
||||||
td{min-width: 15px; height: 15px;}
|
td{min-width: 15px; height: 15px;}
|
||||||
#fightResult{display:table;}
|
#fightResult{display:table;}
|
||||||
#logs{display:block;padding-left:10px; height: 200px; overflow-y: scroll;}
|
#logs{display:block;padding-left:10px; height: 200px; overflow-y: scroll;}
|
||||||
|
#logs em {color: grey; font-size: 70%; test-transform:italic;}
|
||||||
.battleshipGrid{display:table-cell; padding-left:10px; border-collapse:collapse; margin: 20px 20px 20px 20px;}
|
.battleshipGrid{display:table-cell; padding-left:10px; border-collapse:collapse; margin: 20px 20px 20px 20px;}
|
||||||
.nofloat{float: none;}
|
.nofloat{float: none;}
|
||||||
.battleshipGrid tr{}
|
.battleshipGrid tr{}
|
||||||
|
|
|
@ -1,4 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
require_once(__DIR__."/functions.php");
|
require_once(__DIR__."/functions.php");
|
||||||
$bots=get_Bots_Array('connectFou');
|
$bots=get_Bots_Array('connectFou');
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<li><em>players</em> Int indicating the number of players in the game, still 2 on connect Four.</li>
|
<li><em>players</em> Int indicating the number of players in the game, still 2 on connect Four.</li>
|
||||||
<li><em>board</em> The map, i'll explain it at next chapter</li>
|
<li><em>board</em> The map, i'll explain it at next chapter</li>
|
||||||
<li><em>you</em> String, Your bot's character on the grid</li>
|
<li><em>you</em> String, Your bot's character on the grid</li>
|
||||||
<li><em>player-index</em> Int The order of your bot in turns. The first player is 0, second is 2.</li>
|
<li><em>player-index</em> Int The order of your bot in turns. The first player is 0, second is 1.</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h4>The map</h4>
|
<h4>The map</h4>
|
||||||
<p> It is represented by a sub-array, on the "board" parameter.<br/>Exemple:</p>
|
<p> It is represented by a sub-array, on the "board" parameter.<br/>Exemple:</p>
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
function get_Post_Params($botsCount){
|
function get_Post_Params($botsCount){
|
||||||
$keysBots=array('bot1','bot2');
|
$keysBots=array('bot1','bot2');
|
||||||
foreach($keysBots as $botKey){
|
foreach($keysBots as $botKey){
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
require_once(__DIR__."/functions.php");
|
require_once(__DIR__."/functions.php");
|
||||||
$bots=get_Bots_Array('connectFou');
|
$bots=get_Bots_Array('connectFou');
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,4 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
require_once(__DIR__."/functions.php");
|
require_once(__DIR__."/functions.php");
|
||||||
switch ($_POST['act']){
|
switch ($_POST['act']){
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
function get_Post_Params($botsCount){
|
function get_Post_Params($botsCount){
|
||||||
$keysBots=array('bot1','bot2');
|
$keysBots=array('bot1','bot2');
|
||||||
foreach($keysBots as $botKey){
|
foreach($keysBots as $botKey){
|
||||||
|
@ -15,22 +26,3 @@ function get_Post_Params($botsCount){
|
||||||
}
|
}
|
||||||
return array('bot1' => $_POST['bot1'],'bot2' => $_POST['bot2']);
|
return array('bot1' => $_POST['bot1'],'bot2' => $_POST['bot2']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
function get_Bots_Array(){
|
|
||||||
//Recupérer la liste des Bots
|
|
||||||
$bots=array();
|
|
||||||
$botsList=explode("\n",file_get_contents(__DIR__."/listOfBots.txt"));
|
|
||||||
|
|
||||||
foreach($botsList as $botLigne){
|
|
||||||
if(preg_match("/\ (http|https):\/\//", $botLigne)){
|
|
||||||
list($name,$url)=explode(" ",$botLigne);
|
|
||||||
$bots[]=array("name" => $name, "url" =>$url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $bots;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
require_once(__DIR__."/functions.php");
|
require_once(__DIR__."/functions.php");
|
||||||
|
|
||||||
$bots=get_Bots_Array('tictactoe');
|
$bots=get_Bots_Array('tictactoe');
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
$arenas=array(
|
$arenas=array(
|
||||||
array(
|
array(
|
||||||
'id' => "tictactoe",
|
'id' => "tictactoe",
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
$siteParam=array("BASEURL" => "http://botsarena.tinad.fr/");
|
$siteParam=array("BASEURL" => "http://botsarena.tinad.fr/");
|
||||||
$mysqlParams=array(
|
$mysqlParams=array(
|
||||||
'host' => 'localhost',
|
'host' => 'localhost',
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
if(isset($_POST['xd_check'])){
|
if(isset($_POST['xd_check'])){
|
||||||
//un formulaire a été soumis
|
//un formulaire a été soumis
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
function get_arenas_list(){
|
function get_arenas_list(){
|
||||||
include (__DIR__."/arenas_lists.php");
|
include (__DIR__."/arenas_lists.php");
|
||||||
return $arenas;
|
return $arenas;
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
$hist=get_battles_history($currentArena);
|
$hist=get_battles_history($currentArena);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
#- BEGIN LICENSE BLOCK ---------------------------------------
|
||||||
|
#
|
||||||
|
# This file is part of botsArena.
|
||||||
|
#
|
||||||
|
# Copyright (C) Gnieark et contributeurs
|
||||||
|
# Licensed under the GPL version 3.0 license.
|
||||||
|
# See LICENSE file or
|
||||||
|
# http://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
#
|
||||||
|
# -- END LICENSE BLOCK -----------------------------------------
|
||||||
|
|
||||||
$rs=mysqli_query($lnMysql,"SELECT 1 FROM bots_modifs WHERE validate_secret='".mysqli_real_escape_string($lnMysql,$_GET['params'])."';");
|
$rs=mysqli_query($lnMysql,"SELECT 1 FROM bots_modifs WHERE validate_secret='".mysqli_real_escape_string($lnMysql,$_GET['params'])."';");
|
||||||
if(!$r=mysqli_fetch_row($rs)){
|
if(!$r=mysqli_fetch_row($rs)){
|
||||||
error(404,"Page doesn't exist");
|
error(404,"Page doesn't exist");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user