.
This commit is contained in:
parent
c97f0620e2
commit
cd595e8784
|
@ -27,7 +27,7 @@ function score($board,$me,$opponent,$colToPlay,$depth){
|
||||||
for ($i=0; $i < 7; $i++){
|
for ($i=0; $i < 7; $i++){
|
||||||
$line.=$newBoard[$y][$i];
|
$line.=$newBoard[$y][$i];
|
||||||
}
|
}
|
||||||
if(strpos($searchValue,$line) > -1){
|
if(strpos($searchValue,$line)){
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ function score($board,$me,$opponent,$colToPlay,$depth){
|
||||||
for ($i=0; $i < 6; $i++){
|
for ($i=0; $i < 6; $i++){
|
||||||
$line.=$newBoard[$i][$colToPlay];
|
$line.=$newBoard[$i][$colToPlay];
|
||||||
}
|
}
|
||||||
if(strpos($searchValue,$line) > -1){
|
if(strpos($searchValue,$line)){
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ function score($board,$me,$opponent,$colToPlay,$depth){
|
||||||
for($jx = $ix, $jy = $iy; ($jx < 7) && ($jy > -1); $jx++, $jy--){
|
for($jx = $ix, $jy = $iy; ($jx < 7) && ($jy > -1); $jx++, $jy--){
|
||||||
$line.=$newBoard[$jy][$jx];
|
$line.=$newBoard[$jy][$jx];
|
||||||
}
|
}
|
||||||
if(strpos($searchValue,$line) > -1){
|
if(strpos($searchValue,$line)){
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
//diagonal /
|
//diagonal /
|
||||||
|
@ -68,12 +68,11 @@ function score($board,$me,$opponent,$colToPlay,$depth){
|
||||||
$ix = -$b;
|
$ix = -$b;
|
||||||
}
|
}
|
||||||
$line="";
|
$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){
|
if(strpos($searchValue,$line)){
|
||||||
echo "|->".htmlentities($line).strpos($searchValue,$line)."|\n";
|
|
||||||
print_r($newBoard);
|
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,10 +102,6 @@ function better_col($board,$me,$opponent,$depth){
|
||||||
for( $i = 0; $i < 7; $i++){
|
for( $i = 0; $i < 7; $i++){
|
||||||
if($board[5][$i] == "+"){
|
if($board[5][$i] == "+"){
|
||||||
$sc = score($board,$me,$opponent,$i,$depth);
|
$sc = score($board,$me,$opponent,$i,$depth);
|
||||||
if($depth == 0){
|
|
||||||
echo $i." ".$sc."\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if( $sc > $betterScore){
|
if( $sc > $betterScore){
|
||||||
$betterScore = $sc;
|
$betterScore = $sc;
|
||||||
$betterCol = $i - $depth;
|
$betterCol = $i - $depth;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user