From cd595e8784e4893832030a659f84f91523d49a27 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Mon, 13 Jun 2016 19:14:32 +0200 Subject: [PATCH] . --- connectfour.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/connectfour.php b/connectfour.php index c05084f..b907b30 100644 --- a/connectfour.php +++ b/connectfour.php @@ -27,7 +27,7 @@ function score($board,$me,$opponent,$colToPlay,$depth){ for ($i=0; $i < 7; $i++){ $line.=$newBoard[$y][$i]; } - if(strpos($searchValue,$line) > -1){ + if(strpos($searchValue,$line)){ return 42; } @@ -36,7 +36,7 @@ function score($board,$me,$opponent,$colToPlay,$depth){ for ($i=0; $i < 6; $i++){ $line.=$newBoard[$i][$colToPlay]; } - if(strpos($searchValue,$line) > -1){ + if(strpos($searchValue,$line)){ return 42; } @@ -55,7 +55,7 @@ function score($board,$me,$opponent,$colToPlay,$depth){ for($jx = $ix, $jy = $iy; ($jx < 7) && ($jy > -1); $jx++, $jy--){ $line.=$newBoard[$jy][$jx]; } - if(strpos($searchValue,$line) > -1){ + if(strpos($searchValue,$line)){ return 42; } //diagonal / @@ -68,12 +68,11 @@ function score($board,$me,$opponent,$colToPlay,$depth){ $ix = -$b; } $line=""; - for ($jx = $ix , $jy = $iy ; ($jx < 7) && ($jy < 6) ; $jx++ , $jy++){ - $line.=$newBoard[$jy][$jx]; + + for ($jx = $ix , $jy = $iy ; ($jx < 7) && ($jy < 6) ; $jx++ , $jy++){ + $line.=$newBoard[$jy][$jx]; } - if(strpos($searchValue,$line) > -1){ - echo "|->".htmlentities($line).strpos($searchValue,$line)."|\n"; - print_r($newBoard); + if(strpos($searchValue,$line)){ return 42; } @@ -103,10 +102,6 @@ function better_col($board,$me,$opponent,$depth){ for( $i = 0; $i < 7; $i++){ if($board[5][$i] == "+"){ $sc = score($board,$me,$opponent,$i,$depth); - if($depth == 0){ - echo $i." ".$sc."\n"; - } - if( $sc > $betterScore){ $betterScore = $sc; $betterCol = $i - $depth;