Wednesday, 4 January 2012

Java: Texas Hold Em (33) - The Console Client

Hullo again! I meant to make this post in advance to get up here so I could have today off, but then I didn't, so I'm stuck here :(

Today we start on our ConsoleClient, which should be the final piece to our functionality. Maybe, I honestly don't quite get either of the clients, so there will probably be a load of debugging to do. Probably some which I won't be able to do. But that's enough optimism, let's get down to the client!

Okay, so briefly, the console client will essentially...handle stuff. Not the graphic end of it, but what actually goes on, it'll print stuff out and let players know what's going on and stuff, I'll show you some time. Note that in the code, there'll be a DummyBot. I don't want you to worry about this. It's icky, and gets into the AI, which is undeveloped my the actual guy who actually wrote this code (You'll recall I'm a filthy copycat), and the Dummy just calls and folds or whatever.
After playing with this (not the code, the actual outcome), it's clear there's a tonne of debugging that I'll need to do, but hey, the core concepts are there, so there.

This should require very little in the way of explanation. The big blind and starting cash are set as static variables, as well as a buffered reader for the console. That's pretty much there to take in info. Please ignore the starting cash being less than the big blind, I was just messing around and forgot to change it!

The constructor itself does nothing extraordinary either. We see the buffered reader initialized, a table created, then populated and finally started off. Easy.

The rest of the class is populated with (mostly) small methods to deal with things, here we see the messageReceived method which simply prints out a message, as well as the main method. The existence of a main method means we can run this class on its own now, and it'll create an instance of itself, which will run the constructor, which will initialize the reader and do table stuff!

Exciting? Exciting. Probably. Remember, since this class extends the Client interface that we went over before, it'll have all the same methods, so feel free to go back and look at them. Tomorrow, we'll cover some more and so on. See you then, and hopefully something will require a bit more explanation!

Questions/comments welcome as always.


  1. Oh whoa, I've been snoozing on the Texas Hold Em posts, I'll have to go back and catch up.

  2. I know what you mean about the future posts. Sometimes failing to do them comes to bite me back in the ass.

  3. This was nice!

  4. Ahah. I kinda wanna see the debugging going on. Things being explained afterwards and stuff.