Compare commits

..

No commits in common. "7abac5e995ed313c1032c0304614e47a958fbe88" and "164286d59a9f4434e0864b271b20f522a3a8b088" have entirely different histories.

5 changed files with 12 additions and 98 deletions

View File

@ -5,8 +5,8 @@
- [X] Make all vector functions applicable to string functions and vice versa
- [X] Implement all functions as seen in propeller
- [X] Implement all functions as seen in the specification
- [X] Implement Linear Algebra functions as specified in the previous papers
- [X] These are in a separate branch, just need merging now
- [ ] Implement Linear Algebra functions as specified in the previous papers
- [ ] These are in a separate branch, just need merging now
- [X] Add a function to sort a vector forward and backwards
- [X] Disambiguate isEmpty and stackIsEmpty
- [X] Rename Logical to Bool
@ -19,7 +19,7 @@
- [X] Move utility functions to their own file
- [ ] Make add/sub/mult/div/mod instructions generic
- [ ] Use template haskell to (mostly) generate functions from generic ones (Split files based on the arity of their functions)
- [X] Add more special functions like sqrt, pow
- [ ] Add more special functions like sqrt, pow
## PushGP TODO
- [X] Implement a Plushy genome translator
@ -36,7 +36,6 @@
- [ ] Add history stack(s), like a call stack
- [ ] Implement interpreter options (PushArgs would work well)
- Should probably place this in a separate file
- [ ] Implement Novelty Lexicase selection
- [X] Implement different forms of downsampling
- [ ] Implement concurrent execution of creating random plushies and evaluating individuals
- [X] Devise a good way to implement ERCs

View File

@ -164,10 +164,6 @@ instructionFloatShove = instructionShove float
instructionFloatIsStackEmpty :: State -> State
instructionFloatIsStackEmpty = instructionIsStackEmpty float
-- |Duplicate the top N items from the float stack based on the top int from the int stack.
instructionFloatDupItems :: State -> State
instructionFloatDupItems = instructionDupItems float
-- |Pushes the sin of the top float to the float stack.
instructionFloatSin :: State -> State
instructionFloatSin state@(State {_float = f1 : fs}) = state {_float = sin f1 : fs}
@ -183,40 +179,9 @@ instructionFloatTan :: State -> State
instructionFloatTan state@(State {_float = f1 : fs}) = state {_float = tan f1 : fs}
instructionFloatTan state = state
-- |Pushes the absolute value of the top float to the float stack.
instructionFloatAbs :: State -> State
instructionFloatAbs state@(State {_float = f1 : fs}) = state {_float = abs f1 : fs}
instructionFloatAbs state = state
-- |Pushes the exponential of the top float to the float stack.
instructionFloatExp :: State -> State
instructionFloatExp state@(State {_float = f1 : fs}) = state {_float = exp f1 : fs}
instructionFloatExp state = state
-- |Pushes the log of the top float to the float stack.
instructionFloatLog :: State -> State
instructionFloatLog state@(State {_float = f1 : fs}) = state {_float = log f1 : fs}
instructionFloatLog state = state
-- |Pushes the squared value of the top float to the float stack.
instructionFloatSquare :: State -> State
instructionFloatSquare state@(State {_float = f1 : fs}) = state {_float = f1 ^ (2 :: Int) : fs}
instructionFloatSquare state = state
-- |Pushes the cubed value of the top float to the float stack.
instructionFloatCube :: State -> State
instructionFloatCube state@(State {_float = f1 : fs}) = state {_float = f1 ^ (3 :: Int) : fs}
instructionFloatCube state = state
-- |Pushes the square rooted value of the top float to the float stack.
instructionFloatSqrt :: State -> State
instructionFloatSqrt state@(State {_float = f1 : fs}) = state {_float = sqrt f1 : fs}
instructionFloatSqrt state = state
-- |Pushes the top float with its sign reversed to the top of the float stack.
instructionFloatReverseSign :: State -> State
instructionFloatReverseSign state@(State {_float = f1 : fs}) = state {_float = (-1) * f1 : fs}
instructionFloatReverseSign state = state
-- |Duplicate the top N items from the float stack based on the top int from the int stack.
instructionFloatDupItems :: State -> State
instructionFloatDupItems = instructionDupItems float
allFloatInstructions :: [Gene]
allFloatInstructions = map StateFunc ($(functionExtractor "instruction"))

View File

@ -168,55 +168,5 @@ instructionIntIsStackEmpty = instructionIsStackEmpty int
instructionIntDupItems :: State -> State
instructionIntDupItems = instructionDupItems int
-- |Pushes the sin of the top int to the int stack. Rounding if needed.
instructionIntSin :: State -> State
instructionIntSin state@(State {_int = i1 : is}) = state {_int = round (sin (fromIntegral @Integer @Double i1)) : is}
instructionIntSin state = state
-- |Pushes the cos of the top int to the int stack. Rounding if needed.
instructionIntCos :: State -> State
instructionIntCos state@(State {_int = i1 : is}) = state {_int = round (cos (fromIntegral @Integer @Double i1)) : is}
instructionIntCos state = state
-- |Pushes the tan of the top int to the int stack. Rounding if needed.
instructionIntTan :: State -> State
instructionIntTan state@(State {_int = i1 : is}) = state {_int = round (tan (fromIntegral @Integer @Double i1)) : is}
instructionIntTan state = state
-- |Pushes the absolute value of the top int to the int stack.
instructionIntAbs :: State -> State
instructionIntAbs state@(State {_int = i1 : is}) = state {_int = abs i1 : is}
instructionIntAbs state = state
-- |Pushes the exponential of the top int to the int stack. Rounding if needed.
instructionIntExp :: State -> State
instructionIntExp state@(State {_int = i1 : is}) = state {_int = round (exp (fromIntegral @Integer @Double i1)) : is}
instructionIntExp state = state
-- |Pushes the log of the top int to the int stack. Rounding if needed.
instructionIntLog :: State -> State
instructionIntLog state@(State {_int = i1 : is}) = state {_int = round (log (fromIntegral @Integer @Double i1)) : is}
instructionIntLog state = state
-- |Pushes the squared value of the top int to the int stack.
instructionIntSquare :: State -> State
instructionIntSquare state@(State {_int = i1 : is}) = state {_int = i1 ^ (2 :: Int) : is}
instructionIntSquare state = state
-- |Pushes the cubed value of the top int to the int stack.
instructionIntCube :: State -> State
instructionIntCube state@(State {_int = i1 : is}) = state {_int = i1 ^ (3 :: Int) : is}
instructionIntCube state = state
-- |Pushes the square rooted value of the top int to the int stack. Rounding if needed.
instructionIntSqrt :: State -> State
instructionIntSqrt state@(State {_int = i1 : is}) = state {_int = round (sqrt (fromIntegral @Integer @Double i1)) : is}
instructionIntSqrt state = state
-- |Pushes the top int with its sign reversed to the top of the int stack.
instructionIntReverseSign :: State -> State
instructionIntReverseSign state@(State {_int = i1 : is}) = state {_int = (-1) * i1 : is}
instructionIntReverseSign state = state
allIntInstructions :: [Gene]
allIntInstructions = map StateFunc ($(functionExtractor "instruction"))

View File

@ -335,7 +335,7 @@ instructionVectorFloatInsertVectorFloat = instructionVectorInsertVector vectorFl
-- |Takes the mean of the top float vector and pushes the rounded float value
-- to the float stack.
instructionVectorFloatMean :: State -> State
instructionVectorFloatMean state@(State {_vectorFloat = [] : _}) = instructionVectorFuncVectorToPrim float vectorFloat retZero state
instructionVectorFloatMean state@(State {_vectorFloat = [] : vs}) = instructionVectorFuncVectorToPrim float vectorFloat retZero state
instructionVectorFloatMean state = instructionVectorFuncVectorToPrim float vectorFloat (\xs -> sum xs / fromIntegral @Int @Double (length xs)) state
-- |Takes the maximum of the top float vector and pushes the float value
@ -413,11 +413,11 @@ instructionVectorFloatAbs = instructionVectorFuncVectorToVector vectorFloat (map
-- |Applies the square function to all indices in an float vector, rounds the result as it moves along.
instructionVectorFloatSquare :: State -> State
instructionVectorFloatSquare = instructionVectorFuncVectorToVector vectorFloat (map (^ (2 :: Int)))
instructionVectorFloatSquare = instructionVectorFuncVectorToVector vectorFloat (map (^ 2))
-- |Applies the cube function to all indices in an float vector, rounds the result as it moves along.
instructionVectorFloatCube :: State -> State
instructionVectorFloatCube = instructionVectorFuncVectorToVector vectorFloat (map (^ (3 :: Int)))
instructionVectorFloatCube = instructionVectorFuncVectorToVector vectorFloat (map (^ 3))
-- |Applies the sqrt function to all indices in an float vector, rounds the result as it moves along.
instructionVectorFloatSqrt :: State -> State

View File

@ -335,7 +335,7 @@ instructionVectorIntInsertVectorInt = instructionVectorInsertVector vectorInt
-- |Takes the mean of the top int vector and pushes the rounded int value
-- to the int stack.
instructionVectorIntMean :: State -> State
instructionVectorIntMean state@(State {_vectorInt = [] : _}) = instructionVectorFuncVectorToPrim int vectorInt retZero state
instructionVectorIntMean state@(State {_vectorInt = [] : vs}) = instructionVectorFuncVectorToPrim int vectorInt retZero state
instructionVectorIntMean state = instructionVectorFuncVectorToPrim int vectorInt (\xs -> round $ sum (map (fromIntegral @Integer @Double) xs) / fromIntegral @Int @Double (length xs)) state
-- |Takes the maximum of the top int vector and pushes the int value
@ -413,11 +413,11 @@ instructionVectorIntAbs = instructionVectorFuncVectorToVector vectorInt (map (ro
-- |Applies the square function to all indices in an int vector, rounds the result as it moves along.
instructionVectorIntSquare :: State -> State
instructionVectorIntSquare = instructionVectorFuncVectorToVector vectorInt (map (round . (^ (2 :: Int)) . fromIntegral @Integer @Double))
instructionVectorIntSquare = instructionVectorFuncVectorToVector vectorInt (map (round . (^ 2) . fromIntegral @Integer @Double))
-- |Applies the cube function to all indices in an int vector, rounds the result as it moves along.
instructionVectorIntCube :: State -> State
instructionVectorIntCube = instructionVectorFuncVectorToVector vectorInt (map (round . (^ (3 :: Int)) . fromIntegral @Integer @Double))
instructionVectorIntCube = instructionVectorFuncVectorToVector vectorInt (map (round . (^ 3) . fromIntegral @Integer @Double))
-- |Applies the sqrt function to all indices in an int vector, rounds the result as it moves along.
instructionVectorIntSqrt :: State -> State