I saw this video, and I am really curious how it was performed. Does anyone have any ideas? My intuition is that he scraped pixels from the screen (one per 'box'), and then fed that into some program to determine the next move.
Is scraping pixel-by-pixel the way to do this, or is there a better way? I am looking to do something similar with either Java or Python.
Thanks
Probably that's the most reliable way. There are ways to inspect what is happening inside a process - looking directly at its internal state and memory - but they are platform-specific and very prone to misbehaving because your dealing with a slightly different version of something - that includes a different flash version as well as a different version of the app. Those methods are more often used for "trainers" for exe games, where there's typically only one or two versions of the executable to worry about.
Lots of screen shots, comparing, figuring out reliable indicator pixels seems the way to go - plus keeping track of what you expect to happen, of course. When the app is running, it should work from a screenshot at a time (hopefully ensuring a consistent picture, with no half-updated views) and then test the minimum number of pixels needed using (perhaps) a decision tree.
There are ways to automate construction of efficient decision trees, but it's probably easier to do it manually based on comparing screen shots. In this case, since Tetris normally creates all new pieces at the same position, with a 1:1 relationship between colour and shape, you can probably determine the shape and position of a new piece from a single pixel colour - so "decision tree" is probably the wrong term, really, in this case - though there are other things the bot needs to read from the screen.
What's more interesting is the logic to actually make gameplay decisions, since that bot clearly isn't just slotting every piece into the most immediately obvious position, but deliberately aiming to create opportunities to clear 3 or 4 rows at a time.
Yes, i think he scanned the pixels. Actually it should be very simple because you only need to scan the new shape for each move. With that information you can locally calculate the grid and further use it for your AI calculations.
Related
To clarify, I know why my game is running slow. I have a lot of different objects in the current area and it has to tick and render all of those objects. I just don't know how to fix the problem without just making less objects.
The answer I am looking for is more of a concept of how I can go about fixing this problem rather than just making a bunch of code for me to paste into my game.
I am designing my games based off of tutorials by RealTutsGML. There where some issues I had to work around with his method of building games, but I figured them out.
So every tick in my game, I have to look through all of the objects that currently exist. The more objects that exist, the longer it takes to process all of them. I need to find a way to help free up memory if those objects are currently not in view, for example. I know games like Minecraft use chunks to free up unused memory. (Blocks outside of the view distance are not generated) What can I do to allow for an environment with many objects without causing so much lag? I want to be able to have a big level without having so much lag from all the objects that have to be ticked and rendered.
Another thing that I will clarify is that all of the objects loaded into the levels are held in a LinkedList so that I can easily create and destroy objects. Every tick, I run a for loop through those linked lists to process every objects behavior and how they are rendered.
[EDIT APRIL 28]
The objects in the game I was working on are organized in a very grid-like format. So that includes the tiles, the player, and all of the other game objects.
You haven't given too much information about your game (I'm not going to look through the tutorial either). You may want to give more background information, and maybe some code snippets.
I know one thing about your code with certainty: you are using linked lists. Linked lists, especially when you add and remove things from the middle, are slow. The reason for this is memory (or cache) locality. When they say computers are growing exponentially faster, they meant the processor is. Your data needs to be transported from its home in memory to another location to a place where it can be used. When data is needed, it is transported by a bus, which also brings neighboring data. (Note that "bus" is actually the technical name for the component.) Linked lists, especially how you're using them, manipulate data in a way that destroys neighborhoods of data. As a result, the bus essentially becomes a "taxi", getting data one at a time. And the bus, according to the graph, is a stunning 10x faster than the computers of the 1980's (remember, the graph has an exponential scale).
Also, it seems to me like you probably don't need to tick EVERY object EVERY frame. Yes some objects, like mobs, will need to tick every frame (if they are close enough to be active). From what I assume your game looks like, you have each block of grass being its own object and ticking every frame. Stop watching the grass grow.
MineCraft, for example, will only tick sand blocks when a neighboring block changes (which is why sand generated in the air will only fall when disturbed).
You may want to check these pages out:
Question about memory locality.
Question about linked lists and memory locality
Site explaining cache locality, and source of picture.
Question about slow graphics loop.
Code Review is a good place to get feedback on your code.
Game Development will give more game-based answers.
In an organized environment like such, I think it would be very obvious that making chunks(holds tiles/game objects) and mega-chunks(holds chunks, chunks were still running slow) would be a clear solution especially in an organized environment like this. Like someone on here said, clearly not everything needs to be processed at once and not even exist all at once.
Here is how I see chunks being useful.
I tried this, but didn't see much of a difference, so I am going to try making chunks to hold chunks and hopefully that will help.
First let me quickly tell what I am trying. I am doing tetris-like game using Box2D, I know Box2D is maybe not the best option in this case, but I really need to have normal physics also because the levels have obstacles and if you hit them blocks are supposed to rotate.
Here is image to demonstrate what I mean.
Case 1:
This is how I want it to be.
Case 2:
This was one of my ideas, just to make the block size of falling piece little bit smaller so they fit nicely into the empty space. As expected problem with this was the empty space around the block. Making it look like box doesn't belong there.
Case 3:
Keeping the block size of falling piece same as "wall" block size it never makes it to the empty space, because edges collide and it stays like that.
so how can I make it fit in empty space filling it and without looking weird?
EDIT: If I make size of the falling object smaller it wont work in this case:
And here is image to demonstrate what kind of behavior I want:
1) Use setFixedRotation(true) on your body.
2) Make it little smaller than available space (from both sides). Make the difference so small that effect would be invisible (yet it will be sufficient for box2d).
This should fix your problem.
Edges won't touch, but if necessary you can try removing friction as well.
Note:
Using a physics engine might be an overkill in your use case, but it is not a that bad idea since you won't have to do much if you use it properly.
Good luck.
Update:
1) Don't make objects small. Make them thin. :)
This should solve your first problem.
2) If you want behavior shown in next case, you are expecting free rotation while falling + correct orientation when touching ground. These two things inherently contradict each other.
I would suggest to rethink your strategy. But still if you are determined to do it the same way, there are some weird ways to achieve it (nothing is impossible, right?).
The one I could think of right now is implementing a tendency of all objects to go to nearest right orientation all the time (external moment as a function of current orientation). It should be updated in render. It is effectively a control system, but there is no guarantee that the orientation would be achieved by the time it is going to collide and the physics won't look natural too. Just try to expand your imagination and have fun. I would certainly like to see it if you find out a better way.
Enjoy.
I would like to implement a visualisation of this video in Java as experience to help me understand all of the 'troubles' in creating visualisations. I have some experience in OpenGL, and a good understanding of how to handle the physics involved. However, if anybody knows of any good game engines that may help (or at least do some of the heavy lifting involved in creating a visualisation of the above) I would be grateful.
Also, I noticed that the linked video must use many separate jets in order to operate in the way it does. Is it likely that it was created using something a little lower level such as C? Is it possible to use a higher level language like Java to control such a system?
Honestly, if you want to implement "just that", I think using a game engine is overkill. Just implement a simple particle engine on your own and you are done.
Seriously, that problem is not so difficult, any language can be used for it. The basic principle behind it is the same as behind steam organs or self player pianos. You have an input data that shows what the pattern to play is and you advance it in a given time.
Here is how I would build the basic control system. You take a black and white image. The width is exactly as wide as the number of "emitters" and the length is as long as the pattern needs to be. You read the image and start at the first line. You walk through each pixel in that line and if the pixel is black you emit a drop and if the pixel is white you don't. You then move in a given interval (maybe 25ms) to the next line and set the emitters accordingly.
The cool thing with images is that you can simply paint them in any graphic program. To get the current time to work you render the time into a image buffer in memory, then pass that into the above code. (You even get fonts if you like...)
You can use jMonkeyEngine.
JAVA OPEN GL GAME ENGINE
I'm working on a sketch search engine that correlates whatever someone's sketching with a picture in the database (the db is just about 40 pictures now). I'm doing this mostly for fun so I'm not that well-versed in computer imaging techniques.
First of all, are there any rules of thumb on how one should create histograms (bin sizes, ranges, etc)? I'm using some histogram code found at http://www.scribd.com/doc/6194304/Histograms (but ported to JavaCV). Sometimes I get good results, sometimes I get bad results, most of the time I get "meh" results. I've been experimenting a TON with bin sizes and ranges and I'm wondering if comparing higher dimensional histograms may be the answer here.
Second of all, it seems that black makes a very strong presence in my current histogram setup (even a black dot shifts the entire result set). Should this be expected? Or did I screw something up? Example:
And after the dot:
Note how I'm already getting pictures of "earthrise" as "close" matches.
I'm also wondering what methods I should use for blob or feature analysis. I think that stuff like SURF may be overkill because I only want to broadly compare blobs, not accurately map templates. Is there any way I can compare the edges after being passed through a Canny filter? (Low complexity if possible):
For example, here, I want the two smiley faces to be at the top because the needle smiley "blob" is more closely related to the smily face shape than to a bunch of passion fruit or a galaxy.
Phew long question. If you want to try out the engine for yourself, go to http://skrch.dvt.name/ (shameless plug, I know, I know -- only works in FF/Chrome/Safari). Maybe more experienced computer vision people can make suggestions based on results. Oh, I'm using the CV_COMP_BHATTACHARYYA distance when comparing histograms (it seemed that it gave the best results although chi-square isn't bad either).
Is there a background ?
IS it significant ?
Maybe you need to look at whether there is a user-supplied background or not.
then you "just" need to have 2 histogram per db entry, one with bg, one without.
That'll stop earthrise looking like an apple with a dot.
for basic bg separation, try a canny, then taking "outside" and removing it from a copy of the original.
We think there are potentially a number of technologies that might work for us - Java3D, Google Sketchup, JavaFX or gaming framework, and probably many we're not familiar with.
We're getting ready to build an app that will need to be able to display large numbers of simple objects in three dimensions. Say, a couple thousand wireframe boxes, and allow us to pan, rotate and zoom easily and smoothly. We're primarily a java shop, so a java solution would probably be preferred over other technologies, just because that's what we're strong in.
We want drag&drop and object resizing with the mouse. We also want to re-position the boxes or other objects based on event feeds from an external application. So, we might want to re-position hundreds of the boxes a few times a second.
What technologies can actually get this done?
Our legacy app does this with Java 3D, but we'd like to consider what's suitable for the next generation version.
We like something that's a littler higher-level than Java3d.
Edit: In the end, we used jMonkeyEngine, and that did the trick for us.
A few thousand wire-frame boxes can be rendered at many frames per second with just about anything. Using 3d hardware acceleration, these could also be rendered as solid in a z-buffer at completely interactive frame rates. I don't think the image you describe is going to help in making the decision. Pick something that's easy to use.