“Will you be the third ?!” (c) Athos or chess on THREE

chess for three

The impetus for writing the article was the article habrahabr.ru/blogs/algorithm/105450 by lightcaster, who is engaged (it seems to be an interesting hobby) in what is interesting to my team in the foxyevents.de project (do not consider it for advertising) with a proposal to join our team developers. Because there is no way on Habré to write to this person "from the outside", it is necessary to write your own interesting (I hope) article.

Prelude


Any rare outstanding student wants to program to write something special ...

Once upon a time ("in a past life, probably"), when playing chess, my father joked that it would be nice to play three, not two, and at the same board. In those days there was no Internet (remember those !?) and it was impossible to find something like that in a matter of seconds. I remembered this “joke” after almost 15 years, when I needed to look for a project for a university where I taught “programming multimedia systems” ... The

idea seemed far from bad and I spoiled several sheets with enthusiasm before I drew something similar to

image

Of course, like any person inspired by the idea, I did not use the search engine to find a miracle that was invented long ago ...

Shovels and rakes


Perhaps the programming step was the hardest in this story. Not only did I have to jump from BASIC (BC> RK> Corvette> ZX Spectum 48 (BASIC)> Intel Pentium 4) immediately to Java 1.4 (jump through 8 years of computer life), and even mathematically faced an unsolvable task for myself . The fact is that “calculating by formula” was not identical to what the monitor showed. If we take it according to the formula when turning, for example, we obtain fractional values, because there are no rectangular cells on the board. Obtaining a fractional value by the formula, it is not possible to understand whether, for example, the value 0.33 is at 0 or 1 pixel. Just rounding here does not solve the problem.

It turned out that by clicking on cell 3 very close to the border (or clicking on the border), an unexpected cell was highlighted, which, in turn, was still not quite correctly outlined.

line trouble

As you can see in the figure, the lines do not coincide in several pixels if you extend the inclined lines of different lengths (the experiment can be carried out, for example, in MS Paint-e). At that time, I was doing a practical semester in Spain and in the evenings in wilderness you could do only a few things: watch TV, program, swim in the sea, fish or collect tangerines. Because I still didn’t catch fish, and the TV hated far before this millennium, then I was engaged in “tasks”, programming for the company or solving this problem every night, “spending at the computer” 15 hours a day. Days passed, weeks ... two months passed ... the task was not solved, the time for delivery was approaching. Of course, I understood, "clumsily, but it works." However, this did not suit me, and even some kind of competition had already begun, who did whom.

[At this point, you can try to postpone the article and solve the problem yourself. Impatient can read more ...]

Toughie


I was always interested in a non-standard solution of problems and here it, fortunately, helped me out. Look at the following figure carefully.

chess for three in 2D

What do you see? A board ... lines ... cells ... colors? Yeah. And how many colors are there on the board? Count? Lines, cells, several colors ... 7 ... 8 ...? But you considered it very bad. Their 98! Each cell is an indistinguishable color for the eye, but not for the computer! Presenting the project at the "school", the hall has reserved. The wave in the hall exceeded my expectations. The reaction, however, was not only positive. My professor “stuck” me with a score of 0.7 points lower, considering this decision “dirty in the programming world” and the rest of the professors could not convince him. The solution was very simple: I deleted almost all the math and replaced it with a simple picture, just reading the color under my arm ...

Happy end


I developed chess further for a long time (tests showing the position on the board, playing on the network, showed at the school on "multimedia parties"), I even wanted to patent and talked with a lawyer. By the way, “I take this opportunity to say hello to my brother” (a stolen phrase from the radio) for drawing what you see in 3D. For those who are interested, the source code can write to me, maybe I will dig it out somewhere on a CD that has been lying for years, and maybe you can do something more with this code than I did. It would be nice to see "dusting chess" a few steps higher compared to the "initial" steps, where they have lingered for quite some time ...

Ps: layer for the third presentation of chess can be seen here:www.hdm-stuttgart.de/multimedial/medianight/archiv_ss_06/medianightprojekt20060421141924/projektview

Pps: Owners of stereo glasses can enjoy this miracle in 3D.

chess for three 3D stereo

Also popular now: