diff --git a/connectfour.php b/connectfour.php index 9b35729..d4d1d8e 100644 --- a/connectfour.php +++ b/connectfour.php @@ -28,7 +28,7 @@ function score($board,$me,$opponent,$colToPlay,$depth){ $line.=$newBoard[$y][$i]; } if(strpos($searchValue,$line) !== false ){ - return 42; + return 200; } //verticaly @@ -38,7 +38,7 @@ function score($board,$me,$opponent,$colToPlay,$depth){ } //echo $line."p".$searchValue." ".strpos($searchValue,$line)."|\n"; if(strpos($searchValue,$line) !== false){ - return 42; + return 200; } @@ -57,7 +57,7 @@ function score($board,$me,$opponent,$colToPlay,$depth){ $line.=$newBoard[$jy][$jx]; } if(strpos($searchValue,$line) !== false ){ - return 42; + return 200; } //diagonal / $b = $y - $colToPlay; @@ -74,7 +74,7 @@ function score($board,$me,$opponent,$colToPlay,$depth){ $line.=$newBoard[$jy][$jx]; } if(strpos($searchValue,$line) !== false){ - return 42; + return 200; } //if grid is full @@ -89,7 +89,7 @@ function score($board,$me,$opponent,$colToPlay,$depth){ return 0; } - if($depth < 7){ + if($depth < 6){ //CO if(($depth % 2) == 0){ return better_col($newBoard,$opponent,$me,$depth + 1) - $depth; diff --git a/connectfour2.php b/connectfour2.php index 6dcba5b..5a19b95 100644 --- a/connectfour2.php +++ b/connectfour2.php @@ -170,7 +170,7 @@ switch($params['action']){ //diagonales \ $diagStr=""; - for($x=0 , $y=$k isset($params['board'][$y][$x]); $x++, $y--){ + for($x=0 , $y=$k; isset($params['board'][$y][$x]); $x++, $y--){ $diagStr.=$params['board'][$y][$x]; } if(can_win($diagStr,$params['you']) !== false){ @@ -194,7 +194,7 @@ switch($params['action']){ $colAvailable=array(); //dont play on full colomns for($i=0;$i<7;$i++){ - if(($grid[5][$i] == "+") OR ($grid[5][$i] == "_")){ + if(($params['board'][5][$i] == "+") OR ($params['board'][5][$i] == "_")){ $colAvailable[]=$i; } }