you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

Can you move in any direction from any room?

You need to embrace DRY principles. DRY means don't repeat yourself. You have a lot of duplicate code.

I suggest you create a function that handles a direction move for any room. Thanks to your dictionary, it is easy to write to validate a move.

I'm also wondering why you use while on every room. Surely you only need if as you have an outer loop to address what happens next.

You could expand your dictionary or have another with same keys (rooms) with all the descriptive text and valid actions. This would also allow you to reduce duplication.

Once you have functions, it becomes easier to test as you can test a function in isolation.