Showing posts with label texas hold em game. Show all posts
Showing posts with label texas hold em game. Show all posts

Thursday, 15 December 2011

Java: Texas Hold Em (22)

Hi, people! Going to just make this as brief as I can today, don`t feel up to much. The Player class has 177 lines when I got rid of all the (rightfully present) comments, so you can keep track of how far we have to go before the end.

Let`s get right into some methods now, with a few get...() methods and reset...() methods (among others) as you might expect would be needed in a round-based game:

Wednesday, 14 December 2011

Java: Texas Hold Em (21)

Alrighty, I looked over the ConsoleClient class, and uh, I was lost, so let's do the Player class instead! It's a little long, about 300 lines before I do anything to it, like make it ugly and remove vast amounts of comments, but we'll get through it.

After that, we can just do the Table class, leaving ConsoleClient to the end of the functional code, at which point we have bots and GUIs to do. See, this is why people rarely code from scratch, and just modify other peoples' code, it takes way too long otherwise. But I suppose in the heart of learning...

Tuesday, 13 December 2011

Java: Texas Hold Em (20)

Hey now, the Client isn't empty, only everything that it does is! Wait, does that make it sadder? Who cares, it probably deserves it. That's right folks, it's time to get the Client done, and therefore officially the start of the "What the fuck am I doing, and why?" part of the project! At least we're not at the "What am I doing, and how am I supposed to work out how?" part?

Here we go!

Monday, 12 December 2011

Java: Texas Hold Em (19)

Hey hey, post as promised, late as promised! I'm so awesome! Today we're continuing with our HandValue class, and we'll be done with it tonight! I do hope after all this time wasted this project doesn't end up being a flop :P

After this, we could move on to the Table, but that is what Players sit at, so we should do those. However, it looks like the Player class needs a Client interface to work with. Being an interface, and not a class, if you remember, this means that Client will be a collection of related methods, but empty.

We`re starting to get into territory that I don`t quite get, so...good luck? We'll see how this pans out!

Sunday, 11 December 2011

Java: Texas Hold Em (18) - Weekend Post

Whoops, lost track of time, but here's the second weekend post! We'll keep this one short too, and tomorrow we'll move back to the standard posts. One more week with weekend posts, then back to the 5/week schedule.

Working from the pseudo-blueprint we constructed yesterday, let`s get through the instance variables and the constructor for the HandValue class:

Saturday, 10 December 2011

Java: Texas Hold Em (17) - Weekend Post

Heh, almost forgot about saying I'd do this for 2 weekends :P Since it's the weekend and everyone probably just wants to chill, I'll keep it short and sweet.

We're starting with the HandValue class, and what this does, basically, actually gives some representation to the value got by the evaluator, complete with a toString() method and a way to compare hands! As a general blueprint, we need:

Friday, 9 December 2011

Java: Texas Hold Em (16) - HandEvaluator Finished.

Okay, so, today we finish this class up, finally. That's the good news. The bad news is, there's still a HandValue class to get through, which will put together the HandValueType and the HandEvaluator, so we're not totally out of the woods.

The HandValue class should be finished in 2-3 days though, so it's not so bad. Enough talk of the future, let's get done with the now!

Thursday, 8 December 2011

Java: Texas Hold Em (15)

Busy, busy! Just gonna throw my post out there today, and be done with it :P Today we get through Four of a Kind and Straight Flush, tomorrow, we finish this class (bloody finally) with the Royal Flush and the Constructor that actually uses everything we've made!

Fwoomp (That's the sound of code falling into place):

Wednesday, 7 December 2011

Java: Texas Hold Em (14)

There appears to be some trouble with understanding the coding that's been going on. That's fine, I'm not exactly 100% on everything, either. The thing to remember is you need to know exactly what you're trying to do with some code, and then work out all the steps required for getting there, bit by bit. Computers are dumb, you can't just say "Throw me the ball". You need to take it in small steps. "This is the ball. Picking something up involves... Now pick up the ball. Swing your arm in x direction and release the ball..."


Luckily, a lot of the time, coding involves modifying someone else's code instead of creating stuff from scratch, so you have the option of looking at what steps are being taken, then thinking of how you can do whatever you want from that point onward. Here's today's code:

Tuesday, 6 December 2011

Java: Texas Hold Em (13)

Ahoy there. Today we're going to continue on the same train of thought as yesterday, this time making a boolean method for the next 2 hand value types: Three of a Kind and Straight. Let's dive right into it, since there's no administrative stuff to go through:

Monday, 5 December 2011

Java: Texas Hold Em (12)

Okay, back on track! To make up for the previous week, I'll be doing Sat-Sun updates for the next 2 weeks! We should be done with the evaluator comfortably this week, allowing us to move on, and we'll soon be out of the comfort zone of someone else's code, which I'm kinda worried about, but oh well.

We left off last week at calculating any duplicates, as well as the high card of a hand, so the progression from this point would be to have a bunch of private methods for use in the constructor that actually as "Does this hand contain x?" for each of the possible hand value types. Here we go:

Monday, 28 November 2011

Java: Texas Hold Em (11)

Ugh, late post, sorry! I spent the better part of 2 days asleep, and I don't even know why, so doing this wasn't exactly a priority! Still, today we get to continue with our Hand Evaluator! Let's see, we had just finished finding straights and flushes, so let's continue that thread of thought and grab a method to find duplicates (encompassing single/double pairs, triples and four-of-a-kinds, thanks Mr. Stigter, for more efficiency!), and then something to calculate the high card in the hand to further calculate the hand's value.

Here's what I got (Yes, I did basically just use Stigter's code, but understanding it took time!):

Friday, 25 November 2011

Java: Texas Hold Em (10)

Hi hi, this is the last post for the week, because I'm lazy and went down to only 5 posts a week, remember. Going to be continuing with our HandEvaluator, which is fairly big, as far as what we've seen goes, and it'll be made longer by me messing around and looking for better ways to do what Stigter did! At least, for my own uses.

Now, we want our evaluator to work straight off, on being created, without calling any special methods on the object, which means our constructor is actually going to need to make use of methods we declare in the class. For this reason, it's probably best that we don't work on the constructor until we finish our methods! Here's what I got so far:

Thursday, 24 November 2011

Java: Texas Hold Em (9)

Happy Thanksgiving to all the Yanks in the audience. Today we're moving onto the evaluation part of the program. This one's a little big, so it'll be more than 1 post dedicated to it! To keep things concise (or at the very least, available in small chunks), I'll keep posts to 2 screenshots worth of code per day, as I've been more or less doing for a while, anyway.

Fixing things in previous posts won't count, unless its a ridiculous amount! Speaking of which...

Wednesday, 23 November 2011

Java: Texas Hold Em (8)

To comments: Yeah, going to work on base functionality before everything else, then add in the visual and actual user interactivity. Also, thanks for info on the blinds!

So today I wanted to start on the HandEvaluation, since it is a rather big class. Complex, kind of, but mostly just big (As far as I know, which revolved entirely around guesswork), but the enumeration to hold the types of hand values is probably better off in its own class. It's similar to the Action we had yesterday, take a look:

Tuesday, 22 November 2011

Java: Texas Hold Em (7)

In response to a question from yesterday's post: I don't think the evaluation will be the toughest part, since the player clients all need to come together, or the GUI itself, using actual graphics might be a pain in the ass. We'll see, though.

For today: Action class! I'm gonna follow the example program for this one, since it looks simple, and much easier than what I was planning to do with it, but since the example program isn't fully functional (because I'm stupid and take inspiration from all the wrong places), it may need some tweaking later on.

Monday, 21 November 2011

Java: Texas Hold Em (6)

Short one today, I wanted to make a Player class, but realized I'd probably need a Client class to handle the, well, client for the player(s), so I'm putting that off.

I could work on the Client, but who wants to think on a Monday? I could work on the Table that the players "sit" at, but that requires players, and I'll be damned if I'm working on the GUI before a huge chunk (all?) of the functionality is complete. This leaves very few things for me to look at. From what I can think of, something to handle the evaluation of the hands, to determine who wins, and the actual Actions a player can take.


It seems like the Action class will be the shortest, since it'll just be an enumeration with a couple of parameters, so I'll get on that tomorrow. Honestly, thinking of what required what and how I'd go about it (though I have a feeling I'm wrong about a lot) took longer than it appears given the paragraph and a half above :P Quite enough time out of my busy schedule for today!

See you tomorrow!

Thursday, 17 November 2011

Java: Texas Hold Em (5)

Uh, so it's now Friday. I have no idea what happened. I apparently passed out or something, and had been down and out for a full day. I am a bastion of physical health, I know. So after a while at the doctor it looks like the verdict is "Man up, bitch", so to celebrate, I'm going to write more code. And also mention here that I'll be dropping my posts to 5/week instead of 6!

So we were on the Hand class, and here`s how the rest of that goes:

Monday, 14 November 2011

Java: Texas Hold Em (4)

Today (Almost tomorrow >_>) is gonna be short, mostly because its so late! We're gonna start off with the Hand class! Over the next day or two we'll finish it up, and then we can move on to something else! Hand Value, or Player or Table, I dunno, we'll see. Let's get this show on the road:

Saturday, 12 November 2011

Java: Texas Hold Em (3)

Hi, today, we're going to (I think) finish off the Deck class, for happy fun times. Might need to change the toString() of Card since it looks kinda ugly, BUT it does work, as does the shuffling., so yeah. It's okay, though, I suppose, since the end result will hopefully be graphically represented.

Here's the Deck beyond the constructor: