2021-02-24 18:40:46 +03:00
|
|
|
app "test-astar"
|
2021-12-12 15:55:46 +03:00
|
|
|
packages { pf: "platform" }
|
2021-12-22 04:17:31 +03:00
|
|
|
imports [ pf.Task, AStar ]
|
2021-12-12 15:55:46 +03:00
|
|
|
provides [ main ] to pf
|
2021-02-15 23:34:55 +03:00
|
|
|
|
|
|
|
main : Task.Task {} []
|
|
|
|
main =
|
2021-02-19 01:39:50 +03:00
|
|
|
Task.putLine (showBool test1)
|
2021-02-19 19:07:27 +03:00
|
|
|
|
2021-02-19 01:39:50 +03:00
|
|
|
# Task.after Task.getInt \n ->
|
|
|
|
# when n is
|
2021-12-22 04:17:31 +03:00
|
|
|
# 1 ->
|
2021-02-19 01:39:50 +03:00
|
|
|
# Task.putLine (showBool test1)
|
2021-12-22 04:17:31 +03:00
|
|
|
#
|
|
|
|
# _ ->
|
2021-11-30 22:55:08 +03:00
|
|
|
# ns = Num.toStr n
|
2021-02-19 01:39:50 +03:00
|
|
|
# Task.putLine "No test \(ns)"
|
2021-02-15 23:34:55 +03:00
|
|
|
showBool : Bool -> Str
|
|
|
|
showBool = \b ->
|
|
|
|
when b is
|
2021-12-22 04:17:31 +03:00
|
|
|
True ->
|
|
|
|
"True"
|
|
|
|
|
|
|
|
False ->
|
|
|
|
"False"
|
2021-02-15 23:34:55 +03:00
|
|
|
|
|
|
|
test1 : Bool
|
2021-12-22 04:17:31 +03:00
|
|
|
test1 =
|
|
|
|
example1 == [ 2, 4 ]
|
2021-02-15 23:34:55 +03:00
|
|
|
|
|
|
|
example1 : List I64
|
|
|
|
example1 =
|
|
|
|
step : I64 -> Set I64
|
|
|
|
step = \n ->
|
|
|
|
when n is
|
2021-12-22 04:17:31 +03:00
|
|
|
1 ->
|
|
|
|
Set.fromList [ 2, 3 ]
|
|
|
|
|
|
|
|
2 ->
|
|
|
|
Set.fromList [ 4 ]
|
|
|
|
|
|
|
|
3 ->
|
|
|
|
Set.fromList [ 4 ]
|
|
|
|
|
|
|
|
_ ->
|
|
|
|
Set.fromList []
|
2021-02-15 23:34:55 +03:00
|
|
|
|
|
|
|
cost : I64, I64 -> F64
|
2021-12-22 04:17:31 +03:00
|
|
|
cost = \_, _ -> 1
|
|
|
|
|
|
|
|
when AStar.findPath cost step 1 4 is
|
|
|
|
Ok path ->
|
|
|
|
path
|
2021-02-15 23:34:55 +03:00
|
|
|
|
2021-12-22 04:17:31 +03:00
|
|
|
Err _ ->
|
|
|
|
[]
|