readme and world picker

This commit is contained in:
Dominic DiTaranto 2025-08-29 21:46:48 -04:00
parent f37f655fb9
commit 2a182c4fb6
2 changed files with 27 additions and 11 deletions

View file

@ -2,7 +2,12 @@
Welcome to PYSOKOBAN!
The object of the game is to move all of the boulders to specific storage
positions in the shortest amount of moves possible.
positions in the shortest amount of moves possible.
With 13 worlds and 617 different levels, you will never be bored (unless you do not like sokoban, of course)!
All levels were STOLEN from [here](http://www.sneezingtiger.com/sokoban/levels.html). I did not write any of the levels... maybe I will one day.
```
KEY MOVEMENT
+===========================================+
@ -10,8 +15,14 @@ positions in the shortest amount of moves possible.
| @ | you || \ | / | \ | / |
| # | wall || h- . -l | 4- . -6 |
| 0 | boulder || / | \ | / | \ |
| . | storage || b j n | 1 2 3 |
| * | stored^ || b j n | 1 2 3
| . | storage || | |
+===========================================+
```
## Getting Started
1. Create virtual environment with: `python3 -m venv venv`
2. Activate virtual environment with: `sourve venv/bin/activate`
3. Install Requirements with: `pip install -r requirements.txt`
4. Play the game with: `python3 main.py`

23
main.py
View file

@ -281,17 +281,22 @@ class Map:
if __name__ == '__main__':
def get_world_response():
response = input('Which world would you like to play? Input a number: ')
parser = argparse.ArgumentParser(prog='pysokoban')
parser.add_argument('-w', '--world', dest='world', choices=WORLD_MAP.keys())
args = parser.parse_args()
if response not in [str(idx) for idx, _ in enumerate(list(WORLD_MAP.keys()))]:
return get_world_response()
if args.world in WORLD_MAP:
world = args.world
levels = WORLD_MAP.get(args.world)
else:
world = list(WORLD_MAP.keys())[random.randint(0, len(WORLD_MAP.keys()))]
levels = WORLD_MAP.get(world)
return response
os.system('clear')
for idx, name in enumerate(list(WORLD_MAP.keys())):
print(f'[{idx}] {name}')
random_idx = idx + 1
print(f'[{random_idx}] random world')
world = list(WORLD_MAP.keys())[int(get_world_response())]
levels = WORLD_MAP.get(world)
g = Game()
g.initialize_level()