Thursday, April 28, 2016

Calendar

This project is about a calendar which displays the various dates from 1 to 31 and the weekdays(Sun to Sat).
The project can be modified to select a particular month or year of the calendar on mouse input. This is left as an exercise.

Snapshot:


Here is the source.

Galaxy and cylinder

Two projects in this post. The first one is on Galaxy where the points(stars) are moving towards the viewer or looks like the space ship is moving in an infinite star system.
Snapshot:


Here is the source.

The other project is about a group of points in a cylinder rotating about the axis of the cylinder...

Snapshot:


Here is the source.

Friday, April 22, 2016

Vehicles going down a Highway - A Racing Game

I happen to travel daily on a tolled highway and this has afforded me some insight into the way vehicles move on it.
To the uninitiated in graphics simulating a highway with vehicles of all sizes would seem trivial.


A Question:
A question occurred to me about how could a vehicle try to minimize its travel time?

Observations:
Heavy vehicles struggle to climb an uphill and it also depends on whether the truck is carrying goods or not. Under such circumstances other passenger vehicles cannot get passage if the slow moving vehicles block the way.

Another observation is travel time depends not only on the top speed of your vehicle but also on the speed and position of other vehicles on the way and this is something that cannot be predicted.

Your own vehicle sometimes moves faster and sometimes slower depending on road conditions. Racing car fans know very well how fractions of a second matter in a win or loss.

The solution: 
The vehicles going on the road would do better for themselves if they stick to certain policies. These rules of driving do not originate from safety or traffic rule considerations but from game theory. What might be the form of such rules? Why would they help you while driving on a highway? Are there vast number of such rules, all of which you could never remember and more importantly would, not obeying them lead to any penalties in travel time.
I have read that in game theory a zero sum game is one where losses made by a player are exactly the gains made by the other and vice-versa. In a zero sum game which is also called strictly competitive game, solutions are usually found by the minimax algorithm a technique which assigns a score to each player and tries to attain maximum score for "the" player as opposed to the competitor under any circumstance.

I have in mind making an unbeatable tic-tac-toe game of 3x3 or 4x4 or 5x5 and this blog post originated from that thought.

Tuesday, April 19, 2016

Stack and Queue

On request i have created a project called Stack and Queue in which the following classes are defined.

button
stack
queue

There are four buttons at the bottom named "Push" "Pop" "Insert" and "Delete" which are used to push and pop from the stack and insert and delete from the queue.

Here is a snapshot:


Here is the source. Remember it is a C++ project and you have to save the file as .cpp. This is a very easy project to understand as you would have studied the working of stack and queue in your data structure classes.