Phil Freihofner wrote:
Mich Robinson wrote:I would actually love to write this in C just because C would give me a 10x speed increase but sadly no-one would be able to play the program unless they installed it and that is too big a sacrifice.
I presume that is a comment about your skill and knowledge of C programming vs your knowledge of Java programming. Well-formed Java is very fast, quite on a par with C. Certainly it is not 10x slower! From what I have read on this thread, your code is pretty monolithic and could probably perform much better using good Java practices. I recommend checking out the "Cattle Drive" here, for example, as a way to achieve this end.
Unfortunately it became a bit addictive and I've been working on it ever since with varying results so I doubt it qualifies for under 48 hours now! It still looks the same though. I may have the original code from that point though.Phil Freihofner wrote:Very cool that you got the game working so quickly! You might check out Ludum Dare competition, for Java games written within 48 hours.
Minmax really isn't that difficult but sadly a chess program won't do well with only a minmax search as it's way too slow. Alphabeta is a much faster approach as it prunes much of the search tree you need to examine. Next you need to implement iterative deepening so you slowly increase the search depth but keep the score for each move tried then, at the next deeper level, you try the moves in score order. This improves the efficiency of the pruning. Next you need to implement move ordering at all levels - admittedly the scoring here is just a very rough estimate but it still helps. Next you want to continue searching beyond the maximum depth if the position is very volatile - this stops the program thinking it's made a gain after a 6ply search when, if it looked a little deeper, it would have actually lost material. I could go on. When I started this project I had no idea how far game programming had progressed since I first read about it - it's been quite educational for me.Phil Freihofner wrote:Congratulations on getting minmax working! That is no mean feat.
Arcade : Alien Swarm
Board : Chess - Checkers - Connect 4 - Othello
Phil Freihofner wrote:There is a very interesting book on programming: "Dreaming in Code". Worth checking out on multiple levels. (Terrific background history, for example: "the mother of all demos"!)
One take-away for me was that the programmers, some of the best in the industry, working on "Chandler" decided to use Python, but none were particularly versed in its idioms/idiosyncracies. When they finally hired a Python hotshot, several years into the project, he was taken aback at the inefficiencies in the code, and wrote a "famous" blog post about Python not being Java (as the programmers were writing Python code using Java best-practices). He was able to improve much of the code and get huge performance gains.
My take-away is that NOT taking the time to truly learn the language one is working in is like handicapping oneself needlessly. Even "legendary" programmers can be hampered by not learning best practices for the language they are working in.
The debate on programming speed goes on and on. A strong case is made, for example, that modern JIT processing surpasses compiled code in certain situations, and is the basis for Java being comparable to C. I'll leave it at that.
It's fun to play the Ludum Dare entries. You can sample some of them, and other Java games here:
http://www.java-gaming.org/boards/showcase/2/view.html
I have found JGO to be a very helpful forum for game programming, and recommend it highly.
Arcade : Alien Swarm
Board : Chess - Checkers - Connect 4 - Othello
Sorry Phil, I think I was being a bit too defensive. You spend so long with a program that it almost becomes like another child. Interesting to see someone else use FORTH - I remember writing a Forth compiler (actually a threaded language interpreter) for an Acorn Atom computer - it was certainly a very interesting language.Phil Freihofner wrote:I hope you don't take my comments in the wrong way.
Arcade : Alien Swarm
Board : Chess - Checkers - Connect 4 - Othello