this stuff is broken rn. It's bed time

This commit is contained in:
Rowan Torbitzky-Lane 2025-02-14 01:11:37 -06:00
parent eab4932d54
commit 2399b7660b
4 changed files with 12 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import HushGP.Instructions.Opens
import HushGP.State import HushGP.State
import HushGP.Utility import HushGP.Utility
import HushGP.Instructions import HushGP.Instructions
import Debug.Trace
tempPlushy :: [Gene] tempPlushy :: [Gene]
tempPlushy = [ tempPlushy = [
@ -15,9 +16,11 @@ tempPlushy = [
GeneInt 1, GeneInt 1,
GeneInt 0, GeneInt 0,
StateFunc (instructionIntDiv, "instructionIntDiv"), StateFunc (instructionIntDiv, "instructionIntDiv"),
Skip,
GeneInt (-15), GeneInt (-15),
StateFunc (instructionIntSub, "instructionIntSub"), StateFunc (instructionIntSub, "instructionIntSub"),
StateFunc (instructionNoOpBlock, "instructionNoOpBlock"), -- StateFunc (instructionNoOpBlock, "instructionNoOpBlock"),
StateFunc (instructionExecIf, "instructionExecIf"),
Close, Close,
Close Close
] ]
@ -72,6 +75,10 @@ plushyToPush' openPlushy push
| firstPlushy == Close = if any isOpen push | firstPlushy == Close = if any isOpen push
then plushyToPush' (drop 1 openPlushy) (if numOpen (push !! openIndex) == 1 then preOpen <> [Block postOpen] else preOpen <> [Block (postOpen <> [decOpen (Open (numOpen (push !! openIndex)))])]) then plushyToPush' (drop 1 openPlushy) (if numOpen (push !! openIndex) == 1 then preOpen <> [Block postOpen] else preOpen <> [Block (postOpen <> [decOpen (Open (numOpen (push !! openIndex)))])])
else plushyToPush' (drop 1 openPlushy) push else plushyToPush' (drop 1 openPlushy) push
| firstPlushy == Skip =
case uncons openPlushy of
Just (_, _ : xs) -> plushyToPush' xs push
_ -> plushyToPush' (drop 1 openPlushy) push
| otherwise = plushyToPush' (drop 1 openPlushy) (push <> [firstPlushy]) | otherwise = plushyToPush' (drop 1 openPlushy) (push <> [firstPlushy])
where where
firstPlushy :: Gene firstPlushy :: Gene

View File

@ -15,7 +15,7 @@ import HushGP.Instructions.VectorCharInstructions
-- To be used in plushy conversion. -- To be used in plushy conversion.
instructionOpens :: Map.Map Gene Int instructionOpens :: Map.Map Gene Int
instructionOpens = Map.fromList [ instructionOpens = Map.fromList [
(StateFunc (instructionExecIf, "instructionsExecIf"), 2), (StateFunc (instructionExecIf, "instructionExecIf"), 2),
(StateFunc (instructionExecDup, "instructionExecDup"), 1), (StateFunc (instructionExecDup, "instructionExecDup"), 1),
(StateFunc (instructionExecDupN, "instructionExecDupN"), 1), (StateFunc (instructionExecDupN, "instructionExecDupN"), 1),
(StateFunc (instructionExecPop, "instructionExecPop"), 1), (StateFunc (instructionExecPop, "instructionExecPop"), 1),

View File

@ -74,4 +74,5 @@ interpretExec state@(State {_exec = e : es}) =
(GeneVectorCharERC (val, _)) -> interpretExec (state & exec .~ es & vectorChar .~ val : view vectorChar state) (GeneVectorCharERC (val, _)) -> interpretExec (state & exec .~ es & vectorChar .~ val : view vectorChar state)
Close -> undefined -- This should never happen. Will be converted to Blocks in the Plushy -> Exec stack process Close -> undefined -- This should never happen. Will be converted to Blocks in the Plushy -> Exec stack process
(Open _) -> undefined -- This should also never happen. Should be converted in Plushy -> Exec stack process (Open _) -> undefined -- This should also never happen. Should be converted in Plushy -> Exec stack process
Skip -> undefined -- This should double also never happen.
interpretExec state = state interpretExec state = state

View File

@ -26,6 +26,7 @@ data Gene
| PlaceInput String | PlaceInput String
| Close | Close
| Open Int | Open Int
| Skip
| Block [Gene] | Block [Gene]
| GeneIntERC (Integer, StdGen) | GeneIntERC (Integer, StdGen)
| GeneFloatERC (Double, StdGen) | GeneFloatERC (Double, StdGen)
@ -129,6 +130,7 @@ instance Show Gene where
show (GeneVectorChar xs) = "Char Vec: " <> show xs show (GeneVectorChar xs) = "Char Vec: " <> show xs
show Close = "Close" show Close = "Close"
show (Open x) = "Open: " <> show x show (Open x) = "Open: " <> show x
show Skip = "Skip"
show (Block xs) = "Block: " <> show xs show (Block xs) = "Block: " <> show xs
show (GeneIntERC x) = "Int ERC: " <> show x show (GeneIntERC x) = "Int ERC: " <> show x
show (GeneFloatERC x) = "Float ERC: " <> show x show (GeneFloatERC x) = "Float ERC: " <> show x