Jeremy's Blog

Archive for September, 2009

ArrayShift in C#

by Jeremy on Sep.29, 2009, under Journey of Souls

This probably isn’t the most elegant or efficient method of doing this, but I needed a way to perform an “ArrayShift” on an array in C#. There’s no built-in method to do this, so I wrote up and dropped this method in my ToolBox:

/// <summary>
/// A C# implementation of "ArrayShift" this is a generic method that
/// will take an Array of T's, shift one off of the beginning of the
/// array and return it.
/// </summary>
/// <typeparam name="T">The type of array.</typeparam>
/// <param name="array">An array of T's, will be modified to remove
/// the first element.</param>
/// <returns>First element of array.</returns>
public static T ArrayShift<T>(ref T[] array)
{
   T first = array[0];
   IList<T> list = array.ToList();
   list.RemoveAt(0);
   array = list.ToArray();

   return first;
}

It’s a quick and dirty way to accomplish what I needed. If anyone has a better method, I’m open to it.

2 Comments :, , more...

Journey of Souls: Progress Journal #1

by Jeremy on Sep.25, 2009, under Journey of Souls

I’m about to wrap up a reasonably productive evening of coding and I’d like to go over a little of what I accomplished. It wasn’t a whole lot, but there were some very important pieces put in place that will allow us to actually start connecting to something soon.

  1. The DescriptorCollection (namespace JoS.Game.Collections) class mentioned in the previous JoS entry is pretty much completed. It needs a little bit of code commenting to round it out, but for the most part the starting functionality is all there. It holds a Dictionary<String, Descriptor> which is the collection of Descriptors. .addDescriptor adds a Descriptor to the list, .getByEndpoint allows us to look up a Descriptor by its remote socket endpoint, and .delByEndpoint removes a Descriptor from the list.
  2. The beginnings of the actual Descriptor (namespace JoS.Game) class are now there. Needed to make sure DescriptorCollection works, of course. We’re a couple methods away from being able to read from/write to client sockets using this class.
  3. I’ve completed a pretty basic Logger (namespace JoS.Utilities) class to handle any logging that we need to do.
  4. The beginnings of MainGame.Main() (the entry point to the whole app) have been put together. Main game loop coming soon.

Will probably take another hour’s worth of coding to get us a functional “chat” server using our game’s conventions. Then we can move on to dropping in the rest of the content needed to get us rolling. In case I haven’t mentioned this, the goal is to get us back to at least where we were, functionality-wise, with the old PHP JoS by the end of November. We’re well on our way to meeting or beating that goal, if I can keep moving at a reasonable pace.

Comments Off :, , more...

HDTVs Make Excellent Monitors

by Jeremy on Sep.24, 2009, under General Ramblings

… especially for lazy people.

Thanks to Dutch giving me a wireless keyboard and mouse that he wasn’t using, I decided to start using the HDMI out to hook it up to my TV. It worked out pretty well:

I’ve been thoroughly enjoying this setup, so far. It’s even really nice for writing code. I think the most awesome part about the whole thing is that it can do full 1080p. My previous HDMI-enabled machine could only do 720p. Since the video card is pretty beefy (for a laptop), I’ve been playing a few games in this setup. It’s nice. Just as good, if not better, than sitting in the recliner and playing on a normal console.

Now, I need to get a gamepad that’ll work with it wirelessly …

Comments Off :, more...

Journey of Souls: Loose Class Structure

by Jeremy on Sep.24, 2009, under Journey of Souls

The old PHP version of JoS made the JoS_Core class the central point of almost the entire game. It kept references to all of the descriptors, areas, rooms, etc. It was kind of ugly and I don’t think I want one class basically being the owner of every piece of the game. I’d like to split things out more than that.

There are a handful of requirements that we need to meet with our class/object structure/architecture:

  1. We need access to all of the Socket resources from the game loop in order to perform a Socket.Select() on them.
  2. We need to be able to match a Socket resource to its Descriptor object.
  3. We need to be able to quickly query for any available resource by some unique identifier (id number, guid, short unique name, etc).
  4. Unless performance requires it, we should try to avoid the “reference” soup that came with the previous implementation. Every object had a property with a reference for each object that was related to it in any way.
  5. Example: Room objects had properties with direct references to all of the characters in the room, the rooms exits, the area the room was apart of. And the exits had references to the rooms they led to and the rooms they were in. The characters had references to the room that they were in. There were a lot of circular references and it’s hard for most reference counting garbage collectors to properly free resources with these types of references.

  6. Classes with Events and Event Handlers need to be public so that scripted pieces in IronPython will be able to see them properly.

Possible solutions:

#1 and #2: Keep a Dictionary<String, Descriptor> that has all of the Descriptors in it in a DescriptorCollection class which will have the lookup methods mentioned in #3. The String key would be the string representation of the Socket.RemoteEndPoint. Including the remote port. Not including the remote port would make it impossible for us to accept multiple connections from the same IP Address.

#3 and #4: The resources could all be kept in their own Collection classes with the resources mapped out as necessary in Lists or Dictionaries. Multiple Dictionaries using references can be created to facilitate multiple identifiers. We’ll tie the identifiers to the rest of the objects and use the lookup methods on the Collections when we need to get an object reference.

#5: Make sure classes are defined as public. They’re not completely public by default.

This entry is almost entirely copied verbatim from the current revision of an internal collaborative document. There were some minor edits for clarification.

Comments Off :, , , more...

Dropbox Saves Me Again

by Jeremy on Sep.15, 2009, under General Ramblings

I’ve been keeping a lot of my development stuff within Dropbox lately, so that I can sync it between my Windows machine and my Macbook. Well, a data file that my code needs to directly modify as it processes the file and spits out new ones got corrupted as the result of a bug in my code.

Thankfully, since I use Dropbox, it was easy to login to the website and revert the data file to a previous version and try it again. Otherwise, I wouldn’t have a copy of the data file and would have to re-assemble it from the pieces I had four hours ago.

Thanks, Dropbox!

Comments Off :, , more...

Journey of Souls: Language Decisions

by Jeremy on Sep.15, 2009, under Journey of Souls

We’ve been giving a lot of thought to our choice in Programming Language for Journey of Souls. For a while, it was starting to look like we were going to end up writing everything in PHP or Python. I think we’ve made our decision (or at least are very close). It ended up coming down to a few things that PHP and Python just don’t have any out of the box support for. Things that it would be extremely stupid for us to roll our own implementations, when another language offers the feature up really well. The first of these being Events and Event Handling. The second being a way to write game scripts in a way that they can be replaced on the fly while the game is still running. Here’s some of the details from our research and decisions. (continue reading…)

1 Comment :, more...

Journey of Souls: Spirit Realm, Offline Training, In-Game Consequences

by Jeremy on Sep.14, 2009, under Journey of Souls

I covered a few of my goals for Journey of Souls in my previous post. Dutch and I actually kept our plans to book club this evening and it brought about some discussion on a few game mechanics that we’d like to see in Journey of Souls. First of all, there’s a huge disparity between people who spend way too much time playing games and people who play casually. We want to make some enhancements to try to reduce that disparity and try to keep it fair to the players who do invest their time. Second, we’ve identified ways to enhance our use of the spirit realm to give it a few “eerie” but what we believe to be very cool effects. We’ve also discussed ways to clearly communicate what’s in the spirit realm versus what’s in the physical realm and different “affinities” to different areas in the spirit realm. Finally, we want to make it clear that we’re going to try to make in-game (or in character) consequences to as much “bad” behavior as possible. We don’t want to write code to prevent people from doing logical things, no matter how screwed up their logic might be. Instead, we want there to be in-game consequences to all of your actions. (continue reading…)

Comments Off :, , more...

My Goals for Journey of Souls, Part One

by Jeremy on Sep.09, 2009, under Journey of Souls

This post was scheduled to be published on the other 09:09:09 9/9/09 for the day. Cause I’m corny like that.

As some of you may or may not know, I’ve been off and on working on a MUD called Journey of Souls. I wanted to take a moment to go over what my plans are for the game for the benefit of those of you who don’t read what I write on Anfiniti. Dutch and I’ve been more inspired to work on the game lately, and we’ve even decided to book club a selection of chapters from a game development book which closely relate to what we’ll be doing. The plan is for this book club to actually start this weekend, so we’ll see how that goes.

At the moment, I’m right on the edge of finally choosing the language we will be developing the MUD in. We originally started in PHP, but there are some things that it can’t do (without some highly unsupported extensions) that some languages (say, Python) can do by default. And then there’s that whole we plan to run this on a server for months at a time thing. I originally started with PHP for two reasons, one of which was to prove it could be done in PHP (and done well). So, we’re still surveying that landscape to figure out what we’ll finally be settling on. I’d like to make a decision by the weekend, because I’d like for us to do any examples from our book club in the language we’ll actually be writing the code for the game in. Anyway, onto my goals for the game …

My goals are a bit lofty. It’ll be a long time before the game is available to the public, but I’ve been slowly gathering together ideas over the years for different things to incorporate into the game and different ways to get it out to the masses, once it’s ready. I want to try to summarize my goal for JoS into this post and give you guys all an idea of the type of game I’m going for. If I could just get the cat to stop sticking hair to my monitor. (continue reading…)

Comments Off :, , more...

9:09:09 9/9/09

by Jeremy on Sep.09, 2009, under General Ramblings

Happy 9’s to you all. I used the joke below in like three different places last night. Might as well be a schmuck and put it here too. It’s still lame, and that’s okay. I was able to laugh about it. A little. Okay, maybe it was just a smirk. Whatever.

[01:11] Jeremy Privett: Oh, and we’re coming up on 9:09:09 9/9/09.
[01:11] Dutch Buckholz: yes, yes we are
[01:11] Jeremy Privett: It was nice knowing you.
[01:11] Dutch Buckholz: nah – that’s 2012, everybody knows that
[01:12] Jeremy Privett: lol
[01:12] Dutch Buckholz: today is just a day without LOLcats

Either way, make some attempt to enjoy the day. I mean, you’re only ever going to see 9:09:09 9/9/09 once in your lifetime, after all. Well, twice if you count the PM version.

I actually scheduled this blog entry to post exactly at 9:09:09 9/9/09. In some timezone. I don’t remember which one it’s set to.

Comments Off :, , more...

Okay, so I lied

by Jeremy on Sep.09, 2009, under General Ramblings

There’s something about this whole blogging thing that, no matter how pointless it may seem, always keeps me coming back to it. Maybe I’m expecting people to read this thing and actually care. (Yes, I know some of you actually do.) There’s a lot of history in this old thing. I still keep making backups of the database, because I don’t want to lose what’s here. I also don’t intend to let the web space go away. I don’t have the time to do anything more complex than a blog at the moment, so why am I wasting the money?

Since I stopped blogging, I’ve looked at this thing almost every day. As if something was going to just pop up here on its own. Or you folks were going to comment on something (oh, wait — you can’t). I’ve been so smashed by work that I’ve sort of lost connection with a lot of really awesome people and I’m really not okay with that. Blogging again is going to be my first step to getting back in touch with all the folks that have kinda been swept aside in the wake of all of the crazy stuff that’s been happening for the past ten months.

I have projects I’m working on that I want to talk about. Life elements I haven’t talked about here. There’s a lot still to say. And a lot has happened over the past several months. It’s going to be interesting to see if I actually will write about any or all of it, but this is me saying that I’m at least going to make an attempt. You’ve all heard that before, though.

I’m still @jeremyprivett on Twitter and I’ll be trying to be more active there, as well. Encourage me! Help me be more active with all of you. I don’t forget about any of you on purpose, I swear. There’s just a lot going on. A lot of stuff has just kind of dropped off my radar and I want to get it all back.

It’s Round … 3, I think. Let’s do this thing.

1 Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!