Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
dir = [North, East, South, West] #We'll use this to find which direction to go next
d = 0
clear()
while(True): #Infinite loop. Will run as long as you have WS
----plant(Entities.Bush)
----use_item(Items.Weird_Substance, 100) #change 100 for the desired amount of WS
----|---while get_entity_type() != Entities.Treasure: #Run until you run into the treasure
----|---|---if not move(dir[d]): #Try to move in the chosen direction
----|---|---|---d = (d + 1) % 4 #If you moved, turn right
----|---|---else:
----|---|---|---d = (d - 1) % 4 #If you didn't move, turn left
----|---harvest() #Profit. Rinse and repeat
Steam is not great for formatting code... So I added some "-"s and "|" to mark indentation.
def dfs(visited):
----if get_entity_type() == Entities.Treasure:
----|---return True
----for dir in [North, East, South, West]:
----|---if move(dir):
----|---|---if get_pos() not in visited:
----|---|---|---visited.add(get_pos())
----|---|---|---if dfs(visited):
----|---|---|---|---return True
----|---|---move(opposite(dir))
----return False
Moving and then checking if we have already visited is not really efficient, it would be better to write a function to tell you where you would have ended up if you moved, and check if that position is already visited before trying to move. But I'll leave it as this for simplicity.
def harvest_treasure_new(req):
#start_maze() #creates a maze
while num_items(Items.Gold) < req:
#list of all directions, and a todo list of directions yet to be gone
directions = [North, East, South, West]
todo = list(directions)
while get_entity_type() != Entities.Treasure:
#write something that checks if there is a wall at the last location in todo,
#if there is a wall, remove the item, and go to the next one.
#if there is no wall, go that direction.
#issue being, it doesnt know when it should be backtracking
#instead of forging a new path
#add all 4 directions to our to-do list, the one we came from first
#figures out which item is at todo[-1], and sets previousDirection to its opposite
for dex in range(4):
if directions[dex] == todo[-1]:
previousDirection = directions[(dex+2)%4]
#append previousDirection to todo
todo.append(previousDirection)
#append the other directions to todo
for dir in directions:
if dir != previousDirection:
todo.append(dir)
#found treasure
print('Success!')
if measure() == None:
start_maze() #creates a maze
while get_entity_type() == Entities.Treasure:
use_fertilizer() #if there isnt enough fertilizer, trades for some, then uses it