The Tequila Den

Combines the world of Tequila with Games.

Tag Archives: brainwaves

Longest Road (EVER)

I think I actually got it. What a bitch.

It was a nightmare. I knew it wasn’t going to be easy, but when I first started planning for it, I was honestly stumped. I pieced together the eventual formula, but it took a lot of brain juice.

I’ll break it down. First off, I copy an array of all the roads the player has. Then from that array, I separate all the roads into single segments. What that means is that it is a list of roads that only have a single path. Of course these road segments could be longer when the roads have multiple branches and directions, but this is the simplest form. The roads are all accounted for in this instance. After this, I cycle back through all the segments matching them with other segments and creating new segments. This creates a list of all possible road paths (through all possible branches). This creates a longest road. Although, there’s a catch. Road length can be intercepted by opposing settlements, thus, there’s another check these completed segments must go through. I kept tabs on the ends of the roads throughout the process, so all I did now was cycle through the completed segments catching to see if an ‘enemy’ settlement was blocking, keeping track of the length. At the end, the longest length recorded and returned. Ta-da.

Clear sailing ahead!

Oh fuck, I forgot about ports again. Son of a …

One Line…

Its amazing how much purpose one line of code can affect your game. I accidentally forgot to add one small line of code in the game and the game hung up. I couldn’t for the life of me figure out what was causing it. I put a bunch of escapes and tried for the life of me to narrow out the bug. Turns out I forgot to escape a switch that handled all my server data so all it did was loop thinking there was a continuous stream of data to be handled. Damn it.

The worst part of it all was after I write a fresh piece of code I test it out and see how it plays out. If there’s an error, its normally because of a minor spelling mistake or something that I just plain forgot. In this case it was something rather pivotal. Oops.

Bouncing like a Whore…

I flew out of the gate working with Canasta to begin with, but as the finish line showed its beautiful head, I decided to take a quick break to freshen up the noodle a bit. I started up production on MouseTrap. I made up a HUD and some basic controls. After I hit a little bit of a mental block, I re-opened up Catan. I miss playing that game. Damn it. I gotta call the boys up for a sit down game. Or… I guess I could finish this?

I need to re-focus and finish something!

Eye Candy…

I think I got rid of a little bug. I got ideas of how to completely eradicate it but I would rather not build a bunch of states for each possible move the AI can make, instead I prefer my hierarchy tree instead. I just want to have the computer make the best possible move as opposed to a if it works, it works kind of thing. I’ll see though. I may end up revisiting this in the future to make a more dynamic, more random and unpredictable  opponent. But for now, I want that bastard perfect.

screenshot 2013.04.09

Just a little screenshot showing some gameplay. Basically everything currently works. The only real to do is smoothing out some of the animations for the opposing team. As of now, they still use the “right side up” card to blend through the animations, instead I want to switch to the cards that are shifted 90 degrees. The reason being is that when (if) you see the animations they look goofy and out of place (but work!). But before then, I plan on working on the getting the computer to go into their second hand (called the Foot) and eventually go out and end the hand. Lastly after that big task is the continuation of the game, re-shuffling, point scoring and starting all of it over). Although, all that functionality is already done, it just needs to be initialized. I’m getting excited. This project is nearly the completion!

 

Adapting…

I worked on Canasta a bit more last night. I was skimming through the old code and had to decipher how I handled key presses and mouse spaces. The old way is terrible. I refined it and made it more dynamic. Now it’ll be way easier to add more functionality to it.

Next plan is to finish a primitive version of mouse-spaces and tackle card animations. Definitely not looking forward to that. I have an idea for computer ai in that regard, but not for the player.

Developing…

I’ve made a little bit of head-way the last week or so, I’ve managed to tie in all of the development cards uses. Everything there works now, soldiers, victory points, monopolies, road building and year of plenty’s. Next on the list is tying them into the client’s version of the game which will be rather painless.

The next step will be wrapping up the trading menu, which I’ve been leaving until now, I’ve just haven’t had the heart/time/motivation to really tackle it at this point. It’s a lot of moving little menus around plugging a lot of redundant code to handle all the possible buttons. I’m sure I can smooth it all out by the weekend.

Once that’s all cleaned up and working properly, I can move along to a few other things, I think I’ll slide into the idea of claiming victory (which shouldn’t be difficult at all), adding in the dreadful (it’s going to hurt my head, I know it already) longest road card, as well as the largest army (which is simple). Once I have those finito, the game will be relatively complete, sans ports and the second robber, which I plan on leaving until last anyway.

Peace out homies.

Slaving in the Hive…

I’ve been a little busy bee as of late. I’ve done a lot of work lately on Catan and I’m really starting to see the fruits of my labor. But then, I decided to write a little more detailed ‘to-do’ list and then I started to see all the things I’ve yet to do.

Instead though, I’m going to plow through what you can now do with the Server/Client interaction. As expressed before you can place roads, settlements and cities provided you have the resources, but now I re-fined that and now you have to actually have the pieces to place them. I also double checked to make sure you were able to make a legal move with that piece, so you won’t be stuck in hiatus trying to place something you have nowhere to place. I plan on adding an escape key/button to allow you change your mind.

With cities and settlements come victory points. Now you’re able to see how many points your opponents have and updated as soon as it happens, “([points]) Player_Name” fashion. I’ve also started working on using the development cards, currently you can play a soldier card to invoke the robber and steal resources from your opponents, if there is more than one opponent connected to that resource, you can choose who you rob. This also applies to playing the robber when a “7” is rolled. I’ve also put the cap in when you have an excess of 7 cards in your hand you must discard half of your hand, this is finished. It will also wait to make sure all players have discarded their cards before you’re able to place the robber.

You can now play victory points as well. I’ve sectioned off a part to show your table cards, this will display any soldiers or victory points you’ve played, as soon will show if you have the longest road and/or the largest army.

The neatest thing I’ve added in is a debug console for the server, so I can check variables, run functions and keep an internal log of what’s going on, rather than clogging a print function.

The plan is to make little versions of the soldiers/victory point cards for the other players’ display, Then I’m going to work on trading and fiddle with that as that will be a bit of an undertaking. I’m also going to work at the other player’s display a bit, I want to add in all players and have a way of seeing who’s turn it is a bit easier. I have a ton of notifications to do yet, but I’m slowly kicking stuff off the to-do list.

I fixed a bunch of minor bugs as well, mainly a few minor oversights that would of been caught eventually, but sooner the better. Good news though, I’m fairly certain I squashed the server re-rolling bug that I’ve been having. Should be finally OK now.

No new images, I was too lazy to take one, maybe next time.

Late Night Heroics…

Over the past couple of days I’ve worked on networking in Sphere. Needless to say, it’s been a big pain in the ass. I’m getting a bit better at it, but it’s definitely been a headache to say the least. I just really dislike how Sphere’s sockets are set up. It just seems to be repetitive to CreateByteArray’s then read back from them. I should just be able to send the information I want, and retrieve the information I want. Anyways…

I have got to the point where I run the server, it’ll wait til a client has made a connection, then it will transfer the board data from the server to the client. It’s kind of nifty at the moment. Unfortunately however, it doesn’t keep track of who is who, how many people are connected and well, anything really completely necessary. But hey, its a start. I’m exhausted and going to bed.