DOMINIC SIMPSON

DOMINIC SIMPSON

Treasure Island

 

Python Treasure Island image screenshot

View GitHub repository

As a kid, I was obsessed with those Fighting Fantasy books where you created your own route through the game (“a thrilling fantasy adventure in which YOU are the hero!”). I played them for hours and had a huge collection of the series, purchased from the local WH Smiths. They opened up a whole fantasy landscape that’s been superseded by increasingly complex and elaborate computer games. Yet, just as with Dungeons & Dragons, in the era of the Internet and immersive games like Grand Theft Auto, the Fighting Fantasy books have a nostalgic charm all of their own.

Fighting Fantasy - Sorcery Volume 1 BookFighting Fantasy - Sorcery Volume 2 BookFighting Fantasy - Sorcery Volume 3 BookFighting Fantasy - Sorcery Volume 4 - Book

 

Fighting Fantasy - The Warlock of Firetop Mountain book

Fighting Fantasy - The Forest of Doom bookFighting Fantasy - City of Thieves bookFighting Fantasy - Trial of Champions book

 

 

 

 

 

 

 

 

The code in the GitHub repository linked above is a simplified version of those Fighting Fantasy games. You can run it in Visual Studio Code or another IDE using the Python Terminal. It’s also shown below.

Please note that this website does not display indented code. For this Python to run successfully, it needs to be indented accordingly.

 

print(”’
*******************************************************************************
| | | |
_________|________________.=””_;=.______________|_____________________|_______
| | ,-“_,=”” `”=.| |
|___________________|__”=._o`”-._ `”=.______________|___________________
| `”=._o`”=._ _`”=._ |
_________|_____________________:=._o “=._.”_.-=”‘”=.__________________|_______
| | __.–” , ; `”=._o.” ,-“””-._ “. |
|___________________|_._” ,. .` ` “ , `”-._”-._ “. ‘__|___________________
| |o`”=._` , “` `; .”. , “-._”-._; ; |
_________|___________| ;`-.o`”=._; .” ` ‘`.”\ ` . “-._ /_______________|_______
| | |o ; `”-.o`”=._“ ‘` ” ,__.–o; |
|___________________|_| ; (#) `-.o `”=.`_.–“_o.-; ;___|___________________
____/______/______/___|o;._ ” `”.o|o_.–” ;o;____/______/______/____
/______/______/______/_”=._o–._ ; | ; ; ;/______/______/______/_
____/______/______/______/__”=._o–._ ;o|o; _._;o;____/______/______/____
/______/______/______/______/____”=._o._; | ;_.–“o.–“_/______/______/______/_
____/______/______/______/______/_____”=.o|o_.–“”___/______/______/______/____
/______/______/______/______/______/______/______/______/______/______/_____ /
*******************************************************************************
”’)
print(“Welcome to Treasure Island.”)
print(“Your mission is to find the treasure.”)

choice = input(“You are at a crossroads. Where do you want to go? Type ‘Left’ or ‘Right’: “).lower()

if choice == “left”:
swimorwait = input(
“You have come to a lake. There is an island in the middle of the lake. ”
“Type ‘Wait’ to wait for a boat. Type ‘Swim’ to swim across: ”
).lower()

if swimorwait == “wait”:
whichdoor = input(
“You got the boat and arrive at the island unharmed. ”
“There is a house with three doors: red, yellow, and blue. ”
“Which colour do you choose? ”
).lower()

if whichdoor == “red”:
print(“It’s a room full of fire. Game Over.”)
elif whichdoor == “yellow”:
print(“You found the treasure map! Now let’s find the treasure!”)

row1 = [“⬜️”, “⬜️”, “⬜️”]
row2 = [“⬜️”, “⬜️”, “⬜️”]
row3 = [“⬜️”, “⬜️”, “⬜️”]
treasure_map = [row1, row2, row3]
print(f”{row1}\n{row2}\n{row3}”)

position = input(“Where do you want to put the treasure? Enter two digits: “)

if len(position) == 2 and position.isdigit():
horizontal_row = int(position[0])
vertical_column = int(position[1])
treasure_map[vertical_column – 1][horizontal_row – 1] = “X”

print(“Congratulations! You have placed the treasure on the map:”)
print(f”{row1}\n{row2}\n{row3}”)
print(“You found the treasure and won the game! Ooh aar, me hearties! Congratulations!!”)
else:
print(“Invalid input for the treasure position. Game Over.”)
elif whichdoor == “blue”:
print(“You enter a room full of poisonous beasts. Game Over.”)
else:
print(“You chose a door that doesn’t exist and spontaneously combust. Game Over.”)
else:
print(“You got attacked by an angry trout and equally angry shark. Game Over.”)
else:
print(“You fell into a hole. Oh well. Game Over.”)