Posts tagged: javascript

Javascript Reversi

In the last two days I engaged in developing Reversi, just to learn how the minimax algorithm works. To make it easier to share, and remove GUI toolkit dependencies, my approach was using HTML (a simple page with a 8×8 table), three images (empty cell, black or white cells), a CSS file that fills empty cells or used cells, and highlights movement possibilities, and a couple of JavaScript files (jquery, a reversi-board.js file to handle the board as an object, a reversi.js file to handle the interface between the board and the HTML file, and finally a minimax.js file to handle the minimax algorithm.

At the moment the game is playable, and not too slow. The code can be optimized to make it faster. In the next couple of days I might do that.

Also, regarding the AI code, it can be made better. In one side, the minimax algorithm can try to analyze more moves in advance (only three at the moment), in the other, the board evaluation function can be made better as well.

If you wish to play, go ahead:

iFrames and JavaScript fail?

Was trying to create the typical button to “remove frames” from a site, opening the main iframe content in the full window. While it was easy to make the iframe content to change with a simple HTML link and a target property, it is not easy to make the “remove frames” button to work.

I tried a simple JavaScript function that retrieves the ‘src’ property from the ‘iframe’ object and assigns it to the document location. Unfortunately, it seems that both Firefox and Chrome does not update the iframe DOM object with the correct url property when the user clicks in one link that uses the “target” property.

My current solution would be to change the links with target property to JavaScript actions. But that is insane.

Am I doing something wrong? And, this is a bug or a feature?

Google Wave first impressions

google_wave_logoReceived today the invitation to join Google Wave project. Sincerely, I had no idea about what was Google Wave when I asked a friend for the invitation. But Google has nice projects and I like to know them (and use them when I think they can help on my everyday life).

I did not have much time to use digging out Google Wave. Just used it for twenty to thirty minutes. I think it is a nice JavaScript application, in the sense that explores JavaScript, explores asynchronous calls, and real time. But I can not find any other relevant application of it on my everyday life. I do not think it is useful for writing documents cooperatively (it is too much confusion to do so in a thread like approach), I do not think it gets anything new to common forum applications (only the JavaScript thing, probably) and do not think it is better than common IM for user communication. Probably it can be good to record a discussion on some sort of topic, like a forum, but in a faster way. But I am not sure.

For now, I think it is a good way to waste memory and CPU cycles. My Firefox (under Mac) did not like much the experience, and we had just 4 simultaneous users.