CrazyPython
8/29/2016 - 11:37 PM

bot?

bot?

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;
            }
        }
    }
}