Just another WordPress.com site

Playing Programmers

Hello Interwebs!

Statistics project is 1 meeting away from me having to write a paper, but an update is not worth it, since its just obnoxious technical stuff and bad things that happen when there are 30 instances of something happening in a 15k+ individual dataset, BUT I did get a few things done.

My old undergrad roommate and I got together on Saturday to play programmers. He majored in computer science in undergrad, so lets just say he did a lot of the programming and I was more of a “big picture” guy, but it was a good, productive time anyway.

Our goal is to program the game Bang! (http://en.wikipedia.org/wiki/Bang!) in c#. Its a really fun game, but has some balance issues and I think bootstrapping (http://en.wikipedia.org/wiki/Bootstrapping_(statistics)) is a way to balance it and get a better idea of what is going on. For now, just imagine playing hundreds of thousands of games of Bang! and recording their results to get a distribution (breakdown) of win rates, what cards were used, etc. We are a ways from the actually bootstrapping, so I won’t focus on it here, but you get the idea.

On Saturday we set out to make the deck of cards for the original game:  http://www.emilianosciarra.net/ENG/playing_cards.html

 

It took a fair bit of time. We ended up having 1 typo that led to a null reference in the array we were using that took a long time to catch, but we fixed it and currently have the main deck of cards coded.

One thing we came across that I have run into before and always find interesting was some trouble with referencing an object. It tripped up Adam a bit, so maybe its not just my general lack of experience with programming, but I always find it super frustrating.

Consider what we were doing: defining 82 cards and referencing them. We started by creating card1 = card info, card 2 = card info, etc up to card 82. Now if you wanted to systematically reference these cards with a loop, the approach that comes to my mind is just loop through all cards something along the lines of card*, where * is the number you want. You can do this with strings, where you combine outside variables with text and such, but you can’t (rather we couldn’t figure out how to) get it to reference objects in this way. So you could create a variable that was card1, but the way it was combined created a string and now a reference to the card1 object we created earlier. It was not a super hard to fix, we just had to use an array (http://msdn.microsoft.com/en-us/library/aa288453(v=vs.71).aspx), but it is definitely the thing that frustrates me most about programming. I am pretty good at thinking like a computer (in loops, if statements and such), but sometimes how I think about it does not translate to the reasonable approach I was taking.

After reading around a bit, I have a better idea of what it is hard to deal with the approach we were using and why they have the work around options they have. I think things problems like this are really how you learn how to program in a specific language, it seems reasonable, but is not, so go find a functioning way.

Next weekend we are making a shuffler and adding in the character cards and role cards. I might post a bit more on the information we are keeping track of with the cards as well, but I left my notes on it at Adams and doing it from memory seems silly.

Leave a comment