From 45dd6b9c5c65282e76250be1154ab117d66d7b84 Mon Sep 17 00:00:00 2001 From: kmhswimgirl Date: Sun, 14 Sep 2025 17:53:23 -0400 Subject: [PATCH 1/5] fixed spelling error --- .gitignore | 3 ++- Bomberman/game.py | 4 ++-- teamNN/interactivecharacter.py | 4 ++-- teamNN/project1/variant1.py | 10 +++++----- teamNN/testcharacter.py | 4 ++-- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 3531c981..c897feb3 100644 --- a/.gitignore +++ b/.gitignore @@ -181,5 +181,6 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk +# my venv environment +.bomberman # End of https://www.gitignore.io/api/linux,macos,python,pycharm,windows - diff --git a/Bomberman/game.py b/Bomberman/game.py index 9370d941..12b514bb 100644 --- a/Bomberman/game.py +++ b/Bomberman/game.py @@ -7,13 +7,13 @@ class Game: """Game class""" - def __init__(self, width, height, max_time, bomb_time, expl_duration, expl_range, sprite_dir="../../bomberman/sprites/"): + def __init__(self, width, height, max_time, bomb_time, expl_duration, expl_range, sprite_dir="../../Bomberman/sprites/"): self.world = RealWorld.from_params(width, height, max_time, bomb_time, expl_duration, expl_range) self.sprite_dir = sprite_dir self.load_gui(width, height) @classmethod - def fromfile(cls, fname, sprite_dir="../../bomberman/sprites/"): + def fromfile(cls, fname, sprite_dir="../../Bomberman/sprites/"): with open(fname, 'r') as fd: # First lines are parameters max_time = int(fd.readline().split()[1]) diff --git a/teamNN/interactivecharacter.py b/teamNN/interactivecharacter.py index cd1c4acd..8222ef09 100644 --- a/teamNN/interactivecharacter.py +++ b/teamNN/interactivecharacter.py @@ -1,8 +1,8 @@ # This is necessary to find the main code import sys -sys.path.insert(0, '../bomberman') +sys.path.insert(0, '../Bomberman') # Import necessary stuff -from entity import CharacterEntity +from entity import CharacterEntity # type: ignore from colorama import Fore, Back class InteractiveCharacter(CharacterEntity): diff --git a/teamNN/project1/variant1.py b/teamNN/project1/variant1.py index 54389be8..148921ac 100644 --- a/teamNN/project1/variant1.py +++ b/teamNN/project1/variant1.py @@ -1,16 +1,16 @@ # This is necessary to find the main code import sys -sys.path.insert(0, '../../bomberman') +sys.path.insert(0, '../../Bomberman') sys.path.insert(1, '..') # Import necessary stuff -from game import Game +from game import Game # type: ignore # TODO This is your code! sys.path.insert(1, '../teamNN') # Uncomment this if you want the empty test character -#from testcharacter import TestCharacter +# from testcharacter import TestCharacter # Uncomment this if you want the interactive character from interactivecharacter import InteractiveCharacter @@ -35,7 +35,7 @@ # Run! # Use this if you want to press ENTER to continue at each step -# g.go(0) +g.go(0) # Use this if you want to proceed automatically -g.go(1) +# g.go(1) diff --git a/teamNN/testcharacter.py b/teamNN/testcharacter.py index 6f13216f..b9aa6b1e 100644 --- a/teamNN/testcharacter.py +++ b/teamNN/testcharacter.py @@ -1,8 +1,8 @@ # This is necessary to find the main code import sys -sys.path.insert(0, '../bomberman') +sys.path.insert(0, '../Bomberman') # Import necessary stuff -from entity import CharacterEntity +from entity import CharacterEntity # type: ignore from colorama import Fore, Back class TestCharacter(CharacterEntity): From 270233deb1a9d58cdd0e3e52f7570eb3c1fb6c08 Mon Sep 17 00:00:00 2001 From: kmhswimgirl Date: Sun, 14 Sep 2025 19:38:45 -0400 Subject: [PATCH 2/5] test one --- teamNN/character_one.py | 68 +++++++++++++++++++++++++++++++++++++ teamNN/project1/variant1.py | 15 +++++--- 2 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 teamNN/character_one.py diff --git a/teamNN/character_one.py b/teamNN/character_one.py new file mode 100644 index 00000000..93b4068b --- /dev/null +++ b/teamNN/character_one.py @@ -0,0 +1,68 @@ +# This is necessary to find the main code +import sys +sys.path.insert(0, '../Bomberman') + +# Import necessary stuff +from entity import CharacterEntity # type: ignore +from colorama import Fore, Back + +class CharacterOne(CharacterEntity): + + def do(self, wrld): + # Commands + dx, dy = 0, 0 + bomb = False + + path = [ + 'R','R','R','R', + 'D','D','D','D','D','D', + 'L', + 'D','D','D','D', + 'R', + 'D','D','D','D', + ] + + ''' + Hard coded path: + --------------- + 4 R + 6 D + 1 L + 4 D + 1 R + 4 D + 1 L + 4 D + 4 R + ''' + if not hasattr(self, 'step'): + self.step = 0 + + if self.step < len(path): # if there is still steps left in the path + if self.step < len(path): + move = path[self.step] + if move == 'U': + dy = -1 + elif move == 'L': + dx = -1 + elif move == 'D': + dy = 1 + elif move == 'R': + dx = 1 + + new_x = self.x + dx + new_y = self.y + dy + + if wrld.empty_at(new_x, new_y): + self.step += 1 + else: + self.step += 1 + dx, dy = 0, 0 # no moving if blocked + else: + dx, dy = 0, 0 + + # Execute commands + self.move(dx, dy) + if bomb: + self.place_bomb() + pass \ No newline at end of file diff --git a/teamNN/project1/variant1.py b/teamNN/project1/variant1.py index 148921ac..060697dc 100644 --- a/teamNN/project1/variant1.py +++ b/teamNN/project1/variant1.py @@ -14,6 +14,7 @@ # Uncomment this if you want the interactive character from interactivecharacter import InteractiveCharacter +from character_one import CharacterOne # Create the game g = Game.fromfile('map.txt') @@ -26,12 +27,18 @@ # 0, 0 # position # )) -# Uncomment this if you want the interactive character -g.add_character(InteractiveCharacter("me", # name - "C", # avatar - 0, 0 # position +# Uncomment this if you want the variant character +g.add_character(CharacterOne("me", # name + "C", # avatar + 0, 0 # position )) +# Uncomment this if you want the interactive character +# g.add_character(InteractiveCharacter("me", # name +# "C", # avatar +# 0, 0 # position +# )) + # Run! # Use this if you want to press ENTER to continue at each step From 7129b37cfa82fcc01ea6a654d574971cdc197b6c Mon Sep 17 00:00:00 2001 From: kmhswimgirl Date: Sun, 14 Sep 2025 19:50:33 -0400 Subject: [PATCH 3/5] variant one done hardcoded path, may need to switch to A* in case they have a different map --- teamNN/project1/variant1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/teamNN/project1/variant1.py b/teamNN/project1/variant1.py index 060697dc..8004fa19 100644 --- a/teamNN/project1/variant1.py +++ b/teamNN/project1/variant1.py @@ -42,7 +42,7 @@ # Run! # Use this if you want to press ENTER to continue at each step -g.go(0) +#g.go(0) # Use this if you want to proceed automatically -# g.go(1) +g.go(1) From f83c088106516fe7f0c99d9e3079a904eed990dc Mon Sep 17 00:00:00 2001 From: kmhswimgirl Date: Sun, 14 Sep 2025 20:05:23 -0400 Subject: [PATCH 4/5] minor changes to path --- teamNN/character_one.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/teamNN/character_one.py b/teamNN/character_one.py index 93b4068b..b42b8d5f 100644 --- a/teamNN/character_one.py +++ b/teamNN/character_one.py @@ -20,8 +20,11 @@ def do(self, wrld): 'D','D','D','D', 'R', 'D','D','D','D', + 'L', + 'D','D','D','D', + 'R','R','R','R' ] - + ''' Hard coded path: --------------- @@ -53,11 +56,11 @@ def do(self, wrld): new_x = self.x + dx new_y = self.y + dy - if wrld.empty_at(new_x, new_y): + if wrld.empty_at(new_x, new_y) or wrld.exit_at(new_x, new_y): self.step += 1 else: self.step += 1 - dx, dy = 0, 0 # no moving if blocked + dx, dy = 0, 0 # no moving if blocked (aka i hardcoded the path incorrectly lmao) else: dx, dy = 0, 0 From affc64322cd0797030bc6e5a36e8a3f5e79c73e3 Mon Sep 17 00:00:00 2001 From: kmhswimgirl Date: Sun, 14 Sep 2025 21:23:29 -0400 Subject: [PATCH 5/5] all sys.path.insert fixed --- teamNN/character_one.py | 71 ------------------------------------- teamNN/project1/variant1.py | 15 +++----- teamNN/project1/variant2.py | 2 +- teamNN/project1/variant3.py | 2 +- teamNN/project1/variant4.py | 2 +- teamNN/project1/variant5.py | 2 +- teamNN/project2/variant1.py | 2 +- teamNN/project2/variant2.py | 2 +- teamNN/project2/variant3.py | 2 +- teamNN/project2/variant4.py | 2 +- teamNN/project2/variant5.py | 2 +- 11 files changed, 13 insertions(+), 91 deletions(-) delete mode 100644 teamNN/character_one.py diff --git a/teamNN/character_one.py b/teamNN/character_one.py deleted file mode 100644 index b42b8d5f..00000000 --- a/teamNN/character_one.py +++ /dev/null @@ -1,71 +0,0 @@ -# This is necessary to find the main code -import sys -sys.path.insert(0, '../Bomberman') - -# Import necessary stuff -from entity import CharacterEntity # type: ignore -from colorama import Fore, Back - -class CharacterOne(CharacterEntity): - - def do(self, wrld): - # Commands - dx, dy = 0, 0 - bomb = False - - path = [ - 'R','R','R','R', - 'D','D','D','D','D','D', - 'L', - 'D','D','D','D', - 'R', - 'D','D','D','D', - 'L', - 'D','D','D','D', - 'R','R','R','R' - ] - - ''' - Hard coded path: - --------------- - 4 R - 6 D - 1 L - 4 D - 1 R - 4 D - 1 L - 4 D - 4 R - ''' - if not hasattr(self, 'step'): - self.step = 0 - - if self.step < len(path): # if there is still steps left in the path - if self.step < len(path): - move = path[self.step] - if move == 'U': - dy = -1 - elif move == 'L': - dx = -1 - elif move == 'D': - dy = 1 - elif move == 'R': - dx = 1 - - new_x = self.x + dx - new_y = self.y + dy - - if wrld.empty_at(new_x, new_y) or wrld.exit_at(new_x, new_y): - self.step += 1 - else: - self.step += 1 - dx, dy = 0, 0 # no moving if blocked (aka i hardcoded the path incorrectly lmao) - else: - dx, dy = 0, 0 - - # Execute commands - self.move(dx, dy) - if bomb: - self.place_bomb() - pass \ No newline at end of file diff --git a/teamNN/project1/variant1.py b/teamNN/project1/variant1.py index 8004fa19..532b31e3 100644 --- a/teamNN/project1/variant1.py +++ b/teamNN/project1/variant1.py @@ -14,7 +14,6 @@ # Uncomment this if you want the interactive character from interactivecharacter import InteractiveCharacter -from character_one import CharacterOne # Create the game g = Game.fromfile('map.txt') @@ -27,17 +26,11 @@ # 0, 0 # position # )) -# Uncomment this if you want the variant character -g.add_character(CharacterOne("me", # name - "C", # avatar - 0, 0 # position -)) - # Uncomment this if you want the interactive character -# g.add_character(InteractiveCharacter("me", # name -# "C", # avatar -# 0, 0 # position -# )) +g.add_character(InteractiveCharacter("me", # name + "C", # avatar + 0, 0 # position +)) # Run! diff --git a/teamNN/project1/variant2.py b/teamNN/project1/variant2.py index 306f08e8..1825d671 100644 --- a/teamNN/project1/variant2.py +++ b/teamNN/project1/variant2.py @@ -1,6 +1,6 @@ # This is necessary to find the main code import sys -sys.path.insert(0, '../../bomberman') +sys.path.insert(0, '../../Bomberman') sys.path.insert(1, '..') # Import necessary stuff diff --git a/teamNN/project1/variant3.py b/teamNN/project1/variant3.py index 3d229181..b47d34ba 100644 --- a/teamNN/project1/variant3.py +++ b/teamNN/project1/variant3.py @@ -1,6 +1,6 @@ # This is necessary to find the main code import sys -sys.path.insert(0, '../../bomberman') +sys.path.insert(0, '../../Bomberman') sys.path.insert(1, '..') # Import necessary stuff diff --git a/teamNN/project1/variant4.py b/teamNN/project1/variant4.py index 81e4a631..9e33c7cb 100644 --- a/teamNN/project1/variant4.py +++ b/teamNN/project1/variant4.py @@ -1,6 +1,6 @@ # This is necessary to find the main code import sys -sys.path.insert(0, '../../bomberman') +sys.path.insert(0, '../../Bomberman') sys.path.insert(1, '..') # Import necessary stuff diff --git a/teamNN/project1/variant5.py b/teamNN/project1/variant5.py index 807d4942..31670927 100644 --- a/teamNN/project1/variant5.py +++ b/teamNN/project1/variant5.py @@ -1,6 +1,6 @@ # This is necessary to find the main code import sys -sys.path.insert(0, '../../bomberman') +sys.path.insert(0, '../../Bomberman') sys.path.insert(1, '..') # Import necessary stuff diff --git a/teamNN/project2/variant1.py b/teamNN/project2/variant1.py index 6d1d284c..459ac777 100644 --- a/teamNN/project2/variant1.py +++ b/teamNN/project2/variant1.py @@ -1,6 +1,6 @@ # This is necessary to find the main code import sys -sys.path.insert(0, '../../bomberman') +sys.path.insert(0, '../../Bomberman') sys.path.insert(1, '..') # Import necessary stuff diff --git a/teamNN/project2/variant2.py b/teamNN/project2/variant2.py index 306f08e8..1825d671 100644 --- a/teamNN/project2/variant2.py +++ b/teamNN/project2/variant2.py @@ -1,6 +1,6 @@ # This is necessary to find the main code import sys -sys.path.insert(0, '../../bomberman') +sys.path.insert(0, '../../Bomberman') sys.path.insert(1, '..') # Import necessary stuff diff --git a/teamNN/project2/variant3.py b/teamNN/project2/variant3.py index 3d229181..b47d34ba 100644 --- a/teamNN/project2/variant3.py +++ b/teamNN/project2/variant3.py @@ -1,6 +1,6 @@ # This is necessary to find the main code import sys -sys.path.insert(0, '../../bomberman') +sys.path.insert(0, '../../Bomberman') sys.path.insert(1, '..') # Import necessary stuff diff --git a/teamNN/project2/variant4.py b/teamNN/project2/variant4.py index 81e4a631..9e33c7cb 100644 --- a/teamNN/project2/variant4.py +++ b/teamNN/project2/variant4.py @@ -1,6 +1,6 @@ # This is necessary to find the main code import sys -sys.path.insert(0, '../../bomberman') +sys.path.insert(0, '../../Bomberman') sys.path.insert(1, '..') # Import necessary stuff diff --git a/teamNN/project2/variant5.py b/teamNN/project2/variant5.py index 96f1503b..eee88d81 100644 --- a/teamNN/project2/variant5.py +++ b/teamNN/project2/variant5.py @@ -1,6 +1,6 @@ # This is necessary to find the main code import sys -sys.path.insert(0, '../../bomberman') +sys.path.insert(0, '../../Bomberman') sys.path.insert(1, '..') # Import necessary stuff