Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let pacManVisible options lineOfSight =
- let creaturesInDirection (directionVector: (TileContent * Creature list) list ) = directionVector |> List.collect snd
- let containsPacMan (creatures: Creature list) = match List.tryFind (fun c -> match c with
- | int -> true
- | _ -> false) creatures with
- | Some value -> true
- | None -> false
- if(Set.contains Up options && lineOfSight.Up |> creaturesInDirection |> containsPacMan) then Some Up
- else if(Set.contains Left options && lineOfSight.Left |> creaturesInDirection |> containsPacMan) then Some Left
- else if(Set.contains Down options && lineOfSight.Down |> creaturesInDirection |> containsPacMan) then Some Down
- else if(Set.contains Right options && lineOfSight.Right |> creaturesInDirection |> containsPacMan) then Some Right
- else None
- let decision (current: Move) (lineOfSight: Sight) (choices: Move Set) =
- let restricted =
- choices
- |> Set.filter (fun c -> not (c = backwards current))
- let options = if (restricted |> Set.count > 0)
- then restricted
- else choices
- let pacDirection = pacManVisible options lineOfSight
- match pacDirection with
- | Some move -> move
- | None -> randomMove options
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement