From 9bcbb730366df82b89b82260dc8bc2e5c899cc29 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Mon, 13 Jun 2016 22:13:07 +0200 Subject: [PATCH] . --- connectfour.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/connectfour.php b/connectfour.php index f7a7a72..712cd5d 100644 --- a/connectfour.php +++ b/connectfour.php @@ -96,11 +96,25 @@ function score($board,$me,$opponent,$colToPlay,$depth){ return 0; } } - +/* function worst_col($board,$me,$opponent,$depth){ - + $worstScore= 1000; + $worstCol= -1; + for( $i = 0; $i < 7; $i++){ + if($board[5][$i] == "+"){ + $sc = score($board,$me,$opponent,$i,$depth); + if( $sc < $worstScore){ + $worstScore = $sc -$depth; + $worstCol = $i; + //echo $i.":".$sc."|"; + } + } + } + return $betterCo } +*/ + function better_col($board,$me,$opponent,$depth){ $betterScore= -1000; $betterCol= -1; @@ -108,7 +122,7 @@ function better_col($board,$me,$opponent,$depth){ if($board[5][$i] == "+"){ $sc = score($board,$me,$opponent,$i,$depth); if( $sc > $betterScore){ - $betterScore = $sc -$depth; + $betterScore = $sc; $betterCol = $i; //echo $i.":".$sc."|"; }