What can be used as a heuristic for Bubblet game? - heuristics

I am planning to make a Bubblet game in Java, because I simply love the game.
What can be used as a heuristic for the game?
I will make it 30x30 or bigger, and I cannot figure out how to make the computer play the game efficiently...
Can you suggest some idea? Thanks

I'd try a combination of dynamic programming and parallel programming:
For each dot, hold a score, count itself and the scores of the 4-connected neighbors before it (up and left) (that are already available due to the dynamic programming).
This can be done in parallel in a diagonal line of progress, thus improving performance.

Related

How to make a Self-Improving Tic Tac Toe Mega (10x10 board) game

I made a Tic Tac Toe (10x10 board size) bot. It plays better than an average human.
The board size is 10x10 instead of 3x3. 5 in a row O's or X's must be placed to win, instead of 3.
So, I made that bot using Minimax + Board Evaluation Function + Limited Available Moves to improve performance.
Let me explain my code.
First, I used Minimax algorithm alone but realized that. There are around 100 possible states after making first move, 100*99 after making second move, 100*99*98 after making 3rd move.
And it is probably impossible to count all possible board states.
So, What I did was created a board evaluation function.
I set some rules for board evaluation function, and it is same, no matter how many games the Bot play.
But I want to make a board evaluation function, that improves itself or give me some data, that I can use it to improve it. I cannot think of any way in Tic Tac Toe, can you guys?
Thanks
One method of doing this would be to generate statistics on board states. Create a board hash function that's 1:1 with effective board states, and populate a dictionary of moves taken. Record wins/losses for each move in each board state, and apply a weight to the move selection based on the win% of a given option.
This is memory intensive, but you can improve that by a factor of 8 by using a hash that's invariant on board rotation and mirroring (trivially, you could hash all 8 rotations and flips of the current state, and always return the minimum, for example; there might be a less brute force option.)
An additional improvement is to not record moves for any games which you are guaranteed to win/lose in your look ahead window, though that's a smaller percentage improvement.

How can I choose the features my q-learning with linear function approximation

I am developing AI using reinforcement-learning.
It is a game that player should avoid bricks falling from sky.
There are 20 bricks falling to the ground.
game screen shot , game play video link
I implemented AI using reinforcement-learning with linear function.
It was hard to choose the best features to get satisfied result.
Anyway it ended up getting best score ever since I tried to make it.
But It's quite weird.
There are some reasons.
It reached convergence very quickly around 10 training.
I just used 6 features.
I couldn't get better score through training more times. (Like I wanted my ai to play like super player. It didn't seem like it though.)
Meanwhile, I tried to use lots of features. I defined features as game screen size(960 * 640).
And I fill those features where brick's relative coordinates from player. I hoped that can make better result than previous one. I trained this method for 7 hours but It didn't work out.
The bottom line is How should I choose the features to make it work best or Is there any different approach to solve it?

Is there a more accurate way to detect ball to ball collisions with Sphero API?

I'm writing a game for sphero, the robotic ball (having issues with their forums, can't seem to ask a question). I'm trying to do ball to ball collision detection for 2 or more players.
first of all the they give a sample here:
https://github.com/orbotix/Sphero-iOS-SDK/tree/master/samples/CollisionDetection
The thresholds they supply are WAY too sensitive, on a wooden floor it triggers all the time. Forgetting that for the minute, I have to use the impact timestamp from both devices to see if they have triggered collisions at roughly the same time.
My issue is when subtracting timestamps, in some cases i'm getting very wide variations and i think the difference is quite long to begin with. I'm storing several timestamps so I don't miss the correct one and I tried playing with the dead time to see if lowering it would help.
Most commonly subtracting 2 NSTimeIntervals i get a difference between 0.68 and 0.72 (I would have expected 0.01 level reactions). So Im checking if the difference is under 0.72, 3 times in a row i got between 0.72 and 0.73, several times I got 1.5, 2.6, 1.1 and even 3.8.
It doesn't seem as though its reliable. The documentation says this time comes from the iPhones reference. Both devices are synced to get time automatically, so they are as close to each other as possible.
Has anyone tried this and come up with a reliable solution, that doesn't involve keeping one ball still ?
I did a significant amount of research on the subject of ball to ball collisions when I started as a developer for Orbotix, the makers of Sphero.
This is a very complicated problem to solve. The closest I came to making this work (for a infected zombies research game) was about 80% accuracy for detecting which ball hit which ball with a sample size of 3. The more balls you would put into the game, the lower the accuracy would become. Hence, we decided to eliminate the issue by having one ball required to stop moving before it was vulnerable, like in Sphero TAG.
There are a few factors that limit this capability, and it seems you have discovered them. I believe the biggest issue is that collision detection has poor performance while the ball is driving. Especially on a rough surface or when the ball makes quick jerky movements. This alone causes majors problems when coupled with the dead time.
I was able to get collision timestamps to within 50 ms on average. Are you taking into consideration the wifi latency in transmitting the packets between phones?
The solution is something you probably don't want to hear, but you should tweak your game play to work within the capabilities of collision detection. That is, the ball driving really slow when it can be contacted, or even come to a stop like in TAG. Ask yourself, how can I make this fun without ball to ball collisions?
I just want to say, first, that we are moving our developer support forum here, to StackOverflow, and that's why you can't post on the forums. So, you did the right thing, Simon, by coming to StackOverflow, and you should be proud.
We just changed the forums to redirect here instead of leaving people confused.
The timestamps are generated by Sphero. But they only make sense is you're using the Poll Packet Times command to generate delay and offset values. Please refer to DID 00h, CID 50h in the API commands document.
That being said, collision detection is an ever evolving technology from our end. We employ a cleverly coded DFT frequency transform on a sliding data window real-time inside the robot. The parameters allow tuning to the surface you're running on; there are no universal settings. If you're obtaining too many false positives then please experiment. If you have ideas to improve the algorithm then contact us directly and maybe we can include it as a new filtering method. We're always open to clever ideas!
You could sync the internal timers of each Sphero at the beginning of the game. These can be matched against a synced timer within each host phone. Clocks may be different, but a millisecond is a millisecond. You could also lower the threshold of the collision detection, thus making it so that the 'event' (damage, infection, etc.) can only occur if the 'attacking' Sphero is moving at a certain speed. Or a variation thereof.

Graphical effects like elastic tentacles in Contre Jour

I am wondering how beautiful is "Contre jour" game for IOS.
Especially i like elastic "tentacles",shown in this video on 2 min 20 seconds:
http://www.youtube.com/watch?v=ptdTdJarWLw
How can I implement such effects?
I know that there is technic called "Verlet integration" and even implementation of "verlet rope" for drawing ropes in cocos2d, but how to make such nice elastic effects to "tentacle" sprite?
I have experience of box2D usage, and may try to implement physics for this effect, but cann't find a solution how to draw sprite with such elastic morphing.
Can anybody help me or give some hints?
Just even explanation of technics, that can help me?
I have a little of experience in opengl, great cocos2d experience, so I plan to use cocos2d.
Sorry for bad english, I hope, you will understand my problem:)
If you use Box2D, you could try a distance joint with the frequencyHz and dampingRatio options set to non-default values. Perhaps a low frequency of around 4-6, and a damping of around 0.5-0.7 could be a good point to start from. You could think of frequency as how many times per second the joint tries to correct the distance, and damping as how well the distance is corrected each time. Setting the damping to a value lower than 1 will means the joint will be slower to correct the distance, and it will have a springy/rubbery behavior.
As for rendering, you could indeed use verlet integration for this. Take the two anchor points of the distance joint as the endpoints of the 'rope', and put a handful of points (doesn't look like too many would be necessary) in between them in an evenly spaced line. Every timestep, the points in between will simply move towards the average of the two points on either side of themselves. You could make the rope look tighter or looser by adjusting how far the inbetween points move to the target position each time step.
The final texture/sprite rendering would then take its position from the current location of the verlet points.

Collision detect with iterative sampling - should I use an engine (box2d) or roll my own?

thanks for taking the time to read my question.
I'm writing a 2d top-down shooter game. It is currently using Box2d as a physics engine. The thing is, it isn't really using Box2d to it's fullest potential, just for collision detection and the underlying velocity/rotation update loop. Any plans to add real physics would simply be eye-candy, not a game changer.
Now I chose Box2d because I went through 2 other physics engines, and they just couldn't handle the types of collisions I'm detecting. I'm creating several 'bullets' with very high velocities, and I do not want them to be instant hits on their targets. JigLib and Flixel both had the same problem - bullets were not overlapping enemies at the time of the frame update, and thus were not detected as collisions (i.e. the bullets passed through enemies because they moved to fast).
I moved to Box2d because of it's iterative collision sampling, as well as the SetAsBullet method on bodies. And it works great! But now Box2d is giving me troubles too - generating several bullets per second, or at the same time, is severely lowering my fps.
So I removed Box2d to confirm that it was not a rendering limitation... added my own velocity/rotation system, and I can fire hundreds of bullets per second. Great! But its lacking any sort of collision detection.
So the questions:
1) Should I write my own iterative collision engine?
2) Should I give Box2d a try again, perhaps with some tweaks to make adding new bodies faster?
3) Is there some other alternative, maybe a lightweight physics engine that specializes in this?
4) Do you know of any other techniques or design patterns that could be of use?
Thanks so much for your help!
Edit: I should note, there are not just bullets, but larger, slower projectiles as well. I considered ray casting a line segment to the projectile's previous position, and catching intersections, but that won't work for the larger objects :(
It depends on how complex your situation can become, If you are good at math and physics you can rollout a fast engine that can handle simple collisions more faster than you can learn using box2d, but why should anyone invent the bycicle if there are plenty of them already invented so choose one you like a try using it, i recommend using box2d

Resources