Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
let evaluateTile brain world pos =
let genes = brain.genes
let proxSquirrel = evaluateProximity world.Squirrel pos (getGene ActorGeneIndex.Squirrel genes)
let proxRabbit = evaluateProximity world.Rabbit pos (getGene ActorGeneIndex.Rabbit genes)
let proxDoggo = evaluateProximity world.Doggo pos (getGene ActorGeneIndex.Doggo genes)
let proxAcorn = evaluateProximity world.Acorn pos (getGene ActorGeneIndex.Acorn genes)
let proxTree = evaluateProximity world.Tree pos (getGene ActorGeneIndex.Tree genes)
let adjDoggo = evaluateAdjacentTo world.Doggo pos (getGene ActorGeneIndex.NextToDoggo genes)
let adjRabbit = evaluateAdjacentTo world.Rabbit pos (getGene ActorGeneIndex.NextToRabbit genes)
proxSquirrel + proxRabbit + proxDoggo + proxAcorn + proxTree + adjDoggo + adjRabbit
let getGene (geneIndex: ActorGeneIndex) (genes: double[]) =
genes.[int geneIndex]
let evaluateProximity actor pos weight =
if actor.IsActive then
let maxDistance = 225.0
let distance = getDistance(actor.Pos, pos)
if distance < maxDistance then
((maxDistance - distance)/maxDistance) * weight
else
0.0
else
0.0
let evaluateAdjacentTo actor pos weight =
if actor.IsActive && actor.Pos <> pos then
if getDistance(actor.Pos, pos) <= 1.5 then
0.05 * weight
else
0.0
else
0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment