If-else statements aren’t “go on to the rest”, they’re “if this happens do this, otherwise do that”, and not “if this happens do this, then do that”.
You’re right that switch is faster, but only after a certain number of elements (in C# it is five elements or more) does the switch become optimized into a lookup table or hash list. Any fewer than that and the switch is a glorified if-else-if statement.
Micro-optimizations like these are what they say: micro. Premature optimization is the root of all evil! Work on the big picture, such as not brute forcing your AI to try to find the best result out of computing hundreds of thousands of results.
Even if there is a little performance boost, i don’t think it is noticeable on todays machines.
Also the AI in this game takes a few minutes to calculate the step and this optimization won’t give you more then a few seconds, which won’t be noticeable for a user who wants to play the game.
So IMHO it is better to choose the easiere-to-read-solution.
I updated the website. Now you can find a description how to create your own ai. If someone is interested, that would be cool
A new Version is uploaded too.
I removed several bugs
I “pimped” the demo mode
I added a puzzle mode. In that mode you get a specified start formation and have to score in one turn. The goal is that the player learn to score and see the possibilites
I have a feeling this AI is turning into “that one thing you know you have to do to make your project work but you don’t want to do it now so you’ll just do it at the very end” :point:
Yes and no. I started the ai at the beginning. Now the ai is about 15 to 20 times faster and stronger too. But it is also too slow. I need a strong and fast ai. So I try to make it better from version to version.
Really neat change on chess mechanics. I would recommend the ball being kicked to where i choose to send it. It seems to just teleport there unlike the AI’s kick movement.
I reckon it should technically be [icode]blacks’[/icode] and [icode]whites’[/icode]. But you are right, it does sound racist now that you pointed that out :persecutioncomplex:
Pawns “transform” to Queens when they reach the end of the board
a new options menu where you can choose if white is playing from up to down or down to up
the puzzles will be saved and you see which puzzles you’ve solved (only android version)
a new “pause menu”: when you press the menu button ingame a pause menu will come where you can choose if you want to restart, go to the main menu or go back to the game.
Next step:
I thought it would be easy but it isnt. I have to change more code than I tought, so it will be implemented in the next version.
Shouldn’t the player be able to choose between queen/knight/rook/castle? I reckon changing into a knight could be useful in some very specific situations
You are right. You should be able but in ChessBall I only implement the queentransformation. The reason is I want to load old replays and when the player can choose which figure it should be I had to modify to much code. So I decided that way. But perhaps I found some time to implement and test it.