diff options
Diffstat (limited to '.stack-work/intero/intero30739dbu-STAGING.hs')
-rw-r--r-- | .stack-work/intero/intero30739dbu-STAGING.hs | 127 |
1 files changed, 0 insertions, 127 deletions
diff --git a/.stack-work/intero/intero30739dbu-STAGING.hs b/.stack-work/intero/intero30739dbu-STAGING.hs deleted file mode 100644 index c0b9790..0000000 --- a/.stack-work/intero/intero30739dbu-STAGING.hs +++ /dev/null | |||
@@ -1,127 +0,0 @@ | |||
1 | module Main where | ||
2 | |||
3 | import Control.Lens | ||
4 | import Linear.V2 | ||
5 | import Linear.V3 | ||
6 | import Data.Matrix | ||
7 | --import Numeric.LinearAlgebra | ||
8 | import System.Random | ||
9 | import Foreign.Storable | ||
10 | |||
11 | |||
12 | data Square = X -- Attacked | ||
13 | | Qu -- Queen | ||
14 | | O -- Open/available | ||
15 | deriving (Show, Eq) | ||
16 | |||
17 | |||
18 | --board = V3 <$> [0..8] <*> [0..8] <*> [0] | ||
19 | --board = [(r,c,X) | r <- [0..8], c <- [0..8] ] | ||
20 | |||
21 | lo8 = [0..8] -- list of 8 | ||
22 | initBoard = matrix 8 8 $ \_ -> O | ||
23 | |||
24 | placeQueen (r,c) b = placeQueen' $ markAttacked b | ||
25 | where | ||
26 | placeQueen' b = setElem Qu (r,c) b | ||
27 | markAttacked b = rowAttacked $ colAttacked $ diagAttacked b | ||
28 | fX = (\_ x -> X) | ||
29 | rowAttacked b = mapRow fX r b | ||
30 | colAttacked b = mapCol fX c b | ||
31 | diagAttacked b = let d = diag r c | ||
32 | attack ap ab = setElem X ap ab | ||
33 | attackall [x] = attack x b | ||
34 | attackall (x:xs) = attack x (attackall xs) | ||
35 | in attackall d | ||
36 | -- in last $ map (\p -> setElem X p b) d | ||
37 | -- in last $ scanr (\p -> setElem X p) b | ||
38 | |||
39 | --solve b = placeQueen (nextAvail b) b | ||
40 | |||
41 | nextAvail b = head [(x,y) | x <- [1..8], y <- [1..8], b ! (x,y) == O] | ||
42 | |||
43 | solve b = solve $ placeQueen n b | ||
44 | where n = nextAvail b | ||
45 | |||
46 | |||
47 | --diag r c = [(x,y) | x <- [1..8], y <- [1..8], (abs x-y) == 1 ] | ||
48 | diag r c = let rl = [1..r] | ||
49 | rr = [r..8] | ||
50 | cu = [1..c] | ||
51 | cd = [c..8] | ||
52 | in zip rl cu ++ zip rr cd ++ | ||
53 | zip (reverse rl) cd ++ zip (reverse rr) cu | ||
54 | |||
55 | |||
56 | |||
57 | |||
58 | -- diag (r,c) b = | ||
59 | -- where l = (r-1,c-1) | ||
60 | -- r = (r+1,c+1) | ||
61 | -- lowbound = 1 | ||
62 | -- highbound = 8 | ||
63 | |||
64 | |||
65 | --initBoard = (8><8) $ repeat O | ||
66 | |||
67 | --firstOpen b = take 1 [(r,c)| r <- [1..8], c <- [1..8], b ! (r,c) == O] | ||
68 | |||
69 | -- firstOpen b = let | ||
70 | -- elem x y = b ! (x, y) | ||
71 | -- in map | ||
72 | |||
73 | -- nextOpen b = | ||
74 | |||
75 | -- solve = let board = initBoard | ||
76 | |||
77 | --avail r c b = | ||
78 | |||
79 | --rowOccupied r b = any (== Q) $ getRow r b | ||
80 | |||
81 | |||
82 | |||
83 | -- diags p = let r = r p | ||
84 | -- l = l p | ||
85 | -- in p : inRange r | ||
86 | -- where inRange x = x >= 1 && x <= 8 | ||
87 | -- inRange' (x,y) = inRange (x) && inRange (y) | ||
88 | -- r x = (fst x + 1, snd x + 1) | ||
89 | -- l x = (fst x - 1, snd x - 1) | ||
90 | -- nexts x = diags' x | ||
91 | -- diags' x = [(fst x - 1, snd x -1), (fst x + 1, snd x + 1)] | ||
92 | -- -- down x = (fst x - 1, snd x - 1) | ||
93 | -- -- down (r,c) = let d = (r-1,c-1) in if inRange d then d : down d else | ||
94 | -- -- up (r,c) = let u = (r+1,c+1) in u : up u | ||
95 | |||
96 | |||
97 | --mapDiag r c = undefined | ||
98 | |||
99 | --placeAll = repeat 8 placeQueen | ||
100 | |||
101 | winnable = undefined | ||
102 | |||
103 | nextOpen board = undefined | ||
104 | |||
105 | -- placeQueen r c = | ||
106 | |||
107 | --b = getE | ||
108 | |||
109 | --placeQueen r c b = b ^. | ||
110 | |||
111 | -- rand = do | ||
112 | -- g <- newStdGen | ||
113 | -- print $ take 8 $ (randomRs (0, 8) g) | ||
114 | |||
115 | |||
116 | -- try r c = let next b = placeQueen r c b | ||
117 | -- in next initBoard | ||
118 | |||
119 | -- try' p = let next b = p b | ||
120 | -- in next initBoard | ||
121 | |||
122 | |||
123 | --res = [ try x y | x <- lo8, y <- lo8 ] | ||
124 | |||
125 | main :: IO () | ||
126 | main = do | ||
127 | putStrLn "Hi" | ||