From a86705bad90c165fc695f42d3a30c9959b4a5505 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Tue, 31 May 2016 09:23:41 +0200 Subject: [PATCH] new bot --- tictactoeJSON.php | 76 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 tictactoeJSON.php diff --git a/tictactoeJSON.php b/tictactoeJSON.php new file mode 100644 index 0000000..ef0c0e0 --- /dev/null +++ b/tictactoeJSON.php @@ -0,0 +1,76 @@ + $betterScore ){ + $betterCell = $cellKey; + $betterScore= $sc; + } + } + } + return array($betterCell,$betterScore); +} + +//count free cases +$freeCells=0; +for($x = 0; $x < 3; $x++){ + for($y = 0; $y < 3; $y++){ + if($message['board'][$x."-".$y] == ""){ + $freeCells ++; + }elseif($message['board'][$x."-".$y] !== $message['you']){ + $hisSymbol=$message['board'][$x."-".$y]; + } + } +} + +if(!isset($hisSymbol)){ + if($message['you'] == 'X'){ + $hisSymbol='O'; + }else{ + $hisSymbol="X"; + } +} + + +echo choose_better_cell($message['board'],$message['you'], $hisSymbol,9 - $freeCells); \ No newline at end of file