Tuesday, September 29, 2009

Portable Ubuntu - best of both worlds

In my day by day work I use Windows. Sometimes though, would be great to have also linux.

There are different solutions to achieve this.

  • install as a second operating system and choose one at boot
  • use some virtualization technique (VMware, Vbox, ... others) and run both 
  • use xwindow client or putty to connect to standalone machine with linux
  • use cygwin
  • use MinGW + Msys
  • run Linux under Windows
Depends on whatever you need.

Monday, September 28, 2009

Vector - upgrade

First of all, I realized two things.
One could lead to undefined behaviour and second definitely could lead to undefined behaviour.
It is all about wide known and liked freeing memory without setting variable to null.

Friday, September 25, 2009

Vector - functions like methods

I would like to show different approach to providing methods to the users. Please note that it is only refactoring, functionality remains exactly the same.

So what it is all about? Simple.
Instead of doing this:
vector$getLength(my_v);
one can do that:
my_v->getLength(my_v);
Beside the fact that this is probably more convenient notation, methods will not interfere with those in different modules as user can access them only from object reference. Furthermore, user is able to replace any method with his own in particular object. While it is quite powerful it is not the case (I think) it would be wise to do so.

Vector upgrade

I have fixed some bugs, add a lot stuff and there it is - new version of vector module.

Thursday, September 24, 2009

My bug with printf - who'd help?

There is such code:

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

int main() {
 int a;
 a = 5;
 int *b = &a;
 long long c = 2;
 printf("C = %lld, A = %d and I expected %d\n", c, *b);
}
And a result is as below:

C = 2, A = 0 and I expected 5

I have experimented a bit but did not found correct format.
Anyone?

Wednesday, September 23, 2009

How to make c more comfortable part 1


This is first part about c language. I would like to provide useful tools which could make a coder's life much easier.

At first I would like to bring you round to use my Vector class-like library instead of regular c arrays as it provides much more flexibility and safety.

Saturday, August 15, 2009

ZUMAjs

Link
http://www.swietochlowice.org/%7Emierzwm/zuma/index.html


The reason

This time I wanted to take a challenge of making more dynamic game in javascript.. The choice was Zuma. Zuma is a very nice and absorbing game. It is good to relax and free your mind when it is overcrowded by thoughts.

So there is my solution: ZumaJS

And you can also checkout others made in Flash:

http://game.zylom.com/servlet/Entry?g=3013&s=2576&nocache=1253559336508
http://www.gry.pl/gra/Honey_Trouble.html

Technical info
 Thread-like behavior.
Although js does not provide multithreading you can fake it behavior by spawning comparatively short pieces of code in intervals. It does not take advantage of 4-core processor though (unless you use Google gears and task workers). So instead of putting all in main big loop I have decided to give "free will" to every object. It means that every orb and cannon are separated objects which decide of themselves and know only their neighbours. Every object runs in a separated "faked thread".

How to rotate:
For rotating a canon I decided that the most comfortable way would be to use canvas. Of course, there is snag - IE does not support canvas but there comes salvation called excanvas

What's more?
Paths are composed of Bezier Curves and all this stuff is created using great mootools framework. It is lightweight, it is powerful and it provides way of coding which js ought to support natively.

Sum up
I am afraid that javascript manipulation on DOM is slow and it can be difficult to develop more complex games.Moreover, it seems that the best way to deal with sound in javascript is to use Flash wrapper... Still javascript and web technologies is more and more popular so it will definitely  improve its lacks. Due to fact that development time is very easy and quick it will spread to be not only browser (and second important server side) language, but also to provide stand alone applications like Adobe AIR (and Google seems to head in the same direction).

Monday, March 30, 2009

Tic Tac Toe 4x4x4 made in javascript

Link
http://www.swietochlowice.org/~mierzwm/ttt3d/index.html



The reason
When I was a schoolboy we were often playing TicTacToe 4x4x4 with friend of mine. It can be pretty difficult game where you have to foresee next moves exactly as in game of chess. So I had a while and I searched Internet to find such game to give a trial to my skills and of course - have fun. One of them did not run because incorrect Java VM version, second was playing too schematically because programmer simply included a lot of tables with best moves and one was just terribly ugly. At least I have found one that played pretty strong but it still lacked in interface. At this point I thought to myself “For God's sake! It can be done better!”. So to not to be one that does not practice what he preaches I have decided to provide my own solution.

And there it is, you can see it there and come around if I succeeded in achieving initial assumptions. Try to beat machine, it is not very easy but possible.

Technical info
I have decided to develop it in javascript. Why? Maybe to show that such things can be done without installing plugins to webbrowsers, and maybe because in javascript I have much more control over space that is provided by webbrowser.
I have also developed few auxiliary libraries, that helped me to provide convenient interface. Including movable windows, hint clouds, lazy script & image loader etc. I also used great library ( slightly adjusted) that comes from Lutz Tautenhahn http://www.lutanho.net/svgvml3d/index.html which provide uniform way to handle both VML and SVG and aid to put 3D elements.
It is pure javascript and was tested with all comparatively new versions of most popular webbrowsers, it is IE 7,8, FF 3.x, Opera 10, Google Chrome. For AI I have implemented modified MiniMax with alfa-beta pruning algorithm  and set up depth of thinking to 4 half-moves, which was enough to beat all others TTT 4x4x4 implementations I have found in the net and tie with one the strongest.

Sum up
Javascript has growed from auxilary "page modification" language to being fully capable to implement applications and it can in some cases do better then Flash or Java. What would be very, very nice is to be able develop multithread apps (deep pondering at the background).
We can also compare speeds of different implementations of js run time machine. As we could expect Trident is the slowest one the rest is much more faster and Webkit seems to be the fastest over Gecko and Presto.

Monday, February 23, 2009

Nowe błoto czyli MUD

Jakoś się tak porobiło, że ostatecznie rozstałem się z Killerem. Po krótkim okresie nic-nierobienia i kolejnej dyskusji z Magiusem nt co gdzie robią źle, co dobrze, co można by zmienić, palnąłem: To zrób własnego MUD'a. Tutaj krótkie wyjaśnienie MUD czyli potocznie błoto, a w szczególe Multi User Dungeon to komputerowa, sieciowa gra tekstowa, w której wielu ludzi naraz może się wcielać w swoje postaci i szukać przygód (MUD w Wikipedii). Zrób własnego muda skończyło się, że robimy własnego muda, a to w dużej mierze oznacza, że ja robię muda bo Magius kodować nie potrafi. Sprawy idą nienajgorzej, roboty od groma (sama baza kodowa to kilka tysięcy plików). Znaleźli się ludzie, którzy zadeklarowali pomoc (oczywiście ogromna większość tych deklaracji pozostała deklaracjami) i jakoś robimy. Adres naszej stronki i bloga to http://www.caw-mud.net.