Skip to content

Commit e8d9aaa

Browse files
committed
Move Pacman sources to each version directory.
1 parent 53403fd commit e8d9aaa

File tree

4 files changed

+50
-54
lines changed

4 files changed

+50
-54
lines changed
File renamed without changes.
File renamed without changes.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
module Pacman where
2+
3+
pac0 = [(1,5),(1,4),(1,3),(1,2),(1,1),(2,1),(3,1),(4,1),(5,1),(5,2),(5,3),
4+
(5,4),(5,5),(6,5),(7,5),(8,5),(9,5),(9,4),(9,3),(9,2),(9,1)]
5+
6+
ghost0 = [(9,1),(9,2),(9,3),(9,4),(9,5),(8,5),(7,5),(6,5),(5,5),(4,5),(3,5),
7+
(2,5),(1,5),(1,4),(1,3),(1,2),(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),
8+
(7,1),(8,1)]
9+
10+
pac1 = pac0 ++ (reverse $ init pac0)
11+
ghost1 = ghost0 ++ (reverse $ init ghost0)
12+
13+
pac = x where x = pac1 ++ x
14+
ghost = x where x = ghost1 ++ x
15+
drop_interval = 7
16+
drops = [ f x | x <- [1..] ] where
17+
f x = if x `mod` drop_interval == 0 then
18+
1
19+
else 0
20+
21+
game_list = zipWith func pac ghost where
22+
func pac_pos ghost_pos =
23+
if pac_pos == ghost_pos then
24+
-1
25+
else 1
26+
27+
result = takeWhile (>= 0) game_list
28+
final = 0 : [(sum final) + x | x <- result]
29+
30+
drops2 = zipWith f ghost drops where
31+
f x y = if y == 1 then x
32+
else (0,0)
33+
34+
len = length result
35+
all_pac = take len pac
36+
all_drops = take len drops2
37+
38+
drop_list = map (+(-1)) $ iterate (+drop_interval) drop_interval
39+
score = [(head $ drop x all_drops) `elem` (drop x all_pac) | x <- drop_list]
40+
score_int = [ f x | x <- score] where
41+
f x
42+
| x == True = 1
43+
| otherwise = 0
44+
45+
46+
movement_list = zip3 pac ghost drops
47+
48+
first (x,_,_) = x
49+
second (_,y,_) = y
50+
third (_,_,z) = z

homework-assignments/Georgiana.si.Mihai.hs renamed to homework-assignments/georgiana.and.mihai/main.hs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -62,57 +62,3 @@ update ref = do
6262
redraw imgs ix
6363
writeIORef ref $ GD (ix + 1) imgs
6464
return True
65-
```
66-
67-
`Pacman.hs`
68-
```
69-
module Pacman where
70-
71-
pac0 = [(1,5),(1,4),(1,3),(1,2),(1,1),(2,1),(3,1),(4,1),(5,1),(5,2),(5,3),
72-
(5,4),(5,5),(6,5),(7,5),(8,5),(9,5),(9,4),(9,3),(9,2),(9,1)]
73-
74-
ghost0 = [(9,1),(9,2),(9,3),(9,4),(9,5),(8,5),(7,5),(6,5),(5,5),(4,5),(3,5),
75-
(2,5),(1,5),(1,4),(1,3),(1,2),(1,1),(2,1),(3,1),(4,1),(5,1),(6,1),
76-
(7,1),(8,1)]
77-
78-
pac1 = pac0 ++ (reverse $ init pac0)
79-
ghost1 = ghost0 ++ (reverse $ init ghost0)
80-
81-
pac = x where x = pac1 ++ x
82-
ghost = x where x = ghost1 ++ x
83-
drop_interval = 7
84-
drops = [ f x | x <- [1..] ] where
85-
f x = if x `mod` drop_interval == 0 then
86-
1
87-
else 0
88-
89-
game_list = zipWith func pac ghost where
90-
func pac_pos ghost_pos =
91-
if pac_pos == ghost_pos then
92-
-1
93-
else 1
94-
95-
result = takeWhile (>= 0) game_list
96-
final = 0 : [(sum final) + x | x <- result]
97-
98-
drops2 = zipWith f ghost drops where
99-
f x y = if y == 1 then x
100-
else (0,0)
101-
102-
len = length result
103-
all_pac = take len pac
104-
all_drops = take len drops2
105-
106-
drop_list = map (+(-1)) $ iterate (+drop_interval) drop_interval
107-
score = [(head $ drop x all_drops) `elem` (drop x all_pac) | x <- drop_list]
108-
score_int = [ f x | x <- score] where
109-
f x
110-
| x == True = 1
111-
| otherwise = 0
112-
113-
114-
movement_list = zip3 pac ghost drops
115-
116-
first (x,_,_) = x
117-
second (_,y,_) = y
118-
third (_,_,z) = z

0 commit comments

Comments
 (0)