// The "Maker & Taker" Game // (in which maker and taker gamble for the ball) sclass MakerAndTakerGame { /////////////////////////////// //////// PLAYING FIELD //////// /////////////////////////////// //////// Maker's output Bool priceIsUp; // null: It's round 1 and it's the takers turn. (Initial situation before game begins.) // true: Price has gone 1 step up since last round // false: Price has gone 1 step down //////// Taker's output & score, plus time keeper (=rounds played) int takersCurrentBet; // +1 to bet long, -1 to bet short, +2 to bet extra long etc, 0 to stop betting for now int takersScore; // Sum of taker's wins + losses int roundsPlayed; // How many rounds (a round is one take and one make) we had //////// Internal toggle for fun purposes bool takersTurn = true; // Taker always starts //////// Game protocol new L protocol; //////////////////////////// //////// MAKER CODE //////// //////////////////////////// // This defines the crypto's movement over time. // true = one step up, false = one step down. // Multiple steps at once ("cell skips") are anomalies and are not supported here. swappable bool nextCryptoMove() { fail("Put something here"); } void make { priceIsUp = nextCryptoMove(); takersScore += takersCurrentBet*(priceIsUp ? 1 : -1); ++roundsPlayed; protocol.add((selfType) unstructure(print(structure(this)))); takersTurn = true; } //////////////////////////// //////// TAKER CODE //////// //////////////////////////// // Taker's secret sauceeee! // // IOW, do strategy XYZ super-smart mega calculation stuff and set "takersCurrentBet" to a really smart value. // // You can, but don't have to, make use of the value of priceIsUp. // // If you're only watching or done betting, just say takersCurrentBet = 0. swappable void magicJuice {} void take { magicJuice(); takersTurn = false; } // The rest is just some glue for gluing purposes. void step { if (takersTurn) take(); else make(); } }