.
[clean-tests.git] / old / paard.icl
1 module paard
2
3 import StdEnv, StdFunc
4
5 bord :: {{Char}}
6 bord =
7 {{'e', 'p', 's'}
8 ,{'o', ' ', 't'}
9 ,{'s', 'r', 'a'}
10 }
11
12 inbord :: Int Int -> Bool
13 inbord x y = x >= 0 && y >= 0 && x < size bord && y < size bord.[0]
14
15 zetten :: [(Int, Int)]
16 zetten =
17 let m = [(1,2), (-1,2), (1,-2), (-1,-2)]
18 in m ++ map (\(x,y)->(y,x)) m
19
20 zet :: [(Int, Int)] -> [[(Int, Int)]]
21 zet [] = []
22 zet gehad=:[(x, y):_] =
23 [ [(x+dx, y+dy):gehad]
24 \\(dx,dy)<-zetten
25 | inbord (dx+x) (dy+y)
26 && not (isMember (dx+x,dy+y) gehad)
27 ]
28
29 str :: [(Int, Int)] -> String
30 str s = {bord.[x].[y]\\(x, y)<-reverse s} +++ "\n"
31
32 startposities :: [[(Int,Int)]]
33 startposities = [[(x,y)]\\x<-[0..2],y<-[0..2]]
34
35
36 ($) infixr 0
37 ($) :== id
38
39 Start = map str $ iter ((size bord*size bord.[0]) - 2) (flatten o map zet) startposities