module MoveGenerator where
- Custom data structure which is a tuple structure that contains a position (Position row column)
data Position = Position cfw_row : Int, column : Int deriving (Show)
- Gen
- Questoin 1
preparednessQuotient i s c pn pa d n =
(top pa s c) / (bottom pn d n i)
top pa s c = 8 * (pa * (s + c)
bottom pn d n i = 3 * (pn * (d + n + i)
- Question 2
kungPaoFactor r dm ds n c ft
- Part A
- recursion, keep summing up all the 1/n + 1/(n-1) + 1/(n-2) + . + 0 <- when n = 0, it counts as 0
- harmonic 5 = 1/5 + 1/4 + 1/3 + 1/2 + 1 + 0
harmonic : Int -> Float
harmonic n
| n <= 0 =
- available coin types 1,2,5,10,20,50,100
- =
- list comprehension approach
- if the n is 0, we simply just return [] since it doesnt require any change
- if the n is not 0, grab the first list return
- Question 1
- param matching:
- kungPaoFactor r dm ds n c ft ff s -> k
- this is done by separate the formula into budget related and food related function
kungPaoFactor : Int -> Float -> Float -> In
- PegPuzzle.hs
- Written by Kurt Eislet
- NOTE THAT THE COMMENTING DONE BELOW IS NOT HOW WE WANT YOU TO
- COMMENT YOUR PROGRAMS. THINK OF THESE OVERLY WORDY COMMENTS
- AS A MINI-LECTURE ABOUT HOW THI
module MinMax where
import MoveScoring
import MoveGenerator
- Custom data structure which is an n-ary tree representation of possible moves; contains the current board and list of children states
data
LISTS
- Haskell requires homogenous lists; excepts for Int and Floats
LIST PROCESSING
Counting number of ints in an array
mylenInt : [Int] -> Int
mylenInt inlist
|null inlist = 0
|otherwise = 1 + (m
data Color = R | G | B | W | Y | O deriving (Eq, Show)
type Face = (Color, Color, Color, Color)
type State = (Face, Face, Face, Face, Face, Face)
data Move = Fwd | Rgt | Bck | Lft | Up | Dwn deriving
module MoveScoring where
import MoveGenerator
- Calculates score for the currPlayer on the board; Score is 100 if the currPlayer has won and -100 if the currPlayer has lost
boardEval_a4s7 : [String] -
square : Int -> Int
square n = n ^ 2
mypi : Float
mypi = 3.14
rev : [a] -> [a]
rev l
| null l = l
| otherwise = revhelp l []
revhelp : [a] -> [a] -> [a]
revhelp l a
| null l = a
| otherwise = r