<commit_before>﻿module Fitness    
    type Content = Empty | Treasure | Wall
    type Action = Pick | StayPut | North | South | East | West
    type Position = Position of int * int
    type ActionOutcome = {fitness:int; nextPosition:Position}
    type Site = Position * Content 
    type Situation = {current:Site; north:Site; south:Site; west:Site; east:Site}

    let private siteAfterAction action situation =
        match action with
        | North -> situation.north
        | South -> situation.south
        | West -> situation.west
        | East -> situation.east
        | _ -> situation.current

    let private positionAfterAction action situation = 
        fst (siteAfterAction action situation)

    let private siteContent site = snd site

    let private sitePosition site = fst site

    let private situationPosition situation = 
        sitePosition situation.current

    let fitness content action = 
        match content, action with
        | Wall, _ -> -5
        | _ , StayPut -> 0
        | _, North | _, South | _, East | _, West -> 0
        | Empty, _ -> -1
        | Treasure , Pick -> 10

    let outcomeAfterAction action situation =
        let contentAfterAction = situation |> siteAfterAction action |> siteContent
        let currentPosition = situationPosition situation
        
        {
            fitness = fitness contentAfterAction action
            nextPosition = 
                match contentAfterAction with
                | Wall -> currentPosition
                | _ -> positionAfterAction action situation
        }<commit_msg>Reorder functions in Fitness<commit_after>﻿module Fitness    
    type Content = Empty | Treasure | Wall
    type Action = Pick | StayPut | North | South | East | West
    type Position = Position of int * int
    type ActionOutcome = {fitness:int; nextPosition:Position}
    type Site = Position * Content 
    type Situation = {current:Site; north:Site; south:Site; west:Site; east:Site}

    let private siteContent site = snd site

    let private sitePosition site = fst site

    let private currentPosition situation = sitePosition situation.current

    let private siteAfterAction action situation =
        match action with
        | North -> situation.north
        | South -> situation.south
        | West -> situation.west
        | East -> situation.east
        | _ -> situation.current

    let private positionAfterAction action situation = 
        fst (siteAfterAction action situation)

    let fitness content action = 
        match content, action with
        | Wall, _ -> -5
        | _ , StayPut -> 0
        | _, North | _, South | _, East | _, West -> 0
        | Empty, _ -> -1
        | Treasure , Pick -> 10

    let outcomeAfterAction action situation =
        let contentAfterAction = situation |> siteAfterAction action |> siteContent
        
        {
            fitness = fitness contentAfterAction action
            nextPosition = 
                match contentAfterAction with
                | Wall -> currentPosition situation
                | _ -> positionAfterAction action situation
        }
{'fraction_non_alphanumeric': 0.07001278772378516, 'fraction_numerical': 0.0038363171355498722, 'mean_word_length': 2.125874125874126, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1036652', 'n_tokens_mistral': 769, 'n_tokens_neox': 720, 'n_words': 258}