Last active
August 29, 2016 23:43
-
-
Save CrazyPython/1034447ea0d564e324329db669782939 to your computer and use it in GitHub Desktop.
bot?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ppcg.stockexchange; | |
import com.ppcg.kothcomm.game.AbstractPlayer; | |
import com.ppcg.kothcomm.utils.Tools; | |
import java.util.List; | |
public class VincentKasuga extends Player { | |
int knownStock; | |
int knownPrice; | |
int corneredStockType; | |
int corneredLikelehood = 0; | |
boolean marketCornered; | |
public Offer acceptOffer(List<Offer> offers) { | |
if (!marketCornered) { | |
Offer maxOffer; | |
int maxAmount; | |
if (corneredStockType == null) { | |
for (offer: | |
offers) { | |
if (offer.getOffer().getAmount() > maxAmount) { | |
maxAmount = offer.getOffer().getAmount(); | |
maxOffer = offer; | |
} | |
} | |
} else { | |
for (offer: | |
offers) { | |
if (offer.getOffer().getAmount() > maxAmount && offer.getOffer().getType() == corneredStockType) { | |
maxAmount = offer.getOffer().getAmount(); | |
maxOffer = offer; | |
} | |
} | |
} | |
if (maxOffer == null) { | |
// may have cornered the market | |
corneredLikelehood++; | |
if (corneredLikelehood == 5) { | |
// probably cornered the market | |
marketCornered = true; | |
} | |
} | |
return maxOffer; | |
} else { | |
// who needs offers when the market is cornered!? | |
} | |
} | |
public Offer makeOffer(List<Stock> currentStock) { | |
if (marketCornered) { | |
// if we could know when it ended... | |
// avoid leaking stock | |
return Offer(Stock(corneredStockType, 1), 1000); | |
} | |
} | |
void secretValue(int stockType, int value) { | |
knownStock = stockType; | |
knownPrice = value; | |
if (stockType == corneredStockType) { | |
if (knownPrice == 1000) { | |
corneredLikelehood += 3; | |
} else if (knownPrice < 900){ | |
// didn't corner the market. | |
corneredLikelehood = 0; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment