Monday, February 27, 2012
Migration to a new blog
My new blog can be found at blog.rootentropy.co.za.
Saturday, January 30, 2010
Scheduler, Part 2: The Design
The class diagrams for the Scheduler were really simple and straight forward.
The Task class represents a task that we will be scheduling, the task manager contains a list of tasks that and has methods that enables it to control the addition and removal of tasks and the logic to decide which task should be executed next.
The applications Form class is where all the event handlers are taken care of (events are triggered such as clicking on a button). Its good practice to brake your applications logic down into formal steps, in the Scheduler for instance you have to click on the New Task button before the text box below it becomes enabled so that you may enter a name for that task. This makes for more intuitive applications that are more user friendly and have a lower learning curve, an applications interface should always “make sense”.
Keeping control of your programs states and the flow of control is often a tedious task and makes for mindless zombie coding, but once done it really adds to the feel and robustness of the software.
State management and application flow also gives a programmer the opportunity to insure that all the data that is needed for the next step is present, type checking should also be done while controlling program flow.
In my next post Part 3, I’ll go over some code snippets and add a link to the source code and compiled application.
Thursday, January 28, 2010
Scheduler, Part 1: The overview
So I've been coding like a daemon ;) and I've just about finished this little scheduler application.
While I could have done it allot faster and simpler, this version of the application is a bit more robust. In other words if the average Joe was to use it, they shouldn't be able to break it.
It's still a fairly simple program though, its primary task is to take applications you give it, couple them with a date and a time and then once that date/time is reached it executes the given application.
I initially started writing this so that I could execute my Age of Conan updater after 01:00 in the morning, since its updates were HUGE and the cost of my bandwidth comes done between 01:00 and 08:00 in the morning. Yes I am aware that windows have a native scheduler, but that damned thing kept crashing AoC on start-up and I didn't feel like installing a 3rd party program so I wrote one myself.
In any case, Part 2 will illustrate the design of this application and how it works.
Part 3 will the run through some code snippets and just show how everything fits together.
Hope someone can make use of this, Part 3 will also include a link from where the application may be downloaded.
Wednesday, January 27, 2010
Vacation, degree and no more lies!
Since my last post there have been a few, big developments:
- For starters I have a degree, it’s a BSc in computer science and information systems :D :D
- I've also been excepted into computer science honours at Rhodes university, yay!
- And I turned 23.
So my 2 month vacation is about to end with university starting again on the 1st of February, during the last two months I had played a ridicules amount of computer games, done some mediocre coding (in XNA) and finished my first website (for which I received payment).
The website was allot of fun, I worked with a close friend on it. We used a php framework he had written (I like to think I influenced some of it) and had a great time working on it. As soon as I see him again I’ll ask his permission and see if I can share the framework on here.
I'm busy working on a light weight scheduling application again, since microsoft vista chooses to crash instead of execute on demand... The application is coming along nicely but after spending some time on it I realised it could serve as a nice tutorial on how to work with the Time object in C#, file dialogs, polymorphism, encapsulation and UML diagrams. Since I've so far failed at putting up a light tutorial (or of any flavour that is) I'll try and get one up, hazaaa!
So this year I get to do one massive and awesome project in honours (along with my chosen modules) and I’m so keen to start and get into it. Oh and this isen’t another hollow promise, when I’ve selected/accepted for the project I’ll post more details on it. Until then though, peace and code for change. (however you wish to interpret that!)
Monday, November 9, 2009
Systems Development
In the end we had created an entire business management solution; we took 3rd prize and were happy with the results. Here’s a link to a quick website we setup to show off the system. It was written using C# with the .net 3.5 framework and also heavily relied on Ado.Net.
The website showing the system's details can be found at www.2by2.biz.nf .
Friday, September 4, 2009
Game Theory: Pure and Mixed Strategies
Strategies form the basis of Game Theory, without strategies there would be no way of performing actions in a game. A strategy is that set of actions that will be performed for whichever situation that could arise in a game. A strategy may be completely random or on the other hand a thoroughly thought out and complex set of plays, it may even be a mixture of both.
The Strategy
A strategy profile is a set of strategies that are pre-determined by a player to be the actions they perform in response to any given situation in a game. This could be illustrated by a simple finite state diagram. Consider a simple game where players roll a dice and need to bet if their dice roll would beat their opponents. Player 1’s strategy could be to only bet that his dice will be a higher value than his opponent, if he lost his last game (very crudely trying to follow the law of averages) this could be represented as follows.
In other words a player’s Strategy Profile is a subset (but not necessarily a proper subset) of the player’s Strategy Set (which is all possible strategies).
For example the game Rock-paper-scissors gives players a strategy set of {Rock, Paper, Scissors}, a players Strategy Profile could however be to only play {Rock} every time.
Pure Strategy
The Strategy Set available to a player is the set of pure strategies available to a player, a players strategy profile will then consist of a proper or in-proper subset of that strategy set.
This will provide the player with a complete definition of how they will re-act to satiations in that game. In the Rock-paper-scissors example if a players Strategy Profile consists of always playing Rock and then Scissors, so {(R, S, R, S, R, S, ...)} they would be playing a pure strategy.
People have a mixed view on the concept of free will, some believe we are in charge of what we do and other believe that we are merely puppets in the game of life (played by fate) and that all our actions have been pre-determined. If you look at life from this perspective, that we do not have any free will, then life could be seen as a game were the players (fate and fate’s cousin) are playing a pure strategy, from the Strategy set that encompasses all possible actions our lives are played out by a ordered set of actions.
A simpler and less open to debate example of a pure strategy would be that of a person who play exactly the same numbers in the national lottery every week. Out of all the possible combinations in the Strategy Set (49*48*47..*43 possible combinations) were each combination is a pure strategy. If that player plays only one combination (and the same one) every week, it could be said that they are playing a pure strategy.
Mixed Strategy
With a Mixed Strategy a player assigns a probability of play to each pure strategy, this allows a player to select a pure strategy at random, for instance with the Rock-paper-scissors example, if the player rolled a six sided dice and on a 1 or 2 played Rock, 3 or 4 played Paper and a 5 or 6 played Scissors, they would be using a mixed strategy. { ((1,2)->R,(3,4)->P, (5,6)->S))}
Lastly I’d like to mention Nash Equilibriums and strategies, a set of strategies is a Nash equilibrium if no player can do any better by unilaterally changing their strategy, in other words if I player new the opponents strategy beforehand but could still not indefinitely improve their own strategy then their strategy would be a Nash equilibrium.
Pure and Mixed strategies can be a Nash equilibrium this however becomes tricky when your take into account the effect that peoples beliefs have on a game, the issue here is that people lack the ability to (by themselves at least) generate random numbers. We require the ability to generate random numbers if we wish to use a mixed strategy due to its use of probabilities.
So in the end, people hinder the predictive power of a Nash Equilibrium as well as the ability to play any Strategy correctly (whether pure or mixed). In essence a pure strategy is just a mixed strategy were the played strategy has a probability of 1 and all other strategies have a probability of 0. There will always be one person who will go against the grain of a well thought out strategy and in their stupidity break our “intelligent” reasoning.
Tuesday, September 1, 2009
Colour based motion tracking
For a while now I've been wanting to create a game that makes use of motion tracking from an ordinary web camera. The basic idea is to take two frames in succession from a recording, clean up their images and then find the difference between them. If there is a difference then thats were the movement was!
I soon found out that general motion capture wasn't exactly what I was looking for, I wanted a player to control some avatar in a game by using gestures, the best way to isolate one specific movement is to use colour. If the movement falls within some RGB range, then take that as the movement, draw a rectangle around it and take the center of the rectangle for your X and Y co-ordinates to move your avatar. This stops the motion detector from picking up the silly grin I had when I realised I was tracking motion.
The basic code is almost done, I'm just ironing some things out. Hopefully I can have the code up by this weekend with a tutorial. The actual game will be implemented in XNA, at the moment I'm thinking of making a 3D first person space shooter. Were your head will control yaw and pith (while you move your head left/right and up/down) and roll, strafing, acceleration and deceleration will be done using keyboard/mouse.
Perhaps I'll call it "Bobbing Heads Space Flight"
If anyone is interested in trying out something like this I recommend that you have a look at the AForge.NET framework, its just bloody amazing. Also, Andrew Kirillov provided most of the code I used above in his "Lego Plan Tilt Camera" so check out the link if you want to learn more about what he's done, lego pan tilt camera