Thursday, October 2, 2008

Time I Wish I Had (Part 1)

Simply put, I love game programming. Yes, this entails a lot. Graphics programming, game play logic, artificial intelligence development, user interface, sound programming...everything about it is interesting to me in some fashion.

I was lucky enough to work with a friend during the last semester of college to build a Real Time Strategy (RTS) game that incorporated all of these elements listed. It was built in Microsoft's XNA environment using C#. My buddy, also named Scott, had worlds more experience in game development than I, so he was essentially the project lead in our "Tech Wars" RTS game.

I got to dive into certain ares of development that had been until that point theory to me. Aspects of the game that included the AI and gameplay were the most interesting for me...to be able to give objects life, and to give them "rules" on how to react under different situations was challenging but extremely entertaining at the same time. Though nerdy, it was somewhat empowering to be able to give objects life and to tell them how to think.

I honestly wish I had more time to expand on this project and to work on new ones...this working for 30 mins here, an hour there doesn't get me anywhere!

here is the game manual for our project last semester.

I'll go over some of the more technical things during my next post and what I am currently working on in terms of game development. A hint: Particle Engines!

Thursday, May 29, 2008

Some Web Development

It is late, but not too late, so I thought I'd give the reader (you!) a quick peak into my brain right now so I can take a break from some web development work. You'll be stoked to know that I'm going to ramble about web development!! Yaays for some, Oh noes for others. You've been warned.

Lately I've been working as a consultant to do some web development for a huge company (which provides natural gas and electricity for 66% of California...figure it out). The progress of work is going fairly well which is nice because I haven't done any hard-core web development work in over ten months...but moving on, as a consultant I am given a set of, "I want it to do this," and some, "We need this type of functionality," along with a million other buzzwords that include, but are not limited to: streamline, intuitive, microformats, RSS, and the worst one of them all "Web 2.0".

This particular project has me coding with PHP and using mySQL as the database. Now I have had some experience with Ruby on Rails and AJAX, which falls under the umbrella of that glorious "Web 2.0" title, which involved PHP, javascript, XML, and mySQL. AJAX can do and create some neat effects for the user, but doesn't mean that we should try create everything in an AJAX fashion. With this project I was given the instructions to make the project as 2.0 as I could...of course I question this (meaning I question it in my head, they're the ones signing the checks) because I'm almost sure that: A) Web 2.0 doesn't have an official set of standards (at least to my knowledge) which define something as 2.0 verses 1.0 (or maybe even Web 1.54f ;)) and B)the project manager will take some nice looking css or DHTML effects as 2.0ish and not know any better.

I don't know where this "Web 2.0" obsession came from and why it is such a necessary thing to try to achieve in web development. As any developer knows there are multiple solutions for any given problem and singularity idea that if something isn't "Web 2.0" then it is behind the times is quite absurd.

In my next consultant job when asked to make something "2.0" I might just have to say, "Yeah, I can do that, but I can make it 'Haselton 4.6' which is something that is newer and is a higher number than that '2.0'" and then just make some flamboyant DHTML/PHP/ASP.NET project...or not and just nod my head and collect the check.

Monday, April 28, 2008

ISA for a RISC

I get the question, "so what do you do in computer science?" quite a bit. A truly simple question without a simple answer. My mind races when I get this question. Do I tell them about the mathematical logic, number theory, graph theory, numerical analysis, or inform them of automata, computability and computational complexity theories, or I could go the route of analysis of algorithms and data structures, or even go into the realm of system architecture which includes computer architecture, computer organization, and operating systems. But I'm leaving out the data mining, relational databases, artificial intelligence, automated reasoning, and machine learning that I could also talk about. I usually just say, "I program" and be over with it because lets be real, unless you're a fellow CECS student/major/graduate/enthusiast you are not going to want to hear about all that exciting stuff. But now I am going to give you an actual glimpse of some of the things that I work on.

Here is a project that I worked on last semester in my computer architecture class, so I hope that you enjoy it as much as I did working on it :)

fun times

Note: the file is around 2.5 MB so it might take 10+ seconds to load the page

Tuesday, April 22, 2008

those speedy little electrons!

If you're anything like me, you sometime wonder just how fast those little miracles known as electrons really go in everyday substances. With my small background in electricity and magnetism and a big case of wonder (and I know you wonder about this stuff too!) I made up some random scenarios (google helped a bit to which you'll see later) to see if I could actually calculate the speed of an electron.

I know that copper is a fairly typical conductor that is used, so I choose the length of 3.00m and the diameter, or width of 1.5mm of copper randomly to work with. Also, I had to give a current (I) that was being applied to the wire, I randomly choose 8.00 amps. With using copper, I asked google the resisitivity and concentration of copper. These are both important in determining if a substance, in our case copper, is a decent conductor.

Google didn't disappoint and came back with the answers of resisitivity (p) = 1.7*10^-8 (ohms)(meters) and the concentration (n) = 8.5*10^28 meters(negative cubed).

Armed with this information, I set out initially to find what is known as the "drift velocity" of a single electron in copper. A bit of background: millions of nano collisions are happening around us that make up the very things we interact with, same goes for a single electron with a current moving down a copper wire. The current essentially "guides" the electron a certain direction down the wire, but the electron can't go down the wire without bouncing off matter that makes up the copper wire. Thus we come to something known as the "drift velocity", or the average speed at which an electron goes before colliding with something else.*

The calculation of the drift velocity was fairly simple. I had to find the magnitude (J) of the current density in the copper wire. Related functions of current (I) = nq(drift)A
J = A/m^2 With A = cross section of the wire and m = mass of an electron
A = π r^2 = 3.14(0.0075)^2 = 1.8 *1 0^-4
m = (9.1*10^-31)^2 kg = 8.28100 * 10^-61
and it is known that the current density is proportional to the drift speed such that: J = n*e*(drift velocity). Simple algebra leads us to: drift = J/(n*e), or somewhere around 3.30 * 10 ^-4 m/s.

So what does this mean? It means that, on average, an electron will speed up to 3.30 * 10^-4 meters per second before bouncing into something...pretty neat, huh?


This of course got me to thinking how many actual (or close to actual) collisions that were going on in this copper wire every second.

For this I had to answer how many collisions per second does each electron undergo. With algebraic expression for the mean time between collisions equaling: time = mass/((electron's charge)^2 * n * p)
Which came out to be:
9.1 * 10^-31 / ((1.6*10^-19)^2 * (8.5 * 10^28) * (1.7 * 10^-8)) = 2.46 * 10^-14 s

1/(2.46 * 10^-14) = how many collision one electron encounters each second which is 4.07 * 10^13 !!!

Now multiply that times the volume of the wire (how many electrons the wire holds) which happens to be 4.5 * 10^23 and you get (drum roll please...)
1.83 * 10^37 collisions happening every single freakin' second. To try to grasp that number with greater awe, it is:
18300000000000000000000000000000000000 collisions every second!
Pretty damn amazing how much stuff is going on under your nose without you knowing it, huh? With my curiosity satisfied, it was time for an In 'n Out double double, or should be better known as 2(n) ;).

* I have thought about what you're probably thinking, is it possible that an electron travel down the wire without colliding into something? Well, if I were to take you out to the woods and blind fold you and told you to walk straight for a mile, you think that you would never hit a tree?