seperate haskell und purescript directories

This commit is contained in:
weiss
2020-04-19 05:51:24 +02:00
parent 7dfe85a5fd
commit 49481147ff
67 changed files with 5 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
module Main where
import Prelude
import Control.Monad.State (State, gets, modify_, runState)
import Data.Maybe (Maybe(..))
import Data.Tuple (fst, snd)
import Effect (Effect)
import Effect.Console (log, error)
import Effect.Random (randomInt)
import GameInput (parseInitInput, parseInput, GameInitInput, Board, Entity)
import Graph
type GameState =
{ boardSize :: Int
, heroId :: Int
, board :: Board
, entityCount :: Int
, entities :: Array Entity
}
main :: Effect Unit
main = do
initInput <- parseInitInput
error $ show $ initInput.board
nextRound initInput Nothing
nextRound :: GameInitInput -> Maybe GameState -> Effect Unit
nextRound initInput gameState = do
input <- parseInput
-- error $ show $ G.shortestPath "[4,4]" "[1,1]" graph
-- do we start on the left side of the map?
let gameState' =
{ boardSize: initInput.boardSize
, heroId: initInput.heroId
, board: initInput.board
, entityCount: input.entityCount
, entities: input.entities
}
rand <- randomInt 0 3
let res = runState (loop rand) gameState'
let state = snd res
let val = fst res
log $ val
nextRound initInput (Just state)
loop :: Int -> State GameState String
loop rand
| rand == 0 = pure "NORTH"
| rand == 1 = pure "EAST"
| rand == 2 = pure "SOUTH"
| otherwise = pure "WEST"