Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created November 4, 2019 03:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IntegerMan/f8f172e1842fe9825f205b023dcf4d2a to your computer and use it in GitHub Desktop.
Save IntegerMan/f8f172e1842fe9825f205b023dcf4d2a to your computer and use it in GitHub Desktop.
let evaluateProximity(actor: Actor, pos:WorldPos, weight: float): float =
if actor.IsActive then
getDistance(actor.Pos, pos) * weight
else
0.0
let evaluateTile(brain: ActorChromosome, world: World, pos: WorldPos, random: System.Random): float =
evaluateProximity(world.Squirrel, pos, brain.squirrelImportance) +
evaluateProximity(world.Rabbit, pos, brain.rabbitImportance) +
evaluateProximity(world.Doggo, pos, brain.dogImportance) +
evaluateProximity(world.Acorn, pos, brain.acornImportance) +
evaluateProximity(world.Tree, pos, brain.treeImportance) +
(random.NextDouble() * brain.randomImportance)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment