From 2399b7660b82ca4b90f5839f709f2245caf45502 Mon Sep 17 00:00:00 2001 From: Rowan Torbitzky-Lane Date: Fri, 14 Feb 2025 01:11:37 -0600 Subject: [PATCH] this stuff is broken rn. It's bed time --- src/HushGP/Genome.hs | 9 ++++++++- src/HushGP/Instructions/Opens.hs | 2 +- src/HushGP/Push.hs | 1 + src/HushGP/State.hs | 2 ++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/HushGP/Genome.hs b/src/HushGP/Genome.hs index f9a027a..a791c6a 100644 --- a/src/HushGP/Genome.hs +++ b/src/HushGP/Genome.hs @@ -7,6 +7,7 @@ import HushGP.Instructions.Opens import HushGP.State import HushGP.Utility import HushGP.Instructions +import Debug.Trace tempPlushy :: [Gene] tempPlushy = [ @@ -15,9 +16,11 @@ tempPlushy = [ GeneInt 1, GeneInt 0, StateFunc (instructionIntDiv, "instructionIntDiv"), + Skip, GeneInt (-15), StateFunc (instructionIntSub, "instructionIntSub"), - StateFunc (instructionNoOpBlock, "instructionNoOpBlock"), + -- StateFunc (instructionNoOpBlock, "instructionNoOpBlock"), + StateFunc (instructionExecIf, "instructionExecIf"), Close, Close ] @@ -72,6 +75,10 @@ plushyToPush' openPlushy 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)))])]) 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]) where firstPlushy :: Gene diff --git a/src/HushGP/Instructions/Opens.hs b/src/HushGP/Instructions/Opens.hs index ab8c837..7ac841d 100644 --- a/src/HushGP/Instructions/Opens.hs +++ b/src/HushGP/Instructions/Opens.hs @@ -15,7 +15,7 @@ import HushGP.Instructions.VectorCharInstructions -- To be used in plushy conversion. instructionOpens :: Map.Map Gene Int instructionOpens = Map.fromList [ - (StateFunc (instructionExecIf, "instructionsExecIf"), 2), + (StateFunc (instructionExecIf, "instructionExecIf"), 2), (StateFunc (instructionExecDup, "instructionExecDup"), 1), (StateFunc (instructionExecDupN, "instructionExecDupN"), 1), (StateFunc (instructionExecPop, "instructionExecPop"), 1), diff --git a/src/HushGP/Push.hs b/src/HushGP/Push.hs index a676ca0..d2a42a6 100644 --- a/src/HushGP/Push.hs +++ b/src/HushGP/Push.hs @@ -74,4 +74,5 @@ interpretExec state@(State {_exec = e : es}) = (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 (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 diff --git a/src/HushGP/State.hs b/src/HushGP/State.hs index 7b9af01..39c6e9d 100644 --- a/src/HushGP/State.hs +++ b/src/HushGP/State.hs @@ -26,6 +26,7 @@ data Gene | PlaceInput String | Close | Open Int + | Skip | Block [Gene] | GeneIntERC (Integer, StdGen) | GeneFloatERC (Double, StdGen) @@ -129,6 +130,7 @@ instance Show Gene where show (GeneVectorChar xs) = "Char Vec: " <> show xs show Close = "Close" show (Open x) = "Open: " <> show x + show Skip = "Skip" show (Block xs) = "Block: " <> show xs show (GeneIntERC x) = "Int ERC: " <> show x show (GeneFloatERC x) = "Float ERC: " <> show x