安装 Steam
登录
|
语言
繁體中文(繁体中文)
日本語(日语)
한국어(韩语)
ไทย(泰语)
български(保加利亚语)
Čeština(捷克语)
Dansk(丹麦语)
Deutsch(德语)
English(英语)
Español-España(西班牙语 - 西班牙)
Español - Latinoamérica(西班牙语 - 拉丁美洲)
Ελληνικά(希腊语)
Français(法语)
Italiano(意大利语)
Bahasa Indonesia(印度尼西亚语)
Magyar(匈牙利语)
Nederlands(荷兰语)
Norsk(挪威语)
Polski(波兰语)
Português(葡萄牙语 - 葡萄牙)
Português-Brasil(葡萄牙语 - 巴西)
Română(罗马尼亚语)
Русский(俄语)
Suomi(芬兰语)
Svenska(瑞典语)
Türkçe(土耳其语)
Tiếng Việt(越南语)
Українська(乌克兰语)
报告翻译问题









I need a script that can receive more than 2,000,000 gold per minute.
unfortunately, my script can only output 1,110,000 per minute.
def opposite_direction(dir):
return {
North: South,
East: West,
West: East,
South: North
}[dir]
def rec(dir):
if get_entity_type() == Entities.Treasure:
harvest()
return True
for d in [North, East, West, South]:
if d != opposite_direction(dir) and move(d):
if rec(d):
return True
move(opposite_direction(dir))
return False
def one_maze():
i = 0
if get_entity_type() != Entities.Bush and get_entity_type() != Entities.Hedge:
harvest()
plant(Entities.Bush)
while get_entity_type() == Entities.Bush:
if num_items(Items.Fertilizer) == 0:
trade(Items.Fertilizer)
use_item(Items.Fertilizer)
if get_entity_type() == Entities.Treasure:
harvest()
return
for d in [North, East, West, South]:
if move(d):
if rec(d):
break
return True
It starts with some support functions, followed by the actual program
def Maze():
def expecting(ground):
if get_ground_type()!=ground:
till()
def fertilize():
if num_items(Items.Fertilizer)<=1 and num_items(Items.Pumpkin)>=10:
if not trade(Items.Fertilizer):
return False
elif num_items(Items.Pumpkin)<=10:
return False
if num_items(Items.Fertilizer)>1:
return use_item(Items.Fertilizer)
def plant_bush():
expecting(Grounds.Turf)
plant(Entities.Bush)
def plant_maze():
harvest()
plant_bush()
while get_entity_type() != Entities.Hedge:
fertilize()
return None
dirs = [North,West,South,East]
dir = 0
plant_maze()
while get_entity_type() != Entities.Treasure:
while not move(dirs[dir]):
dir = (dir + 1) % 4
dir = (dir - 1) % 4
harvest()
return True
And the modulo is a brilliant change. Well done!
Also (advanced) you can simnplify the calculation of the direction using modulo.
[code]
dirs = [North, East, South, West]
dir = 0
while get_entity_type() != Entities.Treasure:
while not move(dirs[dir]):
dir = (dir + 1) % 4
dir = (dir - 1) % 4
harvest()[/code]