added "real ai "ai snake
This commit is contained in:
@@ -582,7 +582,6 @@ function snakeAIappleBias(){
|
|||||||
preferredDirections.push(3);
|
preferredDirections.push(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 65% chance to go toward apple
|
|
||||||
if (
|
if (
|
||||||
preferredDirections.length > 0 &&
|
preferredDirections.length > 0 &&
|
||||||
random() < 0.65
|
random() < 0.65
|
||||||
@@ -699,12 +698,10 @@ function snakeAIsurvival(){
|
|||||||
score -= distance;
|
score -= distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// avoid tunnels
|
|
||||||
if (freeNeighbors <= 1){
|
if (freeNeighbors <= 1){
|
||||||
score -= 100;
|
score -= 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
// slight randomness
|
|
||||||
score += random(-3, 3);
|
score += random(-3, 3);
|
||||||
|
|
||||||
if (score > bestScore){
|
if (score > bestScore){
|
||||||
|
|||||||
Reference in New Issue
Block a user