Showing posts with label Level Up. Show all posts
Showing posts with label Level Up. Show all posts

Friday, July 24, 2009

Project Euler Level up!

Even though I only have 24 reports, I actually have done another problem which sets me at 25 problems completed. This is great! When I completed the problem I was presented with this message.


I was very excited to see this. I'm above 79.4% - that's pretty awesome. When I went to look at my profile I was very happy to be presented with this.

Yeah, I bet you didn't know they were handing out TRIANGLES! but they aren't just handing them out to anyone. One day I hope to become spherical - this is my dream; my goal in life.

Anyways, I thought I'd take a moment and reflect back on the past 25 problems and see how this project Euler is treating me and everything.

My original primary reason to do these problems was that I wanted to become a better C++ programmer. After the first 10 problems I realized that was an unreasonable goal given the means. These problems are really more intellectually challenging and are working my mind several times harder than it is working my C++ skills. However, I do not want to discredit what I have learned. I have become more familiar with the standard library and more comfortable with the syntax.

One thing these problems are not requiring is work with classes. But, I am considering putting together a namespace and classes (where applicable) of the methods that I find myself commonly using in these problems.

Overall I am enjoying working on these problems. I have always found interest in any intellectual challenge and these are a good way to work that. One thing I am unhappy about is that with all of these reports this blog has become much more serious and intellectual than I originally wanted. If anyone has any suggestions on how to mix things up then let me know! I don't want to lose all 7 of my readers!

Level Up!
Jasson grows to Level 10 Programmer.
Jasson's STR (in fingers) increases by 3.
Jasson's INT increases by 99.
Jasson learns skill "Basic C++".

Alright!

*saved game*

Thursday, June 11, 2009

Quest Log: Question Bank I/O

Occasionally, the topic of a post requires detail and precision and consequently I feel it is necessary to take a serious tone. Such as the topic of this post was a major learning process for me and I feel I would be doing it injustice to obfuscate it in any way.

The saving and loading of question banks seemed easy enough at first but like many thing was much more complex than I had originally anticipated. A question bank consists of subjects and each subject consists of levels and each level consists of questions. Everything except for the questions are basically folders and therefor only contain a title, subtitle and author (type string). The meat of a question bank are the questions. Each question consists of several fields all of which are string or int type except for the query (the actual question) and the answer. These both need to contain richtext and at first were being held in System.Windows.Documents.TextRange.

The TextRange class has a Load and Save method that allows to read/write from a stream in a specific format with one being RTF. These methods were my keys to being able to save/load a Question Bank or so I thought. The first problem I quickly came up against was that TextRange.Load() will read from a stream but reads from the current position to the end of the stream. This was was a problem because each question bank file contains many RTF sections not to mention all of the other data.

With my experience in Streams being extremely limited, I was stumped on how solve this issue. Fortunately at my favorite programming site, StackOverflow I was able to get some help. The solution is pretty straight forward. I simply had to take each RTF section of the file (the query and answer of each question) and put that into its own MemoryStream. Now when using TextRange.Load() it could read to the end of the MemoryStream and everyone would be happy. Problem solved! ... right?

I continued on with development under the assumption that the I/O had been completely taken care of. As I was completing the implementation of the Question Bank Importer I attempted to import a real FITS Question Bank that has 1703 questions in it. It took about a minute or two to import but that would soon be improved upon so at least it worked! I was excited... but my excitement was short lived. Soon afterward, I found myself going to test something else. I ran the debugger and waited for the application to run...and waited...and waited some more and then finally it opened up. It took about a total of 3 minutes!

Remeber that all Question Banks are loaded at startup. Up until this point of development I had been testing everything with two test Question Banks and each of these had about 5-10 questions in them. Everything worked great with these small Question Banks; however, the reality is that FITS writes Question Banks that can have over 2000 questions in them. This is 200 times more than my question bank. In other words, I had a real problem.

The first thing that came to mind was that I needed to get my hands on a profiler. I had actually never used a profiler before and only had heard about them. After doing a little research I found RedGate's ANTS Profiler. I love this piece of software. After running the profiler I quickly found the culprit. TextRange.Load() was taking an absurd amount of the CPU time, about 83%, with another 10% was being devoted to getting the RTF from the FileStream into the MemoryStream (I was parsing it...).

I quickly realized that there was no way to change the speed of TextRange.Load() and that I needed to find another way to do the I/O for the RTF sections of the file. I once again looked to StackOverflow for some guidance. A few suggestions were made, but ultimately I decided to change the type of Query and Answer from TextRange to simply byte[]. This is a MUCH better approach. In retrospect I can see that TextRange was a horrible design decision. It is designed to be used for selecting a section of a FlowDocument and not for storing data. With the byte[] it simply hold what would go into the MemoryStream and then whenever the text of a query or answer need to be displayed this byte[] is loaded with TextRange.Load().

With this alteration the two major sections of the load time were completely cut out and loading went from 2-3 minutes to an unnoticeable load time (1~ second). Needless to say this was a victory for me. It was quite an issue but with it being solved I was glad to have gone through it. It was afterall a great learning experience.

Code samples can be found in the links to the StackOverflow questions.

Because this was such a huge learning process for me I think I deserve a...

Level Up!
Jasson grows to Level 9 Programmer.
Jasson's HP increases by 20.
Jasson's INT increases by 4.
Jasson learns skill "Profiler".

That's more like it!

*saved game*

Friday, June 5, 2009

Quest Log: Power Overwhelming

The moment I took WPF up in hand, I was hit with a surge of power. Once I gained some control I realized there was much much more to WPF than I had initially thought. Not to mention that I also moved to .NET 3.5 SP1 which had a number of new things as well.

I had never used Routed Commands. Never heard of Dependency Properties. Had no concept of Data Templates, Control Templates, and Styles! Bindings? I will admit it was fairly difficult to completely grasp everything and I am actually still learning.

I definitely would have not been able to do it without the help of fellow bloggers, miscellaneous forum posts and one of my new favorite sites, StackOverflow. Unfortunately I do not have everything bookmarked, but here are some of the sites that were very useful.

StackOverflow

This has been the most helpful site for me. It is basically a website were users can post questions and answer questions. That's it!

Dr. WPF - Items Control Series

A blog series by Dr. WPF. It was what really helped me start to learn how WPF actually works and was the inspiration for some of the UI.

Bea Stollnitz Blog
This blog wasn't as helpful to me as some other blogs because of what I was doing, but it definitely has HQ Content (High Quality).

Official Microsoft WinForms and WPF Website
Very useful. I watched many of the videos on the site and plan to watch some more.

Some Site
I don't remember how much I used of this site, but I had it bookmarked and it looks pretty good...

The weekend I made the switch to WPF I did some major grinding. I would say that I was at it for almost 40 hours in the three days. (I had Fridays off... yes, heroes get days off.) Once I returned to the town "SJSU", I couldn't help but to walk up to all of the NPCs and tell them about WPF. But still they all repeated the same thing they always say. I suppose that should have been expected.

Needless to say, I gained a lot of XP from this...

Level Up!
Jasson grows to Level 8 Programmer.
Jasson's HP increases by 1...
Jasson's STR increases by -5... >.>;
Jasson learns skill "Basic WPF"

*saved game*

Thursday, May 28, 2009

Obtained Quest: Application Development

My first real quest! I have had several mini quests before this one, but they were just that - mini. And this is why I start off in this story/blog as a level 7 programmer and not level 1. This may also be a clue to why in some games your characters do not start at level 1. I know I once wondered this but lets avoid from getting completely distracted from what's really important - The Quest!

So this quest was presented to me by the NPC, Matthew Muldoon, the CEO of FITS (Fire Instructor Testing Software) aka my father in law. Once thing I would like to clear up is that I was not presented this quest because I married his wonderful/beautiful/lots of other good things daughter but because, like in all games, only the hero can receive quests. Moving along, Here is an overview of the FITS products.

"With the FITS Quiz Generator and Question Files, you can assemble, customize and print a multiple choice test in minutes instead of hours. Sold only to Fire Service instructors and trainers- not to your trainees.
" - FITS Website

The mentioned Quiz Generator is the software FITS and their clients use. Basically, it allows users to both create questions and store them in a question bank as well as make quizzes using the questions from a question bank. The developer of the Quiz Generator became too busy to continue supporting it and this is where I come in.

I was presented this quest to develop a new Quiz Generator that would shake the very foundation of this world...or at least provide the user with a fresh and simple interface to carry out more or less the same task as the predecessor.

I actually received this quest in about November of 2008; however, development did not really start until sometime in February 2009. I have been working on this quest while I finished up my final semester at San Jose State University and just last week I received the key item "diploma" (BSCS). With lots of hard work and many hours of playtime put into this quest I am finally nearing the completion of it.

The next number of posts will focus on the development of this project and what really went into both designing and developing this application from the ground up. Stay tuned!

*saved game*