Recent Stuph
by Brett Fattori · 02/17/2007 (7:04 pm) · 6 comments
Hey all, I know, long time no talk. Well, I'm getting back into things and it's going slowly. I've been spending time, lately, doing little odds and ends to keep myself busy. I've found that the best way to get back into game dev, is to just do it. Last week, I spent about 5 days writing Asteroids in Javascript using the canvas element and some code that was developed at my work. We don't do games dev at work (unfortunately) but we do do a lot of work with Javascript. We're an e-commerce development house that has done work for clients like Godiva Chocolatiers, Kmart, The Home Depot, Eddie Bauer, and more. My work with Javascript has given me a whole new appreciation (and at times, hatred) of the language.
Ok, back to games dev... I wrote Asteroids in JS in about 5 days. It uses the canvas element as it's rendering context and looks pretty accurate. I had to write some code to do vector letters and numbers, and it took some time to understand what exactly could be done. In the end, I received a lot of feedback (positive and encouraging, mainly because people at work see me as some sort of Javascript oddity) and it'll be something I post somewhere in the future. It will also probably show up as an easter-egg in one of our "products". I'm in product development, so I don't worry as much about client issues and such -- throwing in an easter-egg is just my way of saying "Hi!"
I dropped by IRC a few days ago and have started chatting again with Tom Bampton. He's a great chap, and I've forgotten how much I enjoy talking to him. Paul Dana is there too, and some people whom I don't recognize, but then again -- it's a chat room where devs can just shoot the breeze. It's been fun catching up and seeing what's developed in my two year hiatus.
I also, recently, built a simple poker game with TGB Pro. Man how it's changed since I used it to build CashCow for a GID. It's easy to use and hard in other ways. Getting to know it has been a love/hate relationship. I still have a long way to go with the game, but it might end up being another TGB title at some point.
It was interesting because the overall game setup was like 5 hours to make cards, 1 hour to set up an interface, and 4 days (and still going) to determine what hand I have. The game is simply about chosing the best cards to keep in your hand, and discarding the rest. I got the idea from a touch-screen bar game a friend and I like to play. You're dealt 5 cards and it tells you what you have. You then decide which cards to keep and which to pass on, and then deal up some new cards. If you chose wisely, you'll get a nicer hand and get a good score for that hand. The kicker is that there are 4 jokers in the deck, which can be any card. So, your chances of getting a better hand are always there -- in addition to 5 of a kind which isn't usually possible.
I thought the logic for it would be simple. I refactored many times because I was so very wrong. Little things that make so much sense to you and I regarding what is a flush and a straight are so much more complicated when in code. I tried calculating based on card values, using bitfields to represent cards in my hand, and more odd ways of doing things. Eventually, it just ended up being a quick sort of the cards and then a gaggle of conditional logic. It works nicely, but it still has an issue with flushes versus other hands. The flush, which seems so simple to calculate, becomes a problem because of how it ranks amongst other hands. Since a full house beats a flush, it ends up making some of the logic a little more difficult.
Anyways, the goal of all of this is to make a solid card game "engine" that I can re-use. The final product will be a game which plays all types of poker, and hopefully some new ideas too. My ultimate goal would be to put this on a touchscreen system (of my own building) and put in at my bar in my basement for parties and such.
Well, I just wanted to drop by and say hi to some old friends. Hopefully I can get reaquainted with some of you, and make some new friends. Until next time...
- Brett
Ok, back to games dev... I wrote Asteroids in JS in about 5 days. It uses the canvas element as it's rendering context and looks pretty accurate. I had to write some code to do vector letters and numbers, and it took some time to understand what exactly could be done. In the end, I received a lot of feedback (positive and encouraging, mainly because people at work see me as some sort of Javascript oddity) and it'll be something I post somewhere in the future. It will also probably show up as an easter-egg in one of our "products". I'm in product development, so I don't worry as much about client issues and such -- throwing in an easter-egg is just my way of saying "Hi!"
I dropped by IRC a few days ago and have started chatting again with Tom Bampton. He's a great chap, and I've forgotten how much I enjoy talking to him. Paul Dana is there too, and some people whom I don't recognize, but then again -- it's a chat room where devs can just shoot the breeze. It's been fun catching up and seeing what's developed in my two year hiatus.
I also, recently, built a simple poker game with TGB Pro. Man how it's changed since I used it to build CashCow for a GID. It's easy to use and hard in other ways. Getting to know it has been a love/hate relationship. I still have a long way to go with the game, but it might end up being another TGB title at some point.
It was interesting because the overall game setup was like 5 hours to make cards, 1 hour to set up an interface, and 4 days (and still going) to determine what hand I have. The game is simply about chosing the best cards to keep in your hand, and discarding the rest. I got the idea from a touch-screen bar game a friend and I like to play. You're dealt 5 cards and it tells you what you have. You then decide which cards to keep and which to pass on, and then deal up some new cards. If you chose wisely, you'll get a nicer hand and get a good score for that hand. The kicker is that there are 4 jokers in the deck, which can be any card. So, your chances of getting a better hand are always there -- in addition to 5 of a kind which isn't usually possible.
I thought the logic for it would be simple. I refactored many times because I was so very wrong. Little things that make so much sense to you and I regarding what is a flush and a straight are so much more complicated when in code. I tried calculating based on card values, using bitfields to represent cards in my hand, and more odd ways of doing things. Eventually, it just ended up being a quick sort of the cards and then a gaggle of conditional logic. It works nicely, but it still has an issue with flushes versus other hands. The flush, which seems so simple to calculate, becomes a problem because of how it ranks amongst other hands. Since a full house beats a flush, it ends up making some of the logic a little more difficult.
Anyways, the goal of all of this is to make a solid card game "engine" that I can re-use. The final product will be a game which plays all types of poker, and hopefully some new ideas too. My ultimate goal would be to put this on a touchscreen system (of my own building) and put in at my bar in my basement for parties and such.
Well, I just wanted to drop by and say hi to some old friends. Hopefully I can get reaquainted with some of you, and make some new friends. Until next time...
- Brett
About the author
#2
Keep up the good work.
02/18/2007 (2:57 am)
Its great to see that you made Asteroids using Javascript & the Canvas element. It amazes me that too few have realized how useful it can be in web development. I've also seen a lot of cases where it has been used in Apple Dashboard widgets, which is quite nifty to say the least.Keep up the good work.
#3
Interesting about the problems with the card hand thing. I hadnt really thought about how you would neatly codify a given hand. It need to codify the hand against different things doesnt it, like colour, value, suite etc.
I might even give it as an assignment to my students.
02/18/2007 (3:44 am)
Hey Brett! welcome back!Interesting about the problems with the card hand thing. I hadnt really thought about how you would neatly codify a given hand. It need to codify the hand against different things doesnt it, like colour, value, suite etc.
I might even give it as an assignment to my students.
#4
@Stefan - dRacer is just waiting at the moment. It's been a long time since I touched the code, but I go back and play it occasionally. Joe and Clark have been so busy with GG that they don't have the time to work on dRacer right now. I don't fault them one bit, I'm glad that GG is doing so well and that they are too. I miss working with them regularly. Who knows, dRacer may come down off the shelf to be finished at some point.
@James - The canvas element is WAY underused. It is so simple to work with. I've actually thought of making a 2D games framework for it as a side project.
@Phil - That would make a great assignment. I swear I searched for a couple of hours for card hand algorithms and they are all just so speculative. No concrete examples, but all of them said something about sorting. It does make determining the hand a lot simpler when all of your aces, twos, kings, etc are together. The fun part was adding in jokers and how they change the dynamic.
02/18/2007 (9:24 am)
@All - Hello to you too!@Stefan - dRacer is just waiting at the moment. It's been a long time since I touched the code, but I go back and play it occasionally. Joe and Clark have been so busy with GG that they don't have the time to work on dRacer right now. I don't fault them one bit, I'm glad that GG is doing so well and that they are too. I miss working with them regularly. Who knows, dRacer may come down off the shelf to be finished at some point.
@James - The canvas element is WAY underused. It is so simple to work with. I've actually thought of making a 2D games framework for it as a side project.
@Phil - That would make a great assignment. I swear I searched for a couple of hours for card hand algorithms and they are all just so speculative. No concrete examples, but all of them said something about sorting. It does make determining the hand a lot simpler when all of your aces, twos, kings, etc are together. The fun part was adding in jokers and how they change the dynamic.
#5
Glad you are back. I will of course have to kick your ass if you disappear for so long again ;)
Edit: Spot the deliberate mistake ...
02/18/2007 (11:09 am)
Many years ago I was dicking about with a card engine. I seem to remember running into similar issues as you. I wasn't that bothered about doing a card game so in the end I just ditched it. I came away from it with the knowledge that card game engines get very game specific very quickly, and pretty much the only thing you can do generically is the handling of the deck etc.Glad you are back. I will of course have to kick your ass if you disappear for so long again ;)
Edit: Spot the deliberate mistake ...
#6
Royal Flush
Straight flush
Four of a kind
Full house
Flush
Straight
Three of a kind
Two pair
Pair (Jacks or Higher)
Any Pair
This suffices for most things, but there exists some very cool ways to encode your hands so that you can compare the encodings directly by value.
There was a nice article in Game Developer in Nov 2005, if you don't have access I can do a little write up about it to explain the basics. Come to think of it I might have some flash code that I wrote to test the ideas somewhere that deals 3 random hands and shows you the hand value and % of winning etc.
02/18/2007 (2:00 pm)
For standard winning hands using brute force just start at the top hand and work your way down.Royal Flush
Straight flush
Four of a kind
Full house
Flush
Straight
Three of a kind
Two pair
Pair (Jacks or Higher)
Any Pair
This suffices for most things, but there exists some very cool ways to encode your hands so that you can compare the encodings directly by value.
There was a nice article in Game Developer in Nov 2005, if you don't have access I can do a little write up about it to explain the basics. Come to think of it I might have some flash code that I wrote to test the ideas somewhere that deals 3 random hands and shows you the hand value and % of winning etc.

Associate Stefan Beffy Moises