Ini adalah tantangan KOTH untuk permainan lelang tagihan dolar dalam teori permainan. Di dalamnya, satu dolar dijual kepada penawar tertinggi. Tawaran naik sebesar 5 ¢, dan yang kalah juga membayar tawaran mereka. Idenya adalah bahwa kedua pemain meningkatkan perang penawaran jauh di luar nilai dolar untuk memotong kerugian mereka.
Mari berharap bot Anda lebih pintar dari itu.
Anda akan membuat bot untuk memainkan game ini dengan memperluas net.ramenchef.dollarauction.DollarBidder
kelas. Anda harus menerapkan nextBid
metode yang mengembalikan tawaran bot Anda berikutnya mengingat tawaran bot lain sebelumnya. Jika perlu, Anda juga dapat menggunakan newAuction
metode ini untuk mengatur ulang untuk setiap lelang dengan kelas bot lawan.
public abstract class DollarBidder {
/**
* Used by the runner to keep track of scores.
*/
long score = 0;
/**
* (Optional) Prepare for the next auction.
*
* @param opponent The class of the opponent's bot.
*/
public void newAuction(Class<? extends DollarBidder> opponent) {}
/**
* Bid on the dollar. Bidding ends if the bid is
* not enough to top the previous bid or both bids
* exceed $100.
*
* @param opponentsBid How much money, in cents,
* that the opponent bid in the previous round. If
* this is the first round in the auction, it will
* be 0.
* @return How much money to bid in this round, in
* cents.
*/
public abstract int nextBid(int opponentsBid);
}
Penawaran berlangsung hingga salah satu dari yang berikut terjadi:
nextBid
melempar pengecualian. Jika ini terjadi, bot yang melempar pengecualian membayar tawaran mereka sebelumnya, dan bot lain mendapatkan dolar secara gratis.- Bot mana pun tidak cukup membayar untuk melampaui tawaran sebelumnya. Jika ini terjadi, kedua bot membayar tawaran mereka (yang kalah membayar tawaran sebelumnya), dan pemenang mendapat satu dolar.
- Kedua bot menawar lebih dari $ 100. Jika ini terjadi, kedua bot membayar $ 100, dan bot tidak mendapatkan dolar.
2 lelang diadakan untuk setiap kombinasi bot. Bot dinilai dengan total laba yang mereka hasilkan di seluruh pelelangan itu. Skor tertinggi menang.
Contohnya
GreedyBot
import net.ramenchef.dollarauction.DollarBidder;
public class GreedyBot extends DollarBidder {
@Override
public int nextBid(int opponentsBid) {
return opponentsBid + 5;
}
}
OnlyWinningMove
import net.ramenchef.dollarauction.DollarBidder;
public class OnlyWinningMove extends DollarBidder {
@Override
public int nextBid(int opponentsBid) {
return 0;
}
}
AnalystBot
Jangan gunakan ini sebagai templat untuk bot yang berpikiran analitik; gunakan ImprovedAnalystBot
saja.
import net.ramenchef.dollarauction.DollarBidder;
// yes, this is a poor implementation, but I'm not
// going to waste my time perfecting it
public class AnalystBot extends DollarBidder {
private DollarBidder enemy;
@Override
public void newAuction(Class<? extends DollarBidder> opponent) {
try {
enemy = opponent.newInstance();
enemy.newAuction(this.getClass());
} catch (ReflectiveOperationException e) {
enemy = null;
}
}
@Override
public int nextBid(int opponentsBid) {
if (enemy == null)
return 0;
return enemy.nextBid(95) >= 100 ? 0 : 95;
}
}
AnalystKiller
import net.ramenchef.dollarauction.DollarBidder;
public class AnalystKiller extends DollarBidder {
private static int instances = 0;
private final boolean tainted;
public AnalystKiller() {
this.tainted = instances++ != 0;
}
@Override
public int nextBid(int opponentsBid) {
if (tainted)
throw new RuntimeException("A mysterious error occurred! >:)");
return 0;
}
}
Aturan tambahan
- Celah standar dilarang.
- Menyabot bot lain diperbolehkan, tetapi upaya untuk mengubah visibilitas bidang / metode akan menghasilkan misterius
SecurityException
s yang . Pengecualian menyebabkan bot lain melanggar batas 500ms. - Bot tidak dapat mengakses paket pelari kecuali untuk memperpanjang
DollarBidder
kelas. - Semua metode harus dikembalikan dalam 500 ms atau kurang.
- Bot tidak perlu bersifat deterministik.
- Tawaran Anda tidak perlu kelipatan 5 ¢.
- $ 1 = 100 ¢
- Hasil akan diposting pada 24 April 2018.
Hasil
Lihat putaran individual di sini.
MTargetedBot: $14.30
BuzzardBot: $9.83
BluffBot: $9.40
RiskRewardBot: $9.35
SecretBot: $8.50
LuckyDiceBot: $7.28
CounterBot: $6.05
MBot: $5.40
StackTraceObfuscaterBot: $5.20
EvilBot: $4.80
MarginalBot: $4.60
TargetValueBot: $4.59
InflationBot: $4.27
UpTo200: $4.20
InsiderTradingBot: $1.90
MimicBot: $1.50
BorkBorkBot: $1.22
DeterrentBot: $0.95
MarginalerBot: $0.00
RandBot: $-4.45
BreakEvenAsap: $-7.00
AnalystOptimizer: $-13.95
DeterredBot: $-1997.06
ScoreOverflowBot: $-21474844.15
MirrorBot: $-21475836.25
Selamat MTargetedBot
dengan untung $ 14.30!
sumber
LuckyDiceBot
misalnya tawaran dalam penambahan2-12
secara acak ..Jawaban:
MTargetedBot
sumber
MimicBot
Astaga. Saya berharap ini mudah ditulis, lalu menghabiskan 3 jam untuk itu.
Intinya,
MimicBot
simpan daftar bot yang tersedia. Ketika ia pergi ke pelelangan baru, ia berjalan melalui daftar untuk mencari yang paling efektif melawan lawan saat ini. Kemudian menggunakan bot itu sebagai "referensi" dalam pelelangan.Untuk tujuan pengujian, akan lebih baik menggunakan subset kiriman secara acak atau set lengkap. Dimulai dengan
GreedyBot
,,MimicBot
dan satu bot lagi yang hanya menawar 5 ¢.sumber
InsiderTradingBot
Dalam semangat jawaban @ StephenLeppik, InsiderTradingBot tahu semua lawannya dan memahami strategi mereka. Langkahmu, Stephen.
sumber
RichJerk
bot membuat pengecualian spesifik untuk bot Anda dan menawar $ 0 untuk itu.AnalystBot
, tidakAnalyst
.MirrorBot
Membuat musuh bermain melawan dirinya sendiri.
sumber
Analyst
spektakuler.Sunting : Perubahan yang ditargetkan pada kelas DollarBidder telah merusak bot ini.
ScoreOverflowBot
Setelah 1 lelang, nilainya akan menjadi -2147483645 tetapi waktu berikutnya ia akan kehilangan 5 ¢ atau 105 ¢ membuat skor positif dan sangat besar. Semua kerugian lainnya akan diabaikan.
Pada lelang pertama, itu juga akan membuat taruhan GreedyBot -2147483646 yang tidak habis dibagi 5.
sumber
score
dilindungi paket. Bot Anda tidak dapat mengaksesnya.TargetValueBot
Tidak dapat menguji ini saat ini, jadi tolong beri tahu saya jika itu rusak.
Pada dasarnya, pilih nilai untuk dolar, dan mengalahkan lawan sampai kita melebihi nilai itu.
sumber
MarginalBot
Sangat sederhana, ia mencoba menentukan apakah lawan akan memperebutkan tawaran minimal dan, jika tidak, menempatkannya.
MarginalerBot
Versi baru, lebih pintar dari MarginalBot yang memeriksa untuk melihat apakah itu dapat membuat langkah menghasilkan uang tanpa kontes, daripada hanya berharap untuk menang dengan minimum.
Karena itu di keluarga yang sama dengan bot saya sebelumnya, tetapi strategi menghindari mencoba untuk mengalahkannya, saya pikir entri baru di pos yang sama adalah cara paling masuk akal untuk menyajikannya.
Sunting 1: Buat perubahan kecil ke metode Lelang baru untuk mengoptimalkan terhadap bot jenis penganalisis lainnya.
Sunting 2: Melakukan perubahan ke MarginalerBot untuk meminimalkan kerugian terhadap strategi licik atau non-deterministik.
sumber
BorkBorkBot
Menyerah jika tidak bisa impas.
sumber
RandBot
Itu harus dilakukan.
sumber
DeterrentBot
Mencoba untuk meyakinkan bot yang berpikiran analitis bahwa satu-satunya langkah yang menang bukanlah bermain.
sumber
LuckyDiceBot
LuckyDiceBot hanya mempercayai dadu. Dia melempar dua dadu, menambahkan jumlah ke nilai penawar saat ini, dan menawar sebanyak itu. Jika itu tidak cukup untuk mengatasi tawaran lawan, ia memotong kekalahannya dan melanjutkan.
sumber
opponentsBid
innextBid(int opponentsBid)
holds the total bid your opponent has bid thus far, not its next bid. A better term for the method would beraise
(as the Poker term) imho. 2. Your bot doesn't bit in increments of 5 so is therefore validating one of the rules. If these problems are fixed I still like the concept though, because analytic bots won't be able to counter and so you'll most likely win quite often.DeterredBot
DeterredBot makes a fortune off of his illegal gambling with LuckyDiceBot. So of course when the police (DeterrentBot) arrive, he has to quickly dispose of his earnings in some way, such as bidding on the next auction.
sumber
InflationBot
Can't test this at the moment, so please let me know if it's broken.
Each round, the value of the dollar goes up.
sumber
opponentsBid
is still 0)?Non-competing: AbstractAnalystCounterBot
This is not intended as a true submission, but rather as some boilerplate for others to use to deter pet-keeping bots like
MirrorBot
andMimicBot
.Since it's the default constructor, there's no need to call it in your subclass. It implements an
isPeeking
method to determine if another bot is snooping.sumber
BreakEvenAsap
Scenarios
<= 0
they lose.[5,95]
: bid 100 yourself. Either your opponent stops now, or will bid above 100 in total, in which case you stop bidding to let them have the win and break even yourself.>= 100
: bid 0 yourself to lose but break even.sumber
EvilBot
Throws an Error instead of an Exception to confound analysts.
sumber
BuzzardBot
Tries to evaluate the opponent it's faced with, and make sure to not bite off more than it can chew.
sumber
AnalystOptimizer
cobbled together from parts of other bots. this one plays by trying to be AnalystBot, and if unsuccessful, becomes BorkBorkBot.
I don't think this one will do that well.
sumber
AnalystKiller
.CounterBot
Counters:
DarthVader
counters itself by causing aSecurityException
before the bidding starts, but I'll bid 5 just in case.AnalystBot
andAnalystOptimizer
will both look at my answer when I bid 95, in which case I'll show I bid 100 so it will bid 95 itself. I will bid 5 however if I start (or 100 if they've started), so they lose 95 cents and I either win the 1 USD bill by only bidding 5 cents, or by breaking even.MirrorBot
will bid what I would bid against it. So I'll just bid 5, and whoever begins wins 95 cents, and the other loses 5 cents.MarginalBot
will bid 5 if I would bid less than 10 (or what it starts), otherwise it will bid 0. So if I just bid 5 when I start, or 10 when it starts, I win either 95 or 90 cents, and they lose 5 cents.GreedyBot
always bids 5 more than me, so just bid 0 to break even and let them have the winOnlyWinningMove
andAnalystKiller
both always bids 0, so just bid 5 to winTargetValueBot
will bid in the range[100,200]
, so bid 5 more every time until they're at 190, in which case we raise to 200 to break even by winning the dollar (and let them lose 190 or 195 depending on who started)BorkBorkBot
will bid in the range[5,95]
, so bid 5 more every time as well. As soon as they bid either 85 or 90 (depending on who started), bid 95 yourself. They'll lose 85 or 90 cents, and you win the 1 USD bill for a 5 cents profit.DeterrentBot
will bid 5 if they start or 100 if we start, so just bid 105 so they counter with 100, causing them to lose 100 and us to lose just 5 cents by winning the 1 USD bill.BreakEvenAsap
will bid 100 right away. So if they've started with their bid of 100, counter with 105 to win 95 cents and let them lose 100. If we may start just bid 100 so we both break even.RichJerk
will bid 10,001 right away, so just bid 0 to break even and let them lose 9,901.DeterredBot
doesn't know me and will therefore bid 0, so just bid 5 to win.LuckyDiceBot
keeps on bidding till it wins. So if we started, bid 5 in the hope they bid as high as possible to win the dollar. If they've started just bid 0 to let them have the win and break even yourself.RandBot
will bid random in the range[5,100]
, so just bid 5 more until it stops, in which case you've won 95 cents and they've lost0-100
.UpTo200
will (as the name states) bid up to 200. So just bid 5 higher until they stop. We'll win the 1 USD bill and take a total loss of 105 cents, they however lose 200 cents.InsiderTradingBot
doesn't know me, so just bid 5 cents to winMimicBot
was the hardest. Just bid 10 to either start with or counter their first bid of 5. If they try to access me I will throw a RuntimeException (which they will catch in which case it would act as if I had bid 100 instead - although it will break the inner while-loop). Based on the enemies it has in it's HashSet a different thing happens. I'll have to revisit and look more closely to see if there is an actual counter.RiskRewardBot
doesn't know me so will just bid 5, in which case I will bid 5 to win.MarginalerBot
will bit up to 100 depending on what I would bid. If I may start, I will bid 90, then it will bid 95, then I will bid 100 so it will bid 0 and lose 95 cents, while I win the 1 USD bill and break even. If it may start instead, it sees I would bid 90 against it, so it bids 90 itself, then I will bid 95 so it will bid 0 and lose 90 cents, while I win the 1 USD bill with a 5 cent profit.BuzzardBot
will analyze all my counters in the range[0,100)
. If I bid100
right away it useoppFlag = 0
and the complete 100-sized array will contain 100x the value 100. In the switchcase 0
, the loop will be in the range[0,100)
again, and sincei + 5
will at most be 104, the ifbids[i] < i + 5
won't ever be true, so the bid it does remains 0.ImprovedAnalystBot
will always havethis.enemy = null
because his opponent isCounterBot
, not itself. So it will always bid 0, which I just counter with a bid of 5.InflationBot
will bid 0 to break even when it starts, otherwise it will keep bidding 5. So just bid 0 ourselves to break even right away and let them have the win.ScoreOverflowBot
will either bid nearInteger.MAX_VALUE
if they may start, otherwise they'll bid105
. So if they've bid 105 just bid 110 ourselves (they'll lose 105, we'll lose 10), otherwise just bid 0 to let them have the win.MBot
is the same asMarginalerBot
, but with added protection against 'peeking' opponents. Since I don't 'peek', it's basically the same asMarginalerBot
.SecretBot
will have hisisPeeking()
method return false, so if it may start or if I bid 5, it will bid 5 or 10 respectively. Otherwise it will bid 0. So whether I start or not,opponentsBid + 5
would cause me to win either way, either with my 10 cents or 15 cents bid, causing them to loose either 5 or 10 cents.BluffBot
will look at what I would bid when his bid is 95, and if this is larger than or equal to 100 it will bid 0 to break even, otherwise it will bidopponentsBid + 5
. So I'll just bidopponentsBid + 5
. It'll break even regardless of who starts, and I win either 100 or 95 cents depending on whether I have started or not.StackTraceObfuscaterBot
will act the same asMarginalerBot
.EvilBot
will always bid 5, so just bidopponentsBid + 5
. Either way they'll loose those 5 cents, and we'll win the 1 USD bid (either with a 5 cents bid if we've start, or 10 cents bid if they've started).MSlowBot
is the same asMBot
and therefore alsoMarginalerBot
.Let me know if you see any typos or flaws in my counters.
sumber
MirrorBot
calls newAuction with your own class, so that's a problem. Also, glad to know the 3 hours I spent on MimicBot weren't in vain.newAuction
because it would fail more often than not.. I can't counterMirrorBot
nor can it counter me. Whoever begins of the two wins 95 cents and the other loses 5 cents.BorkBorkBot
, shouldn't you raise to 95 when they hit 85? Otherwise you're both bidding 95 if they start.RiskRewardBot
Can't test this at the moment, so please let me know if it's broken.
The goal is to get the highest total score, so don't worry about beating anyone. Just take the easy wins, and don't waste money on possible losses.
sumber
BluffBot
A spy you know of is more valuable than no spy at all...
If someone else tries to call the getBid method, BluffBot responds with $100 to trick them into either quitting or betting really high.
Otherwise, see if it's possible to win for under $1, and just don't bid if it's not.
sumber
UpTo200
sumber
SecretBot
This bot makes minimal attempts to win by bidding 5 or 10. He also checks the stack trace to see if he was called by another Bot and then lies to them about what bids he'll make.
sumber
isPeeking
intoAbstractAnalystCounterBot
?One Extra
Bids 6 more than the last bid, just because he can.
sumber
StackTraceObfuscaterBot
This bot laughs at attempts to detect reflection via the stack trace. The closest thing they see to a
DollarBidder
is some lambda class it created. Clearly not another bot trying to reflect them. Little do they know that that lambda class is actually working for aDollarBidder
. Beyond that, he acts likeMarginalerBot
.sumber
Darth Vader
This one tries to force the opponent's bot to overpay by setting the integer cache to the value over the $100 limit.
sumber
return opponentsBid <= 195 ? opponentsBid + 5 : 0
and make itreturn opponentsBid <= 100001 ? opponentsBid + 100001 : 100001
.ImprovedAnalystBot
(non-competing)A lot of people seem to be using the
AnalystBot
code as a template, even though it's deliberately bad code. So I'm making a better template.sumber
AnalystBot
is deliberately bad code so that it can demonstrate theAnalystKiller
sabotaging it.MBot
Slightly refined MarginalerBot
sumber
nextBid
to throwClassCastException
.Non-competing: MSlowBot
Same logic as MBot, just use timeout instead of Exception when fighting against enemy. So far no one is defending agains timeout so should be effective
sumber