Pit Game Engine

I recently wrote a game engine for the card game “Pit” and posted it to my Github.

Pit Deluxe (from Amazon.com page)

The Card Game

Pit is a commodities trading card game. It’s quite fun, and good for groups up to eight. Even though I only recently learned of it, the game has actually been around since 1904, when it was first sold by Parker Brothers. The game play involves trading cards with other players until you complete a set of nine of the same card, at which point you yell out (or ring the bell) and declare that you have cornered the market and won the round. Trading consists of yelling out offers and making deals to exchange cards (blind, and always for the same number of cards) with other players. It can be quite hectic, and is probably something like an actual commodities trading floor.

Wikipedia Page
Rules (I use the bull/bear variant)
Boardgame Geek Page
Buy from Amazon.com

The Game Engine

I wrote a game engine (actually two) for Pit in Python. The idea is for people to write Player classes and have them compete against each other. The game engine manages the cards, rounds, scoring and other aspects of the game.

Disclaimer: I wrote a basic player and have run hundreds of game simulations (and even have unit tests!) but I wouldn’t say it’s thoroughly debugged. If you check out the code and find any issues, let me know. Or submit a patch :-)

Thanks for reading, and definitely send along any feedback. It’s always appreciated.

Synchronous Version

This is the version that a couple of my coworkers (and I) are planning to use to test out different Player algorithms. Here’s a run-down of the game flow…

  1. Cards are dealt, players after dealer get 10 cards (dealer rotates, just as in the live game)
  2. Game loop starts, processing one cycle of the game at a time until someone wins
  3. Game Cycle:
    1. Players are asked for an action (make offer, respond to offer, etc.)
    2. Actions are randomized and then processed one by one
    3. Cards update, notifications sent after each action is performed

Game Actions

During each cycle, active players may submit a single action to perform. Those actions include:

  1. Make an offer – call out a number of cards to trade
  2. Respond to an offer – propose a trade to specific player
  3. Ring the bell – declare you have won this round
  4. Pass – do nothing

Notice that “confirm a trade” is not listed. That happens outside of the normal game flow, and is triggered immediately whenever a player sends an offer response to another player. This does allow players to perform more than one action per round, but is somewhat realistic (people tend to hear their own name called, regardless of other distractions) and makes the game bookkeeping easier.

Action Durations

Game actions are not free. Making an offer, responding, or participating in a trade take a fixed number of cycles. During this time a player will not be queried by the game engine for any new actions, nor will the player be notified of actions made (or trades confirmed) by other players. The one exception to this rule is that players will still be notified of direct responses to any of their prior offers, and they may still confirm them, resulting in another trade (and yet another delay of a few game cycles).

Asynchronous Version

I wrote the async version second, and it was meant to be more realistic, closer to how people actually play the game. The idea was to break away from the concept of fixed cycles and order of operations. The game engine and each player run in their own separate (and multithreaded) Python process and communicate with each other via dedicated pipes and a single action queue. The code is a bit more complicated than the synchronous version, and a group of my basic players needs around 30 seconds to complete a single game (the sync version takes a couple tenths of a second).

In the course of writing & testing the async version, I realized that it’s not necessarily that much more realistic. I still had to alter reality in several ways to make the task easier on myself. For example, all communication routes through the game engine. In the real game, everyone is an independent agent and there is no central control.

Perhaps I’ll write a third version some day. In any case, I may write another post with more details about this version, but the current plan is to focus on the simpler (and faster) synchronous version. We want to run hundreds or thousands of trials to see whose player code is best, and I’m not sure the async version is suitable for that in its current state.

October 13 2014 | Uncategorized | No Comments »

Setting up Chatham Sign Shop on Etsy

171-a25-a109-a

We’ve started to set up an Etsy account for the sign shop. Check it out… Chatham Sign Shop on Etsy.

And here’s the main website… Chatham Sign Shop.

We’ve added six signs so far, but hope to have the full catalog eventually. These are all locally made, carved wooden signs in the cape cod style.

10516-a

Tags: ,

May 04 2013 | Uncategorized | No Comments »

Boston Bus Map Android App

screen shot of BostonBusMap app On Friday I downloaded a new app for my android phone: Boston Bus Map. It’s a free app that uses the MassDOT xml feed to show current bus locations and give estimates for arrivals at a given stop.

I have only just begun using the app, but so far I find it very cool & useful. I brought up the 77 route, which runs near my house, and got a google map with an overlay showing the location and direction of each bus on the route. Tapping on a bus shows a little pop-up window with the bus id, route name/number, exact heading, and number of seconds since the last update.

Like many people in the Boston area, I often have two or three ways to get from point A to point B, and knowing exactly how long it will be until the next bus will be a great help in deciding the best way to go. At some point I’m going to go sit at my nearby bus stop and try to get a feel for how accurate the data really is.

BostonBusMap has a…
web page
twitter account
developer blog

Tags: , , , ,

August 29 2010 | local | No Comments »

Anita’s Birthday Dinner

Had dinner in Brookline to celebrate Anita’s birthday. Great time and great weather.

Anita's Birthday Dinner 2010

July 26 2010 | photos | No Comments »

Cuervo Games Boston

Here are pics from my camera for yesterday’s Cuervo Games in downtown Boston. I joined team Red’s Army in the blog/media category. We didn’t win (didn’t even get to finish the final event because they ran out of time) but had a great time, and made up for it w/ free drinks & apps at the bar afterwards.

Other people were also taking photos, and I’ll try to get a copy of those and upload them as well.

Cuervo Games Boston

Tags: , , ,

July 25 2010 | photos | No Comments »

Cape Cod July 2010

On Friday, Brett and I watched Inception at the IMAX in Natick. It was amazing, and I’m going to see it again soon.

After that, we drove down to the Cape and spent the weekend with Dad & Deb.

Cape Cod July 2010

Tags: , ,

July 19 2010 | photos | No Comments »

Gravatar Created

I just set up a profile on Gravatar, which was easy since it made use of my existing WordPress.com account.

Gravatar is a service that automatically adds a profile photo any time you comment or post on a blog/website/forum that supports it. You create an account, register your e-mail address (or multiple addresses), and upload a photo. After that, your photo will appear whenever you use your e-mail address when commenting/posting. This includes sites (like mine) that require commenters to provide an e-mail address, but do not display it to the public.

Pretty cool!

Tags: , ,

July 14 2010 | fun | 1 Comment »

My First Android App

I recently published my first app for the Android platform. My main goal was to get my feet wet with Android development, and the Assistant Coach app seemed like a fairly simple idea that, as far as I could tell, hadn’t been done before.

The whole process took me about a month, working part-time. I really enjoyed the process; the Android documentation is excellent, and the architecture is designed well. It had been a while since I did any Java development, but I fell back into it pretty easily (esp. thanks to Eclipse). I had a blast and am thinking about what to make next. Let me know if you have any ideas!

Tags: , ,

July 07 2010 | assistant-coach and fun | 1 Comment »

Random Chicago Pics

Some random pics from my recent trip to Chicago…
Deep dish pizza from Giordano’s
Morgan St. with Sears Tower in the background
Tanker truck of liquid chocolate at Blommer Chocolate Factory
View from my friend’s apartment in the Fulton River District

Tags: , , ,

July 07 2010 | photos and travel | No Comments »

Assistant Coach Upcoming/Requested Features

Assistant Coach icon

Here is a list of features that have been requested and that I plan to add in a future version of Assistant Coach. Please feel free to contact me w/ any suggestions at all.

  • Data Import – the ability to edit a (text) file of profile data and import it into the application
  • Configure Kick-off Data – right now every kick-off is assumed to result in the opposing team having a first down on their own 30-yard line. This should be configurable in the next version of the app
  • Opponent EP – the data for expected points currently applies to both your team and your opponent’s team. This should actually be two separate sets of data
  • Opponent Profiles – (building on the item above) the specific opponent affects a team’s performance in punting, field goals, and on fourth down. The current way to deal with this is to edit a profile before each new game. In the future, perhaps I can find a way to save a base profile and then automatically adjust values for a given opponent. The opponent profile would be much simpler to edit than redoing the entire team profile.
  • Less Confusing Results Color Bars – the colored bars in the 4th Down Results screen may be slightly confusing because the range of possible values goes from -7.0 to +7.0 but is represented by bars that all have a “positive” thickness. Perhaps a better way to visually represent an EP value would be to have a center line with the bar extending to the left (negative) or right (positive).

Tags: , , , , ,

July 06 2010 | assistant-coach | 4 Comments »

Next »