<commit_before>module Wind where

import Random (Seed, initialSeed, generate, float)
import Html (Html, dl, dt, dd, text)
import Signal
import Time (..)

type alias Model =
  { windDirection : Float
  , windSpeed : Float
  , seed : Seed
  }

initialModel : Model
initialModel =
  { windSpeed = 0
  , windDirection = 0
  , seed = initialSeed 112358
  }




updateWind : Model -> Model
updateWind = updateWindSpeed << updateWindDirection

updateWindSpeed : Model -> Model
updateWindSpeed m =
  let (prob, seed') = generate (float 0 1) m.seed
      windSpeed' = m.windSpeed + prob
  in { m | seed <- seed', windSpeed <- windSpeed' }

updateWindDirection : Model -> Model
updateWindDirection m =
  let (prob, seed') = generate (float 0 1) m.seed
      windDirection' = m.windDirection + prob
  in { m | seed <- seed', windDirection <- windDirection' }

update : a -> Model -> Model
update _ = updateWind





view : Model -> Html
view model =
  dl []
    [ dt [] [text "Wind Speed"]
    , dd [] [text (toString model.windSpeed)]
    , dt [] [text "Wind Direction"]
    , dd [] [text (toString model.windDirection)]
    ]





main : Signal Html
main = Signal.map view model

model : Signal Model
model = Signal.foldp update initialModel delta

delta = Signal.map inSeconds (fps 10)
<commit_msg>Make wind more realistic and add an arrow indicator<commit_after>module Wind where

import Random (Seed, initialSeed, generate, float, int)
import Html (..)
import Html.Attributes (..)
import Signal
import Time (..)
import String (toInt)

type alias Model =
  { windDirection : Float
  , windSpeed : Float
  , seed : Seed
  }


initialModel : Model
initialModel =
  { windSpeed = 0
  , windDirection = 0
  , seed = initialSeed 112358
  }




updateWind : Model -> Model
updateWind = updateWindSpeed << updateWindDirection

updateWindSpeed : Model -> Model
updateWindSpeed m =
  let (prob, seed') = generate (float 0 1) m.seed
      windSpeed' = (m.windSpeed * 0.9) + (prob * 0.1)
  in { m | seed <- seed', windSpeed <- windSpeed' }

updateWindDirection : Model -> Model
updateWindDirection m =
  let (prob, seed') = generate (float 0 360) m.seed
      windDirection' = (m.windDirection * 0.9) + (prob * 0.1)
  in { m | seed <- seed', windDirection <- windDirection' }

update : a -> Model -> Model
update _ = updateWind


transformAngle : Float -> String
transformAngle direction = "rotate(" ++ toString (round direction) ++ "deg)"
        
speedColor : Float -> String
speedColor speed = 
  let lum = round (100.0 * (1 - speed))
  in "hsl(240,100%," ++ toString lum ++ "%)"



view : Model -> Html
view model =
  p [id "wind",
  style [
          ("height", "22px"),
          ("width", "16px"),
          ("font-size", "20px"),
          ("transform", transformAngle model.windDirection), 
          ("color", speedColor model.windSpeed)
  ]] [text ("↑")]



bootstrap : Model -> Model
bootstrap m = 
  let (windDirection', seed') = generate (float 0 360) m.seed
  in { m | seed <- seed', windDirection <- windDirection' }


main : Signal Html
main = Signal.map view model

model : Signal Model
model = Signal.foldp update (bootstrap initialModel) delta

delta = Signal.map inSeconds (fps 10)

{'fraction_non_alphanumeric': 0.12558869701726844, 'fraction_numerical': 0.018524332810047096, 'mean_word_length': 3.170157068062827, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, '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': '5839150', 'n_tokens_mistral': 1083, 'n_tokens_neox': 969, 'n_words': 333}