你是一名外国商人,希望从中获利。有5种商品是人们想要交易的:A价格,B桨,C花香,D花卉和E树。从冬天开始,你需要决定生产什么。然后,在秋天,你旅行和花费你的日子交易利润。
你开始游戏的每一个产品中的10个在存储。每年,你将消耗每种产品中的2种。
在游戏开始的时候,你会收到一个5种产品的列表,以及你每年可以生产的数量(例如:5-A,6-B,3-C,12-D,4-E)。然后你将返回一个字母A到E,决定生产什么。
然后,在秋季,你将把你的产品(包括那些储存的)带到市场上。你有50次转向交易。
你必须决定你是想Purchase,Sell,还是L离开市场。然后,买家将随机与卖方配对。如果一个团体有额外的,随机额外的将错过这个回合。如果一个交易者被跳过,他们将收到S,否则,T。卖方必须决定他想卖出什么,数量(例如:3-A),然后决定他会接受什么(例如:5-B,2-D,1-E)(价值不是全部)。然后,买方将被告知卖方在销售什么产品,然后卖方将为其购买哪些产品,他可以选择一种产品进行交易(例如:D或X )。
在所有的交易结束后,或者在你离开市场之后,你将消耗每种产品中的2种,而新的一年开始了。如果任何1种产品中少于2种,就会死掉(并通过了Q)。
你的分数将是你最后的年数,在50场比赛后,你的分数将被平均为你的总分。
您可以随时返回G查询您的商品。
在任何时候,您都可以返回N查询库存中的新产品数量(在过去的一年中由任何厂商生产,新产品将在旧产品之前进行交易)
在任何时候,您都可以为当前的转弯短语返回T:P、M、arket或Trading。
在交易期间,您可以查询I以获得与您进行交易的播放机所特有的标识符。
在交易期间,可以返回M查询交易人数。
您可以使用任何标准语言,并且必须包括一个command.txt,它是运行程序的命令。
程序的一般流程应该是:
Get productivity
While alive:
Output product you want to produce
While in trading:
Output whether you want to purchase or sell
Get whether or not you were skipped. If not skipped:
If purchasing:
print product you offer, and products you will accept
Else:
Get product offered, products being accepted, and choose the product you will give我有一个测试程序这里。若要使用它,请在“机器人”文件夹中创建一个具有机器人名称的文件夹。添加一个command.txt、您的程序以及您的程序所需要的任何其他内容。我将在他们进来的时候添加意见书。如果不想安装运行部分或全部所需的语言,只需删除bot文件夹中的command.txt即可。
将有5个机器人为每个程序提交。对于同一类型的机器人,ID将有所不同。
我将把一个人生产某一产品的数量称为生产力。每个产品将被赋予一个基本生产力,所有的基本生产力加起来将达到30。其中一个分数将保证最多为3分,所有分数至少为2分。
然后,每个玩家的生产力将与基本生产力不同(一个值将改变+2,另一个值将改变+1,然后+0,-1,其余值将变化到-2)。
基本生产力将在不同的游戏中改变。
seer: 10.128 years
level_headed_trader: 8.196 years
introvert: 6.856 years
random_ando: 5.408 years
hoarder_trader: 4.12 years
ratio_trader: 3.532 years
scared_trader: 3.056 years发布于 2014-08-18 01:08:27
这个机器人试图使他的数量尽可能地相等。
python leveller.pyimport sys
def current_goods():
print "G"
return parse_goods(readline())
def parse_goods(good_string):
return dict([(a, int(b))
for a, b in [product.split("-")
for product in good_string.split(",")]])
def get_minimum(goods):
cur_min = 200
min_good = "X"
for good, amount in goods.items():
if amount < cur_min:
min_good = good
cur_min = amount
return min_good
def get_maximum(goods):
cur_max = -1
max_good = "X"
for good, amount in goods.items():
if amount > cur_max:
max_good = good
cur_max = amount
return max_good
def add_goods(x, y):
return {k: int(x.get(k, 0)) + int(y.get(k, 0)) for k in set(x) | set(y)}
def readline():
line = sys.stdin.readline().strip()
if line == 'Q' or not line:
exit()
return line
def output_goods(goods):
print ",".join([good+"-"+str(amount) for good, amount in goods.items()])
def output_good(good, amount):
print good+"-"+str(amount)
def current_turn_is(turn):
print "T"
return readline() == turn
turns = MARKET, PRODUCE, TRADING, SKIPPED = "M", "P", "T", "S"
market_options = PURCHASE, SELL = "P", "S"
items = APRICOTS, BOARS, CANARIES, DAFFODILS, EARWIGS, NOTHING = "A", "B", "C", "D", "E", "X"
productivity = parse_goods(readline())
while True:
product_to_produce = get_minimum(current_goods())
print product_to_produce
while current_turn_is(MARKET):
print SELL
if readline() != SKIPPED:
maximum = get_maximum(current_goods())
goods = {"A": 1, "B": 1, "C": 1, "D": 1, "E": 1}
del goods[maximum]
output_good(maximum, 1)
output_goods(goods)发布于 2014-08-18 01:11:39
这个交易者避免得到低的数字。
python scared.pyimport sys
def current_goods():
print "G"
return parse_goods(readline())
def parse_goods(good_string):
return dict([(a, int(b))
for a, b in [product.split("-")
for product in good_string.split(",")]])
def get_minimum(goods):
cur_min = 200
min_good = "X"
for good, amount in goods.items():
if amount < cur_min:
min_good = good
cur_min = amount
return min_good
def get_maximum(goods):
cur_max = -1
max_good = "X"
for good, amount in goods.items():
if amount > cur_max:
max_good = good
cur_max = amount
return max_good
def add_goods(x, y):
return {k: int(x.get(k, 0)) + int(y.get(k, 0)) for k in set(x) | set(y)}
def readline():
line = sys.stdin.readline().strip()
if line == 'Q' or not line:
exit()
return line
def output_goods(goods):
print ",".join([good+"-"+str(amount) for good, amount in goods.items()])
def output_good(good, amount):
print good+"-"+str(amount)
def current_turn_is(turn):
print "T"
return readline() == turn
turns = MARKET, PRODUCE, TRADING, SKIPPED = "M", "P", "T", "S"
market_options = PURCHASE, SELL = "P", "S"
items = APRICOTS, BOARS, CANARIES, DAFFODILS, EARWIGS, NOTHING = "A", "B", "C", "D", "E", "X"
productivity = parse_goods(readline())
while True:
current = current_goods()
min_product = get_minimum(current)
min_amount = current[min_product]
product_to_produce = min_product if min_amount < 4 else get_minimum(productivity)
print product_to_produce
while current_turn_is(MARKET):
print SELL
if readline() != SKIPPED:
current = current_goods()
maximum = get_maximum(current)
minimum = get_minimum(current)
to_offer = {maximum: max(productivity[maximum]/productivity[minimum], 1)}
output_good(minimum, 1)
output_goods(goods=to_offer)发布于 2014-08-18 01:06:27
这个商人试图获得尽可能多的产品。
python hoarder.pyimport sys
def current_goods():
print "G"
return parse_goods(readline())
def parse_goods(good_string):
try:
return dict([(a, int(b))
for a, b in [product.split("-")
for product in good_string.split(",")]])
except:
raise IOError(good_string)
def get_minimum(goods):
cur_min = 200
min_good = "X"
for good, amount in goods.items():
if amount < cur_min:
min_good = good
cur_min = amount
return min_good
def get_maximum(goods):
cur_max = -1
max_good = "X"
for good, amount in goods.items():
if amount > cur_max:
max_good = good
cur_max = amount
return max_good
def add_goods(x, y):
return {k: int(x.get(k, 0)) + int(y.get(k, 0)) for k in set(x) | set(y)}
def readline():
line = sys.stdin.readline().strip()
if line == 'Q' or not line:
exit()
return line
def output_goods(goods):
print ",".join([good+"-"+str(amount) for good, amount in goods.items()])
def output_good(good, amount):
print good+"-"+str(amount)
def current_turn_is(turn):
print "T"
return readline() == turn
turns = MARKET, PRODUCE, TRADING, SKIPPED = "M", "P", "T","S"
market_options = PURCHASE, SELL = "P", "S"
items = APRICOTS, BOARS, CANARIES, DAFFODILS, EARWIGS, NOTHING = "A", "B", "C", "D", "E", "X"
productivity = parse_goods(readline())
while True:
product_to_produce = get_minimum(add_goods(current_goods(), productivity))
print product_to_produce
while current_turn_is(MARKET):
print PURCHASE
if readline() != SKIPPED:
offered_good = parse_goods(readline())
accepted_goods = parse_goods(readline())
minimum = get_minimum(accepted_goods)
current = current_goods()
if minimum not in current or current[minimum] < accepted_goods[minimum]:
print NOTHING
elif accepted_goods[minimum] < offered_good.values()[0]:
print minimum
elif accepted_goods[minimum] == offered_good.values()[0] \
and productivity[minimum] > productivity[offered_good.keys()[0]]:
print minimum
else:
print NOTHINGhttps://codegolf.stackexchange.com/questions/36343
复制相似问题