Thursday, April 19, 2007

Rendering chess positions


Chess, 3-D graphics and FOSS are three areas I like. I have been using the POV-Ray program for sometime now and prepared files to render individual chess pieces, which can be included in a POV-Ray scene. I tested the include files with a board and a few lights. This way, I could include the shape definition for a piece and place it on a given position on the board by translating it.

Next, I studied the CPAN Chess libraries in Perl and figured how to read in a file saved in FEN with a Perl script. The script would then generate a POV-Ray file with necessary translate instructions to place different pieces in different positions, as specified in the input FEN file. Now, I simply used POV-Ray to render the file generated above and I have a 3-D view of the board position. I have included a sample image. I got this position by editing the start position in Xboard using the "Edit Game" feature. I saved the position as an FEN file and then ran the perl script and the povray program on my ubuntu powered laptop.

Thursday, April 12, 2007

Varsity project on sourceforge.net

In the penultimate year of my bachelors course in Information Science engineering, my classmate, Vineeth and I developed a handy little piece of software. Back then, we were learning UML and were amused with how new applications could be designed using it's methodology. Why not develop software using which we could design UML diagrams, we thought. This idea stuck as our curricular mini-project for the 6th semester.

The UML design suite, which was the result of our efforts, finally had 7 modules. You could develop
  • Use-case diagrams
  • Sequence diagrams
  • Activity diagrams
  • Class diagrams
  • Component diagrams
  • Deployment diagrams
We implemented two options for saving work. First, an open XML based file format which we developed. Second, any of a set of well known image formats including JPEG and PNG.

The project was not publically available for long and we knew we could not leave something of it's kind stored somewhere on a CD or computer without any positives coming out of it. So recently, I submitted the online and requested sourceforge to have our project up on their archives.

On sourceforge, our project has a homepage, screenshots, a subversion repository, forums for development and open discussion. All these can be accessed by clicking:

http://sourceforge.net/projects/umldesignsuite

Tuesday, February 20, 2007

deepOfix public release

Many things are happening around the world. People are working for a living, children are studying in schools, youth are looking for employment, cities, especially here in south India are growing. Today is a very special day because I am part of something unique. If I were to read a newspaper and ask myself, what does this newspaper have in it for me to be happy about, for example, a fellow Indian - Ratan Tata's work through the years in bringing a grand old company to this age when it has acquired both quality and size, the events culminating in his TATA's takeover of the Corus group. This kind of news makes me take pride in a fellow countryman and in many ways, a man I look up to personally as one who, having had wealth, nevertheless worked and with genuine sincerity and constancy through the years, has brought us here in this massive subcontinent a smile.

Sometimes, days pass us by and we wonder what has changed. Today, I believe something that has been in the laboratory of deeprootlinux is being unveiled - released publicly. Today, DeepRoot Linux releases deepOfix Mail Server, a one-of-its-kind product. deepOfix has been developed without using any propreitary software development platform or software development tool. Our network runs completely on Free Software products. We use FOSS (Free and Open Source) products for testing, linking, interpreting and compiling code, version management, hosting of our servers, managing mail withing our company. I am pleased to know of the many institutions using our product, many of who have good things to say about it. The DeepOfix page on sourceforge.net is:

http://sourceforge.net/projects/deepofix

Update: The deepOfix project is now at http://deepofix.org

Thursday, February 08, 2007

Men, Ideas, Computers and Society

Thomas Jefferson, third President of the United States of America wrote a letter to Isaac McPherson in 1813 regarding an 'idea'. He lived in a time of many intellectual inventions. Inventors often sought patents and Jefferson wanted to communicate to McPherson that an idea should be available to all, for mutual benefit. This is (part of) what he had to write:

"If nature has made any one thing less susceptible than all others of exclusive property, it is the action of the thinking power called an idea, which an individual may exclusively possess as long as he keeps it to himself; but the moment it is divulged, it forces itself into the possession of every one, and the receiver cannot dispossess himself of it. Its peculiar character, too, is that no one possesses the less, because every other possesses the whole of it. He who receives an idea from me, receives instruction himself without lessening mine; as he who lights his taper at mine, receives light without darkening me."

Today, the computer has been long since invented, streamlined and brought to many desks. People in countries all over the earth use computers - many have prepared documents using word processors, presentation software and so forth. Many programmers develop software and many organizations use software and also earn revenue from developing software.

In this article, I wish to write about my moral perspective on free and open source software and proprietary software. The human mind is the place where every invention starts. A person works very hard for a period of time and tries many methods, until finally (s)he comes upon a solution. Where does this solution come from and how is it shared fairly with all? This article is not a final word, or even one I expect the reader to accept. Yet, I hope it makes for interesting reading.

What makes us human? Many animals live on our planet and have many capabilities. But we are social by nature - we share and live together in families. What we own is not entirely ours. For example, if I wear a shirt, the idea of making thread was given to one person. He shared it and many know how to make thread. Similarly, many know how to weave thread into cloth. This idea too came from some person. Cloth making and computer manufacturing may have started not centuries, but millenia apart. Yet, we remain people in need of mutual help.

Now, if every person in the world believed in free software, believed that free software was going to solve many problems, this is positive, but not ultimate. From a moral perspective, we ask ourselves whether we have given to poorer people dignity and opportunity to grow. If we give complete liberty to our children, for example, would they learn and live by principle? How are we to know whether they would use freedom justly and fairly and be fair and just for others? People in a ravaged country would be conscious of the possible ills of a morally deficient society. People who have not felt the pain of certain kinds of deprivation may not grow up with this social sensitivity.

Ultimately, proprietary and open source software models are in the hands of people. If a software developer is sensitive to the poor man near his house, he wants to help him. The poor man has a great dignity as a man, he can have other treasures than wealth - virtue. When justice is not yet established in a land or society, its people suffer and there is need to change. If reform is initiated by people willing to take the risk and offer themselves for it, there may be improvement until possibly justice and peace reigns. If a land or a society enjoys justice and peace, it can be a nursery of mutual respect and growth. Yet, this can stagnate a society because the social interdependence which brought the people to this good time can be forgotten. People can become aloof to the needs of the underprivileged.

Virtues - charity, peace, desire to share, all stem from man's goodness. Social evil comes because of man's passion - greed, prejudice, selfishness. Yet, this is not only a societal problem, but a personal one too. Morality of a society is a necessary precursor of all good things which come later. History has shown that where there were greedy or power hungry people - those who caused many to die, these could not last the test of time. Men may have been feared because of their brutality - even if they were geniuses at military conflict, they did not leave a moral quality that can remain the strength of a society. Morality and ethics therefore are facets of human development that, though different from culture to culture, are a common need for all of us. Only in this way, I can trust you when we work together, or even play a game of football together. Only in this way can we build something that we cannot build individually.

Wednesday, January 31, 2007

Spiral using ncurses

I tried to write a program to draw a spiral using the ncurses library - one which draws slowly in a way which can be seen noticeably. I first analyzed the number of characters to be drawn in each direction - down, right, up and left.

I prepared a table having the number of characters in the outer spiral of the spiral design. I used a variable, m, to hold the number of characters in a particular direction. I programmed m to change according to the mathematical pattern which we can notice in the table.


+----------+----+-----+------+--------+
| n | 1 | 2 | 3 | 4 |
| down | 4 | 8 | 12 | 16 |
| right | 3 | 7 | 11 | 15 |
| up | 2 | 6 | 10 | 14 |
| left | 1 | 5 | 9 | 13 |
+----------+----+-----+------+--------+

I leave the code for the interested reader here. I implemented this using C with the help of the ncurses library for moving the cursor in the relevant directions before printing the character.

#include <curses.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
int x, y, n, i, m, dx, dy, j;
int ay[] = {1, 0, -1, 0};
int ax[] = {0, 1, 0, -1};
int am[] = {1, 1, 1, 1};

char s[80];

n = atoi(argv[1]);
m = n * 4;

initscr();
cbreak();
noecho();
nonl();
intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);

x = 0;
y = 0;

while (m > 0)
{
for (i = 0; i < 4; ++i)
{
dx = ax[i];
dy = ay[i];
for (j = 0; j < m; ++j)
{
x += dx; y += dy;
mvaddstr(y, x, "X");
}
system("sleep 1");
refresh();
--m;
}
}

system("sleep 1");

endwin();

return 0;
}


The program, when run, should draw the pattern arm by arm or the spiral, i.e, first downward, then rightward, then upward and then leftward. The following is the output for n = 3:



X
X XXXXXXXXXX
X X X
X X XXXXXX X
X X X X X
X X X XX X X
X X X X X X
X X XXXX X X
X X X X
X XXXXXXXX X
X X
XXXXXXXXXXXX