Wednesday, April 27, 2011

PA4, done and gone

The interleaving part was a lot easier than I was anticipating, but I had to lighten up on my attempt to preserve the test program in its original form.  The only change I really made was that I put all data into the same queue instead of having separate queues for the Calc and FSM data.

This was made possible through inheritance.  I created a QueueData class with an abstract getDataType() method.  Calc_Data and FSM_Data were refactored to inherit from this class.  The InputQueue was declared to store QueueData objects, so it could accommodate both types of data.  The process() method iterates through the queue, and if getDataType() says it's Calc data, then it calls pCalc.doWork().  Otherwise, it calls pFSM.doWork().

Mission accomplished!

Saturday, April 23, 2011

PA4 is coming along fast!

I just started working on PA4 and it's nearly halfway done already. I had to make some changes to the test program, but otherwise I've been able to conform to it very closely up to this point.

I'm ready to start the interleaving part now.  I know of a couple of different ways to implement this part, but I'm trying hard to use the test program as it's given, and I'm having a lot of trouble figuring out exactly how Professor Keenan's implementation worked.  If I don't figure it out soon, I'll just go with my own implementation and see how much of the original test program I can keep.  That'll be a task for Wednesday, which I believe will be my next chance to sit down with it.

More to come...

Thursday, April 21, 2011

PA3 is almost done...

I finally got a chance to sit down with PA3 again today.  Thankfully, the code I wrote at the airport last weekend compiled and ran.  However, it didn't work.  The server wasn't receiving the same data that was being sent...or so it appeared.

The problem had two parts -- first, memcpy doesn't work exactly the same way as sprintf.  Getting the data into the sending buffer was a whole lot easier when I switched to sprintf to write the integers into the character array.  Second, the server appeared to be receiving garbage.  The problem was the buffer length used in the recv call.  I was receiving the entire length of the buffer rather than just the number of bytes expected.  Once I made that change, the data came through nice and clean.

Then, miraculously, everything else fell into place pretty neatly.  The only other problem is that I was looping through the sorted list backwards and printing the numbers in the wrong order.

So now, the only reason that I say it's almost done is because of the error checking.  There is a lot of validation that I'm just skipping at the moment.  The code is riddled with "TODO" comments marking where additional validation needs to be performed.  I may or may not have a chance to get back in and do those things, so it's possible that the version that I just checked in is the final form of this assignment.

Monday, April 18, 2011

PA3 is underway

I was stuck at the airport with a three-hour delay.  What a great opportunity to start working on PA3!

I had no internet access to get to the Winsock documentation, but I did have my 3G smart phone.  I typed in the long, ugly, complicated URL from the assignment write-up on the unwieldy little keyboard and was able to read the tutorials.  Since I couldn't copy and paste from my phone into the IDE, I had to type the code by hand.  Inconvenient, but probably a better learning experience.

I believe that I was able to get most of the code in, but there was no time to test it.  I hope that I can try to run and troubleshoot the code soon.  I'll post again when I do.

Friday, April 15, 2011

I think PA2 stands for Pain in the A__ 2

PA2 is finished at last!  Here's how it went:

The first time I sat down with it, I took care of the Dog and Cat.  Pretty simple, as explained in my last blog post.

The second session was focused on the Bird.  It went through a few different iterations before it ran without throwing a debug assertion failure.  Getting the output to look right was simple.  Even the memory addresses were showing different objects as appropriate.  But it threw a debug assertion and corrupted the heap every time.

Having reached the end of my rope on the Bird problem, I decided to go ahead and write the code for the Fish. Due to the Bird's assertion failure, I was unable to test the Fish, so I just left the code as it was until I had a chance to fix the Bird.

I took a break from the whole thing and spent an afternoon at Yosemite National Park.  I think the fresh air helped, because when I returned to my hotel room (bed 'n breakfast actually), I was hit with an inspiration.  The problem with the debug assertion failure was a simple and stupid one -- as it turned out, I was just doing a couple of things out of order.  I was clearing out the string before deserializing the object rather than after.  Therefore, the original pointer address was being replaced rather than a brand new string being created.

To top it all off, the code I wrote for the Fish worked on the first try!  Yay!

Sunday, April 10, 2011

Finally, a chance to work on PA2

I finally got a chance to start working on PA2 today.  I wanted to wait and start it after I had a chance to watch the entire lecture, but I'm realizing that it would be impossible to do so, since it has taken me three separate sittings so far to get through the first hour and a half.  I really hate my workload at the moment, and my unreliable internet connection at home certainly doesn't help matters.

OK, enough whining.  There's work to be done.

I loaded up PA2 and ran it, and as expected, one test passed and four failed.  I added serialization code to the Dog class, and it passed the test.  I added serialization to the Cat class, and it passed its test too.  Then I optimized the Cat serialization by reordering the data members to make a smaller packet.  It worked.

Then I started working on the Bird class, and noticed that the serialization will not be quite so straightforward since it contains a string.  This will require some time and thought, neither of which I can spare any more this evening.  So I will have to wait until Tuesday to try out my strategy for this one.

I only hope there's enough time on Tuesday, since it will be my one and only chance to work on it before it's due. This is where things get tense and exciting, eh?

Sunday, April 3, 2011

PA1 -- The Spacewar part

Spacewar compiled and ran without any issues whatsoever.  I was annoyed by the controls, and I think there must be a better keyboard configuration.  I'll have to put some thought into it.

PA1 -- The C++ Part

I'm not entirely sure if my implementation is exactly what the assignment wanted, but the results look good.

Getting Started in SE558

This blog will be devoted to my work in SE558: Architecture and Design for Multiplayer Games. I've only made a couple of networked, multiplayer games, but they weren't real-time action games. So, I hope to get some great and valuable experience in this class by doing a new type of networked game that broadens my skills in this area.

These first few weeks could be a little rough, because I'm currently overbooked at work and it's taking up all of my days, nights, and weekends.  But in three weeks from now, I enter my annual non-teaching session, so there will be nothing on my calendar other than this class.  I can't wait to get there, because the pressures I'm under at the moment are anything but pleasant.

Still, I'm eager to get started on this class. I loved the last class I had with Professor Keenan and I'm really looking forward to this one.