From 4fbd42f9ff5fd19090bd779552cb645f3c70ca65 Mon Sep 17 00:00:00 2001 From: Rowan Torbitzky-Lane Date: Thu, 20 Feb 2025 01:49:04 -0600 Subject: [PATCH] fix yank dup bug --- src/HushGP/Instructions/GenericInstructions.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HushGP/Instructions/GenericInstructions.hs b/src/HushGP/Instructions/GenericInstructions.hs index 4d43fa9..d4d4ac3 100644 --- a/src/HushGP/Instructions/GenericInstructions.hs +++ b/src/HushGP/Instructions/GenericInstructions.hs @@ -102,7 +102,7 @@ instructionStackDepth accessor state@(State {_int = is}) = state{_int = toIntege -- the top int from the int stack. instructionYankDup :: Lens' State [a] -> State -> State instructionYankDup accessor state@(State {_int = i1 : is}) = - if notEmptyStack accessor state + if notEmptyStack accessor state{_int = is} then state{_int = is} & accessor .~ (view accessor state{_int = is} !! max 0 (min (fromIntegral i1) (length (view accessor state{_int = is}) - 1))) : view accessor state{_int = is} else state instructionYankDup _ state = state