Thursday, December 24, 2009

MinMax Pseudocode

As promised here is MinMax Pseudocode/explanation

MinMax Pseudocode

function minMax(board_state,current_depth, maximum_depth,whoseTurn) returns a number
{
    first of all check if the game has ended or maximum depth has been reached.
    if so, then evaluate the board and return a value for its importance.

    otherwise proceed
    {
       generate possible moves on the board
       if there are no possible moves then evaluate the board and return its value
       else proceed
       {
            for every possible move
           {
                    apply "move" depending on whose turn
                    update the localBoard details and state if necessary
                    call minMax again with new localBoard details and current_depth+1 and whoseTurn
                    store the value returned from minMax into a variable local_value
                  
                    check to see if this local_value is better than best value
                    if it is then make assign the best_value = this local_value
                    and also assign the corresponding best_move = this move (it is highlighted in para above)
           }
        }
     }
return bestMove;
}

I hope that is all clear, if you have any doubt ping me. :)

EDIT: all the variables used in this function should be local, if you are using some global variables either store them into local variables or "undomove" after every minMax call.

Wednesday, December 16, 2009

GOOGLe Wave Test




Wednesday, December 9, 2009

MinMax

Last three days I have been struggling and fighting with MinMax, I conquered it finally and made a demo game using it but still there are lot of things to learn in a simple MinMax Algorithm. I will try to explain what it is :

In a normal two-player board games the general scenario involves each of the opponents trying to minimize the others gain and look to maximize their gain. There is no "both win situation"/"co-operative mode", so when making the computer AI for such games, one has to look ahead and choose suitable move that will pay-off in favor of computer. The computer is programmed to look ahead and see all possible moves that can possibly take place from the current scenario and weigh each of the moves, finally choosing the one that will benefit in the long run. What exactly happens is that we make a tree, starting node is the current position of the game and its children basically show the possible next moves that can happen, we weigh each of the node from their children. These algorithms are called MinMax or MiniMax, generally applied to board games like chess, tic-tac-toe, go, zerosum etc.

Apart from normal MinMax there are other algorithms too that help dispense of the moves which will not happen at all. Like take example of chess, there are always so many moves from current position and then if we try to make the tree for all possible next moves and then possible moves from the player, the figure can become too large in matter of depths(levels of children). Alpha-beta pruning is one such method in which those possibly never happening moves or bad choices are discarded early on, so that the computer can spend time working out only the best moves from given position. There is also an algorithm called NegaMax which does exactly the same thing but is a lot faster. I will explain more of this later, possibly with some code and graphs/images to assist. Till then chow!! and keep checking this space. :)

Sunday, December 6, 2009

Project 1

So finally after coming to tiger tail studio, I've got my first project. I will be working on three or four multi-player board games. I already did the design for one of them yesterday, wasn't easy to figure out all the properties and behaviors in one go. Iteration helped get all the objects, their properties and behaviors. After that got into trouble with functions, several functions had multiple objects linkages (meaning they worked on three or four objects but they should start at particular event) and they had to be placed only once, later figured the right places of all the functions. I am not that good at designing. This is the first time ever that I designed before writing down any code, usually I just implement my ideas by coding and then later figure out what all to place where and if the code can be re-adjusted to perform better. I know that in the long run designing phase help, and especially since I have to do multi-player then all should be known beforehand otherwise it would take a lot of time to fix bugs later. Hopefully the design I did would withstand the whole duration of the project and maybe it will help save some time.

Friday, December 4, 2009

Phase

(Yesterday) : The best phase in making a game is coding according to me, the worst part: testing and polishing a game, which actually takes more time than actual coding and all other phases put together.


Just started testing three new games made by co-workers in my company, one of the games is quiet good (something about a war), actually meant for 4 players, it can support up to eight players and four more bots over a simple internet connection. One of them has a lot of bugs(really old game remake), would need to change that. That's the problem with most multiplayer games. Shit happens. Actually it is not until you test the game over internet connection that you would know what all is missing or buggy.


Did I mention that all the three games tested are multi-player!! :D


EDIT (Today) : Testing continued today, and we did all kind of maneuvers on the game, tried to crash them intentionally, and checked of all the aspects, lastly we checked all kind of species against each other.  

Thursday, December 3, 2009

Degration: ActionScript 3 to 2

When I started off with AS2 at that time it looked impressive. Now that I am fluent in AS3, I have been asked to make a game in AS2, seriously looks crap if u come down from AS3. And the code management is pathetic, code is everywhere. Need to unlearn some good stuff, and learn AS2 instead, Baaahhh... :|  


What I really need is AS3 to AS2 converter, so that I can still code in AS3 and the output fla file will be AS2. Anyone know of such a converter?

Monday

From Monday on, I'll be making multiplayer board games, might be 2-3 games in all.

Tuesday, December 1, 2009

New Technique in AS3 by me

I have been developing two of the upcoming technologies and methods that one can use to make more efficient 3d games in racing and FPS. Though all my theory are as yet based on calculations, but they might come in useful. Hoping to get an API made out of this things that I have been doing.

Presentation on new techniques in AS3

Coming Friday, I will give a presentation on new advancements in AS3, the new methodology for newer games and stuff. I hope it goes fine, have a lot of stuff to share.