From 646b816c06a4b563be62be8ff2d99d286c9a7126 Mon Sep 17 00:00:00 2001 From: FireCubez <39168965+FireCubez@users.noreply.github.com> Date: Thu, 20 Feb 2020 22:54:57 +0200 Subject: [PATCH] Make + and - wrap More compatible with most implementations --- BrainfuckInterpreter.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/BrainfuckInterpreter.py b/BrainfuckInterpreter.py index 98761ca..32476b9 100644 --- a/BrainfuckInterpreter.py +++ b/BrainfuckInterpreter.py @@ -57,10 +57,13 @@ def interpret(self, command): elif command == '+': if self.cells[self.pointer] < 255: self.cells[self.pointer] += 1 - + else: + self.cells[self.pointer] = 0 elif command == '-': if self.cells[self.pointer] > 0: self.cells[self.pointer] -= 1 + else: + self.cells[self.pointer] = 255 elif command == '.': if self.pointer in self.cells: