Cards-With-Aladdin

Cards Against Aladdin is a competitive stock portfolio building game.

How to play:

There is a player and a bot. Both are given a shuffled deck of the same publically traded stocks and funds. Each draw four cards at the begining of the game, and start with $100,000 to invest.

When the game starts, it rolls a random quarter to compete in, from 2005 Q1 to 2015 Q4. The game is played in rounds, and the goal is to maximize total yield for that quarter.

In each round, the player and the bot may "buy" up to one of the cards in thier hand at the listed stock price for as many shares as they can afford. If they buy a card, they may draw a new one from their decks. If they do not buy a card, they may not draw a new card.

At the end of each round, both the player and bot can see the cards their opponent has bought, although not the amount of shares for a given card.

After 4 rounds, a wild card is pulled from a shared deck, of which both parties are obligated to buy as many shares of as possible with their remaining cash. If they didn't buy a single card all four rounds, all $100,000 is used to buy as many shares of the wild card as the stock price would allow.

Any left over pocket change is deposited into a savings account and given a 1% yield. At the end of the game, the total yield is added up from their portfolios based on the returns gathered from BlackRock's Aladdin API, and the player (or bot) with the largest total cash yield wins!

Inside our bot ("Aladdin"):

Aladdin, affectionately named after the BlackRock API, has access to actual performance results for all quarters going back quite a ways.

At the beging of the game, the bot draws four cards. It then selects the card with the best return in that quarter. If no non negative return exists, then it picks the lowest negative, and buys one share.

It repeats this for every time it draws a new card, except for the last card, at which point it must pick between choosing best card or leaving it up to chance with the wildcard.

It attempts to leave less than 20% for the wildcard when possible, usually lower if the cards it were delt were good. Good cards are giving various amounts of shares depending on the percentage of growth they had that quarter.

Challenges I ran into:

Finding price points throught the BlackRock API for given periods is non intutitve.

What's next for Cards Against Aladdin

  • Turn Timers, long enough to think, not long enough to google
  • Player vs Player, and expanded amount of people/bot games
  • Actual Netcode
  • Caching stock info on a server so to not spam Aladdin with API calls
  • Expanded decks with multiple industries, harder (not as well known stocks), alternative assets (such gold and cryptoassets)

Built With

Share this project:
×

Updates