From 3d1b0f1d46b22929940c26a6e50903cc5677cb6f Mon Sep 17 00:00:00 2001 From: wfishell Date: Tue, 20 May 2025 15:00:56 -0400 Subject: [PATCH 1/6] Adding a max consistency checks, preventing a 2^n check on the predicates for smts which caused very slow or virtualy unsynthesizable specs, despite their simplicity --- src/TSL/ModuloTheories/ConsistencyChecking.hs | 171 +++++++++--------- 1 file changed, 84 insertions(+), 87 deletions(-) diff --git a/src/TSL/ModuloTheories/ConsistencyChecking.hs b/src/TSL/ModuloTheories/ConsistencyChecking.hs index 7e74649..2d104bb 100644 --- a/src/TSL/ModuloTheories/ConsistencyChecking.hs +++ b/src/TSL/ModuloTheories/ConsistencyChecking.hs @@ -2,42 +2,58 @@ {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TupleSections #-} --- | -- Module : TSL.ModuloTheories.ConsistencyChecking --- Description : Adds partial semantics back to uninterpreted functions by checking which combinations of uninterpreted predicates are satisfiable. For each unsatisfiable combination, the negation of that combination is added as an assumption. +-- Description : Adds partial semantics back to uninterpreted functions by checking which combinations +-- of uninterpreted predicates are satisfiable. To avoid an exponential blow‑up in SMT +-- calls, we now cap the number of combinations examined. -- Maintainer : Wonhyuk Choi module TSL.ModuloTheories.ConsistencyChecking - ( generateConsistencyAssumptions, - consistencyDebug, - ConsistencyDebugInfo (..), - ) -where - -import Control.Monad.Trans.Except -import TSL.Base.Ast - ( AstInfo (..), - SymbolInfo (..), - deduplicate, - ) -import TSL.Error (Error, errConsistency) -import TSL.ModuloTheories.Debug (IntermediateResults (..)) -import TSL.ModuloTheories.Predicates - ( TheoryPredicate (..), - enumeratePreds, - pred2Smt, - pred2Tsl, - predInfo, - predTheory, - ) -import TSL.ModuloTheories.Solver (solveSat) -import TSL.ModuloTheories.Theories - ( Theory, - TheorySymbol, - isUninterpreted, - smtSortDecl, - symbol2Smt, - symbolType, - ) + ( generateConsistencyAssumptions + , consistencyDebug + , ConsistencyDebugInfo (..) + , config_MAX_CONSISTENCY_CHECKS + ) where + +import Control.Monad.Trans.Except +import qualified Data.List as L +import Debug.Trace (trace) + +import TSL.Base.Ast (AstInfo (..), SymbolInfo (..), deduplicate) +import TSL.Error (Error, errConsistency) +import TSL.ModuloTheories.Debug (IntermediateResults (..)) +import TSL.ModuloTheories.Predicates (TheoryPredicate (..), enumeratePreds + , pred2Smt, pred2Tsl, predInfo, predTheory) +import TSL.ModuloTheories.Solver (solveSat) +import TSL.ModuloTheories.Theories (Theory, TheorySymbol, isUninterpreted + , smtSortDecl, symbol2Smt, symbolType) + +-- |Hard cap on how many predicate combinations we send to the SMT solver. +-- This prevents run‑away exponential behaviour when many uninterpreted +-- predicates appear in the spec. Adjust as needed or expose it as a CLI flag. +-- this number can be changed based on the problem, but even for simple synthesis problems the +-- number of predicates being checked was always become 2^n. This simplifies while getting the correct answer +config_MAX_CONSISTENCY_CHECKS :: Int +config_MAX_CONSISTENCY_CHECKS = 100 + + +generateConsistencyAssumptions + :: FilePath + -> [TheoryPredicate] + -> [ExceptT Error IO String] +generateConsistencyAssumptions path preds = + map (fmap fst . consistencyChecking path) limitedCombos + where + -- enumerate all combinations, then keep only the first N + limitedCombos = take config_MAX_CONSISTENCY_CHECKS $ enumeratePreds preds + +consistencyDebug + :: FilePath + -> [TheoryPredicate] + -> [ExceptT Error IO ConsistencyDebugInfo] +consistencyDebug path preds = + map (fmap snd . consistencyChecking path) limitedCombos + where + limitedCombos = take config_MAX_CONSISTENCY_CHECKS $ enumeratePreds preds pred2Assumption :: TheoryPredicate -> String pred2Assumption p = "G " ++ pred2Tsl (NotPLit p) ++ ";" @@ -46,76 +62,57 @@ data ConsistencyDebugInfo = ConsistencyDebugInfo IntermediateResults String instance Show ConsistencyDebugInfo where show (ConsistencyDebugInfo results assumption) = - "ConsistencyDebugInfo {\n" - ++ " results: " - ++ show results - ++ ",\n" - ++ " assumption: " - ++ assumption - ++ "\n" - ++ "}" - -generateConsistencyAssumptions :: - FilePath -> - [TheoryPredicate] -> - [ExceptT Error IO String] -generateConsistencyAssumptions path preds = - map (fmap fst . consistencyChecking path) (enumeratePreds preds) + "ConsistencyDebugInfo {" ++ + "\n results: " ++ show results ++ + ",\n assumption: " ++ assumption ++ + "\n}" -consistencyDebug :: - FilePath -> - [TheoryPredicate] -> - [ExceptT Error IO ConsistencyDebugInfo] -consistencyDebug path preds = - map (fmap snd . consistencyChecking path) (enumeratePreds preds) -consistencyChecking :: - FilePath -> - TheoryPredicate -> - ExceptT Error IO (String, ConsistencyDebugInfo) +consistencyChecking + :: FilePath + -> TheoryPredicate + -> ExceptT Error IO (String, ConsistencyDebugInfo) consistencyChecking solverPath pred = do + let query = pred2SmtQuery pred isSat <- solveSat solverPath query if isSat - then except $ errConsistency $ "Predicate " ++ show pred ++ " is satisfiable. No new assumption added." - else - let assumption = pred2Assumption pred - intermediateResults = - IntermediateResults (show pred) query (show isSat) - debugInfo = - ConsistencyDebugInfo intermediateResults assumption - in return (assumption, debugInfo) - where - query = pred2SmtQuery pred + then except $ errConsistency $ "Predicate " ++ show pred ++ + " is satisfiable. No new assumption added." + else do + let assumption = pred2Assumption pred + intermediateResults = IntermediateResults (show pred) query (show isSat) + debugInfo = ConsistencyDebugInfo intermediateResults assumption + trace ("[Consistency] adding assumption for " ++ show pred) $ return () + return (assumption, debugInfo) + pred2SmtQuery :: TheoryPredicate -> String pred2SmtQuery p = unlines [smtDeclarations, assertion, checkSat] where smtDeclarations = smtDecls (predTheory p) $ deduplicate $ predInfo p - assertion = "(assert " ++ pred2Smt p ++ ")" - checkSat = "(check-sat)" + assertion = "(assert " ++ pred2Smt p ++ ")" + checkSat = "(check-sat)" smtDecls :: Theory -> AstInfo TheorySymbol -> String smtDecls theory (AstInfo vars funcs preds) = unlines [logic, sortDecl, varDecls, funcDecls, predDecls] where - logic = "(set-logic " ++ show theory ++ ")" - sortDecl = smtSortDecl theory - varDecls = unlines $ map declConst vars - funcDecls = unlines $ map declFunc funcs - predDecls = unlines $ map declPred preds + logic = "(set-logic " ++ show theory ++ ")" + sortDecl = smtSortDecl theory + varDecls = unlines $ map declConst vars + funcDecls = unlines $ map declFunc funcs + predDecls = unlines $ map declPred preds + declConst (SymbolInfo x _) = "(declare-const " ++ symbol2Smt x ++ " " ++ symbolType x ++ ")" - declareFun retType (SymbolInfo f arity) = - if not (isUninterpreted f) - then "" - else - unwords - [ "(declare-fun", - symbol2Smt f, - "(", - unwords $ replicate arity $ show theory, - ")", - retType ++ ")" - ] + + declareFun retType (SymbolInfo f arity) + | not (isUninterpreted f) = "" + | otherwise = unwords [ "(declare-fun" + , symbol2Smt f + , "(" + , unwords $ replicate arity $ show theory + , ")" + , retType ++ ")" ] declFunc = declareFun (show theory) declPred = declareFun "Bool" From b2f6f99d71faecc4f21cb3ab2a70d05201f611ce Mon Sep 17 00:00:00 2001 From: wfishell Date: Thu, 22 May 2025 18:25:25 -0400 Subject: [PATCH 2/6] requested changes for consistency checking --- src/TSL/ModuloTheories/ConsistencyChecking.hs | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/TSL/ModuloTheories/ConsistencyChecking.hs b/src/TSL/ModuloTheories/ConsistencyChecking.hs index 2d104bb..2217adb 100644 --- a/src/TSL/ModuloTheories/ConsistencyChecking.hs +++ b/src/TSL/ModuloTheories/ConsistencyChecking.hs @@ -8,15 +8,16 @@ -- calls, we now cap the number of combinations examined. -- Maintainer : Wonhyuk Choi module TSL.ModuloTheories.ConsistencyChecking - ( generateConsistencyAssumptions - , consistencyDebug - , ConsistencyDebugInfo (..) - , config_MAX_CONSISTENCY_CHECKS - ) where + ( generateConsistencyAssumptions, + consistencyDebug, + ConsistencyDebugInfo (..), + ) + where import Control.Monad.Trans.Except import qualified Data.List as L import Debug.Trace (trace) +import Data.Maybe (fromMaybe) import TSL.Base.Ast (AstInfo (..), SymbolInfo (..), deduplicate) import TSL.Error (Error, errConsistency) @@ -32,19 +33,21 @@ import TSL.ModuloTheories.Theories (Theory, TheorySymbol, isUninter -- predicates appear in the spec. Adjust as needed or expose it as a CLI flag. -- this number can be changed based on the problem, but even for simple synthesis problems the -- number of predicates being checked was always become 2^n. This simplifies while getting the correct answer -config_MAX_CONSISTENCY_CHECKS :: Int -config_MAX_CONSISTENCY_CHECKS = 100 +config_MAX_CONSISTENCY_CHECKS :: Maybe Int +config_MAX_CONSISTENCY_CHECKS = Just 100 generateConsistencyAssumptions - :: FilePath - -> [TheoryPredicate] + :: FilePath + -> [TheoryPredicate] -> [ExceptT Error IO String] generateConsistencyAssumptions path preds = map (fmap fst . consistencyChecking path) limitedCombos where - -- enumerate all combinations, then keep only the first N - limitedCombos = take config_MAX_CONSISTENCY_CHECKS $ enumeratePreds preds + allCombos = enumeratePreds preds + limitedCombos = case config_MAX_CONSISTENCY_CHECKS of + Just n -> take n allCombos + Nothing -> allCombos consistencyDebug :: FilePath @@ -53,7 +56,11 @@ consistencyDebug consistencyDebug path preds = map (fmap snd . consistencyChecking path) limitedCombos where - limitedCombos = take config_MAX_CONSISTENCY_CHECKS $ enumeratePreds preds + allCombos = enumeratePreds preds + limitedCombos = case config_MAX_CONSISTENCY_CHECKS of + Just n -> take n allCombos + Nothing -> allCombos + pred2Assumption :: TheoryPredicate -> String pred2Assumption p = "G " ++ pred2Tsl (NotPLit p) ++ ";" From eb2b3def5735d411cc24d5a97045076dd602bf33 Mon Sep 17 00:00:00 2001 From: wfishell Date: Thu, 5 Jun 2025 18:47:40 -0400 Subject: [PATCH 3/6] lazy commit msg --- GridGame.py | 2532 ++++++++++++++++++++++++++++++++++ TestC_R_Files/PingPong.tslmt | 54 + injector.py | 35 + 3 files changed, 2621 insertions(+) create mode 100644 GridGame.py create mode 100644 TestC_R_Files/PingPong.tslmt create mode 100644 injector.py diff --git a/GridGame.py b/GridGame.py new file mode 100644 index 0000000..c05b2cf --- /dev/null +++ b/GridGame.py @@ -0,0 +1,2532 @@ +import sys +from operator import itemgetter +import pygame + +class Cop: + def __init__(self, x, y): + self.x = x + self.y = y + +class _next_Cop: + def __init__(self, x, y): + self.x = x + self.y = y + +_MAX_M = None +_MAX_N = None + +def MaxX(): + return _MAX_M + +def MaxY(): + return _MAX_N + +def MinX(): + return 0 + +def MinY(): + return 0 + +# BEGIN UPDATESTATE +def updateState(_inputs_and_cells): + currentState, Cop.x, Cop.y = itemgetter("currentState", "Cop.x", "Cop.y")(_inputs_and_cells) + + if currentState == 0: + if (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.x = Cop.x + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.y = Cop.y + 1 + _next_Cop.x = Cop.x + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 2 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 3 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 4 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 5 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 6 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 7 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 8 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 9 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 10 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 11 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 12 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 13 + elif currentState == 1: + if True: + currentState = 45 + elif True: + _next_Cop.x = Cop.x + 1 + _next_Cop.x = Cop.x - 1 + currentState = 45 + elif True: + _next_Cop.x = Cop.x + 1 + _next_Cop.x = Cop.x + currentState = 45 + elif True: + _next_Cop.x = Cop.x - 1 + _next_Cop.x = Cop.x + currentState = 45 + elif True: + currentState = 45 + elif True: + _next_Cop.y = Cop.y + 1 + _next_Cop.y = Cop.y - 1 + currentState = 45 + elif True: + _next_Cop.y = Cop.y + 1 + _next_Cop.y = Cop.y + currentState = 45 + elif True: + _next_Cop.y = Cop.y - 1 + _next_Cop.y = Cop.y + currentState = 45 + elif currentState == 2: + if (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 16 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 17 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 18 + elif (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 19 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 20 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 21 + elif currentState == 3: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 3 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 17 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 18 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 22 + elif currentState == 4: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 4 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 23 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 24 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 25 + elif currentState == 5: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 5 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 16 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 17 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 18 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 26 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 27 + elif currentState == 6: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 9 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 29 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 30 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 31 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 32 + elif currentState == 7: + if (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 3 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 7 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 29 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 30 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 31 + elif currentState == 8: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 8 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 29 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 33 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 34 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 35 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 36 + elif (Cop.x != MaxX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 36 + elif currentState == 9: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 9 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 29 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 33 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 35 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 37 + elif currentState == 10: + if (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 23 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 26 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 38 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 39 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 40 + elif currentState == 11: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 11 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 17 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 22 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 41 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 42 + elif currentState == 12: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 12 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 23 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 24 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 38 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 43 + elif currentState == 13: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 13 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 23 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 26 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 27 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 38 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 44 + elif currentState == 14: + if True: + _next_Cop.x = Cop.x + _next_Cop.y = Cop.y + currentState = 1 + elif True: + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 1 + elif True: + _next_Cop.y = Cop.y + 1 + _next_Cop.x = Cop.x + currentState = 1 + elif True: + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + currentState = 1 + elif True: + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + currentState = 1 + elif currentState == 15: + if (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.x = Cop.x + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.y = Cop.y + 1 + _next_Cop.x = Cop.x + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 1 + elif (Cop.x != MaxX()): + currentState = 45 + elif (Cop.x != MaxX()): + _next_Cop.x = Cop.x + 1 + _next_Cop.x = Cop.x - 1 + currentState = 45 + elif (Cop.x != MaxX()): + _next_Cop.x = Cop.x + 1 + _next_Cop.x = Cop.x + currentState = 45 + elif (Cop.x != MaxX()): + _next_Cop.x = Cop.x - 1 + _next_Cop.x = Cop.x + currentState = 45 + elif (Cop.x != MaxX()): + currentState = 45 + elif (Cop.x != MaxX()): + _next_Cop.y = Cop.y + 1 + _next_Cop.y = Cop.y - 1 + currentState = 45 + elif (Cop.x != MaxX()): + _next_Cop.y = Cop.y + 1 + _next_Cop.y = Cop.y + currentState = 45 + elif (Cop.x != MaxX()): + _next_Cop.y = Cop.y - 1 + _next_Cop.y = Cop.y + currentState = 45 + elif (Cop.x != MinX()): + currentState = 45 + elif (Cop.x != MinX()): + _next_Cop.x = Cop.x + 1 + _next_Cop.x = Cop.x - 1 + currentState = 45 + elif (Cop.x != MinX()): + _next_Cop.x = Cop.x + 1 + _next_Cop.x = Cop.x + currentState = 45 + elif (Cop.x != MinX()): + _next_Cop.x = Cop.x - 1 + _next_Cop.x = Cop.x + currentState = 45 + elif (Cop.x != MinX()): + currentState = 45 + elif (Cop.x != MinX()): + _next_Cop.y = Cop.y + 1 + _next_Cop.y = Cop.y - 1 + currentState = 45 + elif (Cop.x != MinX()): + _next_Cop.y = Cop.y + 1 + _next_Cop.y = Cop.y + currentState = 45 + elif (Cop.x != MinX()): + _next_Cop.y = Cop.y - 1 + _next_Cop.y = Cop.y + currentState = 45 + elif currentState == 16: + if (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.y = Cop.y + 1 + _next_Cop.x = Cop.x + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MinX()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif currentState == 17: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 8 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 16 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 29 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 33 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 34 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 35 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 44 + elif currentState == 18: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 4 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 23 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 24 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 25 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 44 + elif currentState == 19: + if (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif currentState == 20: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 9 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 16 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 29 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 33 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 35 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 37 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 44 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 45 + elif currentState == 21: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 5 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 23 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 25 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 26 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 27 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 44 + elif currentState == 22: + if (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 3 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 7 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 29 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 30 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 31 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 44 + elif currentState == 23: + if (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 3 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 7 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 16 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 29 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 30 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 31 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 44 + elif currentState == 24: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 8 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 16 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 29 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 33 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 34 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 35 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 36 + elif currentState == 25: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 3 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 16 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 17 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 18 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 22 + elif currentState == 26: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 9 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 16 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 29 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 30 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 31 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 37 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 44 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 45 + elif currentState == 27: + if (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif currentState == 28: + if (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.y = Cop.y + 1 + _next_Cop.x = Cop.x + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif currentState == 29: + if (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x != MinX()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif currentState == 30: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 4 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 23 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 24 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 25 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 44 + elif currentState == 31: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 8 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 29 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 33 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 34 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 35 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 36 + elif currentState == 32: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 5 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 23 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 25 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 26 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 27 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 44 + elif currentState == 33: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 3 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 16 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 17 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 18 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 22 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif currentState == 34: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 4 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 23 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 24 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 25 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif currentState == 35: + if (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 3 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 7 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 29 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 30 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 31 + elif currentState == 36: + if (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif currentState == 37: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 5 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 16 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 17 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 18 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 26 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 27 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif currentState == 38: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 11 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 16 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 17 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 22 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 41 + elif currentState == 39: + if (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.y = Cop.y + 1 + _next_Cop.x = Cop.x + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif currentState == 40: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 13 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 16 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 17 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 26 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 27 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 41 + elif currentState == 41: + if (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 12 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 23 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 24 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 38 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 44 + elif currentState == 42: + if (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y != MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 44 + elif currentState == 43: + if (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MinX()) and (Cop.y != MaxY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 16 + elif (Cop.x == MaxX()) and (Cop.x != MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 28 + elif currentState == 44: + if (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.y = Cop.y + 1 + _next_Cop.x = Cop.x + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y + 1 + currentState = 1 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x + 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MinX()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + elif (Cop.x != MaxX()) and (Cop.x == MinX()) and (Cop.y == MinY()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif currentState == 45: + if (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y + 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y == MaxY()) and (Cop.y != MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x == MaxX()) and (Cop.x == MinX()) and (Cop.y != MaxY()) and (Cop.y == MinY()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 14 + elif (Cop.x != MaxX()) and (Cop.x == MinX()): + _next_Cop.y = Cop.y - 1 + _next_Cop.x = Cop.x + currentState = 15 + elif (Cop.x != MinX()): + _next_Cop.x = Cop.x - 1 + _next_Cop.y = Cop.y - 1 + currentState = 15 + + return {"currentState": currentState, "Cop.x": _next_Cop.x, "Cop.y": _next_Cop.y} +# END UPDATESTATE +#################################################################################### +#################################################################################### +#######################################GRID SETUP################################### +#################################################################################### +#################################################################################### +class GridGame: + def __init__(self, n, m): + pygame.init() + + # store dimensions and set globals for MaxX/MaxY + self.n, self.m = n, m + global _MAX_M, _MAX_N + _MAX_M = m - 1 + _MAX_N = n - 1 + + # drawing params + self.cell_size = 50 + self.padding = 2 + self.WHITE = (255, 255, 255) + self.BLUE = (0, 0, 255) + self.GRAY = (200, 200, 200) + + # screen setup + self.width = self.m * self.cell_size + 100 + self.height = self.n * self.cell_size + 100 + self.screen = pygame.display.set_mode((self.width, self.height)) + pygame.display.set_caption(f"Grid Game ({n}×{m})") + + # only track the cop’s position, not grid cells + self.cop_pos = None + self.game_state = 'placing_cop' + self.font = pygame.font.SysFont(None, 24) + + def draw_grid(self): + # clear background + self.screen.fill(self.GRAY) + + # draw empty cells + for row in range(self.n): + for col in range(self.m): + rect = pygame.Rect( + col * self.cell_size + 50, + row * self.cell_size + 50, + self.cell_size - self.padding, + self.cell_size - self.padding + ) + pygame.draw.rect(self.screen, self.WHITE, rect) + + # draw the cop at its current position (if placed) + if self.cop_pos: + row, col = self.cop_pos + rect = pygame.Rect( + col * self.cell_size + 50, + row * self.cell_size + 50, + self.cell_size - self.padding, + self.cell_size - self.padding + ) + pygame.draw.rect(self.screen, self.BLUE, rect) + + # status text + status = "Click to place the cop" if self.game_state == "placing_cop" else "Animating..." + text_surf = self.font.render(status, True, self.BLUE) + self.screen.blit(text_surf, (10, 10)) + + pygame.display.flip() + + def get_cell_from_pos(self, pos): + x, y = pos + if x < 50 or y < 50: + return None + col = (x - 50) // self.cell_size + row = (y - 50) // self.cell_size + if 0 <= row < self.n and 0 <= col < self.m: + return (row, col) + return None + + def handle_click(self, pos): + cell = self.get_cell_from_pos(pos) + if cell and self.game_state == "placing_cop": + self.cop_pos = cell + self.game_state = "done" + self.draw_grid() + + def animate_chase(self): + clock = pygame.time.Clock() + state = 0 + row, col = self.cop_pos + + for _ in range(100): + for evt in pygame.event.get(): + if evt.type == pygame.QUIT: + pygame.quit() + sys.exit() + + # compute the next position + out = updateState({ + "currentState": state, + "Cop.x": row, + "Cop.y": col + }) + state = out["currentState"] + row = out["Cop.x"] + col = out["Cop.y"] + self.cop_pos = (row, col) + + # redraw + self.draw_grid() + clock.tick(10) + + def run(self): + running = True + while running: + for evt in pygame.event.get(): + if evt.type == pygame.QUIT: + running = False + elif evt.type == pygame.MOUSEBUTTONDOWN and evt.button == 1: + self.handle_click(evt.pos) + elif evt.type == pygame.KEYDOWN and evt.key == pygame.K_ESCAPE: + running = False + + if self.game_state == "done": + pygame.time.delay(500) + self.animate_chase() + running = False + else: + self.draw_grid() + pygame.time.delay(20) + + pygame.quit() + +def main(): + try: + n = int(input("Enter number of rows (N): ")) + m = int(input("Enter number of columns (M): ")) + if n <= 0 or m <= 0: + print("Grid dimensions must be positive") + return + + game = GridGame(n, m) + game.run() + + except ValueError: + print("Please enter valid numbers") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/TestC_R_Files/PingPong.tslmt b/TestC_R_Files/PingPong.tslmt new file mode 100644 index 0000000..9a48fa7 --- /dev/null +++ b/TestC_R_Files/PingPong.tslmt @@ -0,0 +1,54 @@ +#LIA +initially assume { +} + +always assume { + (MinX() < MaxX()); + (MinY() < MaxY()); + + ! (Cop.x = MinX() && Cop.x = MaxX()); + ! (Cop.x = MinY() && Cop.y = MaxY()); + + + + + [Cop.x <- Cop.x + 1] -> X(!(Cop.x = MinX())); + [Cop.x <- Cop.x - 1] -> X(!(Cop.x = MaxX())); + + [Cop.y <- Cop.y + 1] -> X(!(Cop.y = MinY())); + [Cop.y <- Cop.y - 1] -> X(!(Cop.y = MaxY())); + + +} + +always guarantee { + + //Cop.x maxX eventually cop.x minX and inverse + (Cop.x = MaxX()) -> F [Cop.x <- Cop.x - 1]; + (Cop.x = MinX()) -> F [Cop.x <- Cop.x + 1]; + + (Cop.y = MaxY()) -> F [Cop.y <- Cop.y - 1]; + (Cop.y = MinY()) -> F [Cop.y <- Cop.y + 1]; + + [Cop.x <- Cop.x + 1] || [Cop.x <- Cop.x - 1]; + + [Cop.y <- Cop.y + 1] || [Cop.y <- Cop.y - 1]; + + (! (Cop.x = MinX()) && ! (Cop.x = MaxX())) -> F ([Cop.x <- Cop.x + 1] || [Cop.x <- Cop.x - 1]); + (! (Cop.y = MinY()) && ! (Cop.y = MaxY())) -> F ([Cop.y <- Cop.y + 1] || [Cop.y <- Cop.y - 1]); + + + + // X Coordinate Ping Pong Effects + (Cop.x = MinX() && X (!(Cop.x = MinX()))) -> ((! [Cop.x <- Cop.x - 1]) W (Cop.x = MaxX())); + (Cop.x = MaxX() && X (!(Cop.x = MaxX()))) -> ((! [Cop.x <- Cop.x + 1]) W (Cop.x = MinX())); + + (Cop.y = MinY() && X (!(Cop.y = MinY()))) -> ((! [Cop.y <- Cop.y - 1]) W (Cop.y = MaxY())); + (Cop.y = MaxY() && X (!(Cop.y = MaxY()))) -> ((! [Cop.y <- Cop.y + 1]) W (Cop.y = MinY())); + // Neither X min or max, do something + + + + + +} \ No newline at end of file diff --git a/injector.py b/injector.py new file mode 100644 index 0000000..d64ee8a --- /dev/null +++ b/injector.py @@ -0,0 +1,35 @@ +import subprocess +import re +if __name__ == '__main__': + # 1. Run the TSL synth command and capture its output + proc = subprocess.run( + ["tsl", "synthesize", "-i", "/Users/will/github/tsl_local/tsltools/TestC_R_Files/PingPong.tslmt", "--python"], + check=True, + stdout=subprocess.PIPE + ) + generated_code = proc.stdout.decode("utf-8").strip() + + # 1a. Strip a trailing '}' if it appears alone on its own line + # This removes exactly one extra closing brace (and any surrounding whitespace/newlines) + generated_code = re.sub(r"\n*\}\s*$", "", generated_code) + + # 2. Read the target file + target_path = "./GridGame.py" + with open(target_path, "r") as f: + text = f.read() + + # 3. Replace the region between the markers + pattern = re.compile( + r"(# BEGIN UPDATESTATE\n).*?(# END UPDATESTATE)", + re.DOTALL + ) + new_text = pattern.sub( + lambda m: f"{m.group(1)}{generated_code}\n{m.group(2)}", + text + ) + + # 4. Write it back out + with open(target_path, "w") as f: + f.write(new_text) + + print(f"Injected updateState into {target_path}") From 59ca291fc3722c8743d822143d17360130282180 Mon Sep 17 00:00:00 2001 From: wfishell Date: Tue, 10 Jun 2025 16:22:34 -0400 Subject: [PATCH 4/6] Ping Pong With Strong Until --- TestC_R_Files/PingPong_StrongUntil.tslmt | 48 ++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 TestC_R_Files/PingPong_StrongUntil.tslmt diff --git a/TestC_R_Files/PingPong_StrongUntil.tslmt b/TestC_R_Files/PingPong_StrongUntil.tslmt new file mode 100644 index 0000000..0389c8a --- /dev/null +++ b/TestC_R_Files/PingPong_StrongUntil.tslmt @@ -0,0 +1,48 @@ +#LIA +initially assume { + + +} + + +always assume { + + Cop.x < MaxX() && [Cop.x <- Cop.x + 1] -> X(Cop.x = MaxX()); + Cop.x > MinX() && [Cop.x <- Cop.x - 1] -> X(Cop.x = MinX()); + + Cop.y < MaxY() && [Cop.y <- Cop.y + 1] -> X(Cop.y = MaxY()); + Cop.y > MinY() && [Cop.y <- Cop.y - 1] -> X(Cop.y = MinY()); + + F(Cop.x = MinX()); + F(Cop.x = MaxX()); + + F(Cop.y = MinY()); + F(Cop.y = MaxY()); + + +} + +always guarantee { + + //Cop.x maxX eventually cop.x minX and inverse + Cop.x = MaxX() -> F(Cop.x = MinX()); + Cop.x = MinX() -> F(Cop.x = MaxX()); + + Cop.y = MaxY() -> F(Cop.y = MinY()); + Cop.y = MinY() -> F(Cop.y = MaxY()); + + [Cop.x <- Cop.x + 1] || [Cop.x <- Cop.x - 1]; + + [Cop.y <- Cop.y + 1] || [Cop.y <- Cop.y - 1]; + + + // X Coordinate Ping Pong Effects + (Cop.x = MinX() && (!(X (Cop.x) = MinX()))) -> (!( [Cop.x <- Cop.x - 1]) U (Cop.x = MaxX())); + (Cop.x = MaxX() && (!(X (Cop.x) = MaxX()))) -> (!( [Cop.x <- Cop.x + 1]) U (Cop.x = MinX())); + + (Cop.y = MinY() && (!(X (Cop.y) = MinY()))) -> (!( [Cop.y <- Cop.y - 1]) U (Cop.y = MaxY())); + (Cop.y = MaxY() && (!(X (Cop.y) = MaxY()))) -> (!( [Cop.y <- Cop.y + 1]) U (Cop.y = MinY())); + + + +} \ No newline at end of file From c25e6c89e431af8ea70a1fd28fb229e96b1f6d21 Mon Sep 17 00:00:00 2001 From: wfishell Date: Tue, 10 Jun 2025 16:28:25 -0400 Subject: [PATCH 5/6] making strong until --- TestC_R_Files/PingPong_StrongUntil.tslmt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/TestC_R_Files/PingPong_StrongUntil.tslmt b/TestC_R_Files/PingPong_StrongUntil.tslmt index 0389c8a..b7bfd81 100644 --- a/TestC_R_Files/PingPong_StrongUntil.tslmt +++ b/TestC_R_Files/PingPong_StrongUntil.tslmt @@ -42,7 +42,6 @@ always guarantee { (Cop.y = MinY() && (!(X (Cop.y) = MinY()))) -> (!( [Cop.y <- Cop.y - 1]) U (Cop.y = MaxY())); (Cop.y = MaxY() && (!(X (Cop.y) = MaxY()))) -> (!( [Cop.y <- Cop.y + 1]) U (Cop.y = MinY())); - - + //empty comment } \ No newline at end of file From 80fd46c009ec7a9099ef3f5a8d4b1197d625205a Mon Sep 17 00:00:00 2001 From: wfishell Date: Tue, 10 Jun 2025 16:40:13 -0400 Subject: [PATCH 6/6] Strong Until --- TestC_R_Files/PingPong_StrongUntil.tslmt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestC_R_Files/PingPong_StrongUntil.tslmt b/TestC_R_Files/PingPong_StrongUntil.tslmt index b7bfd81..f7d1c72 100644 --- a/TestC_R_Files/PingPong_StrongUntil.tslmt +++ b/TestC_R_Files/PingPong_StrongUntil.tslmt @@ -42,6 +42,6 @@ always guarantee { (Cop.y = MinY() && (!(X (Cop.y) = MinY()))) -> (!( [Cop.y <- Cop.y - 1]) U (Cop.y = MaxY())); (Cop.y = MaxY() && (!(X (Cop.y) = MaxY()))) -> (!( [Cop.y <- Cop.y + 1]) U (Cop.y = MinY())); - //empty comment + // } \ No newline at end of file