I'm writing 2D space shooter game, something like space invaders, kind of. Right now I have to decide in what way
I will be moving enemy sprites and I can't move forward until I will implement some kind of solution.
Newest version of game source code on my GitHub page (link in profile).
OK, so to the point. First of, I'm using only awt. I want to learn a lot, so I'm not using external libraries in this one.
I want to move my aliens on a 1280x800 field with no obstacles (except other aliens and player).
First I tried to move aliens on predesigned path constructed with Bezier curves, but I was unsatisfied with the result.
Solution lacks flexibility. So I decided to write AI for all aliens and program behavior that way. Unfortunately I didn't wrote
any pathfinding algorithm, and when I started learn about them I couldn't find anything appropriate to my situation. There is a
pathfinding algorithm for finding way in graph, but should I treat every pixel as separate node,
or create logical nodes (couple pixels on couple pixels each), and is it a good way?
Don't take me wrong mates, I'm not looking for fast to build, easy solution. I just need some pointing in right direction,
since my research didn't provide me with enough information.
Should I use a Dijkstra? If yes, how to solve node problem? Or maybe there is a better way?
If you know any good web materials on pathfinding or AI, I would be thankful if you share them with me.
Thanks for getting familiar with the issue mates!
Related
I am developing a text based adventure game and I am implementing a small map feature. I am trying to make an algorithm that randomizes a map with results similar the the one below. However, I haven't had much luck getting map shapes to look like this. Does anybody have any solutions?
EDIT: Apologies for poor explanation, I am new to this site. The path shows a top down view of a path in which the player will walk forward, left, right, and back. As far as the generation, I believe I found a solution! The steps I took were to pick two random points in opposing quadrants and then connect, and repeat.
■■■■■■■■■■■■■■■■■■■■
■▣■■■▣■■■■■■▣▣▣▣■■■■
■■▣▣▣▣▣■■■■■■■▣■■■■■
■■■■■■▣▣▣▣▣■■■▣■■■■■
■■■■■■■■■▣■■■■▣■■■■■
■■■■▣▣▣▣▣▣▣▣▣▣▣▣■■■■
■■■■▣■■■▣■■■▣■■■■■■■
(▣ shows a path tile)
Good morning,
I'm working currently on a pathfinding project. Basically, I got this map on my application :
And so I just want to determine the shortest way to go from A to B (of course, I can't go through the blue and gray part which are basically walls...)
Is A* algorithm a good way to start ?
Well if you have any ideas, any suggestions about this problems, tell me ^^
Thank's for your help !
Yes, A* is a good start, assuming you mean to allow movement on the grid only. I mean an agent on a pixel would only travel North, East, South, West and never diagonally. Be warn you will obtain rather un-natural looking paths with 90° and 45° angles everywhere, but this can be mitigated later using some appropriate tie-breaker.
I propose you start using Dijkstra, and once you got that working modify it to implement A* - both algorithms are very close.
If instead you intend to allow your agents to travel diagonally from any pixel to any other pixel which has direct visibility, then no, an other algorithm is needed.
I wanted to make a circle that has a ripple-effect on the edges, kind of like in the game agar.io. I am kind of lost on how to implement it. Obviously I can't just g.fillOval() because that would draw a solid circle with no movement on the edges.
I'm not asking anyone to write any code for me (but if you really want to, I don't mind :D), but if you could point me in the right direction with some methods I should use. I am using Slick-2D library for java, if that helps.
I also tried analyzing the javascript source from the agar.io website to try to understand how they implemented it in javascript, but I was unsuccessful because the code was obfuscated; all the methods and variables were just single letters.
The only way I can imagine doing this currently is to have each circle be composed of a number of points, and let each point have it's own physics, and it can be affected by other points. If anyone who has insight into this problem, I would greatly appreciate some help. Thank you!
I'm not sure you can do this with Slick2D. It is quite high level and gives a lot built-in classes. What you want to do is really specific. As Slick development has stopped you will not get new features. You should probably look at lwjgl which is the base of Slick. It is more low-level but can be more precise with the form you need.
You can look at this project to have some drawing cool stuff. And for another example of manipulating circle you have this one
I've not found anything here or on google. I'm looking for a way to identify shapes (circle, square, triangle and various other shapes) from a image file. Some examples:
You get the general idea. Not sure if BoofCV is the best choice here but it looks like it should be straightforward enough to use, but again I know nothing about it. I've looked at some of the examples and I though before I get in over my head (which is not hard to do some days), I thought I would ask if there is any info out there.
I'm taking a class on Knowledge Based AI solving Ravens Progressive Matrix problems and the final assignment will use strictly visual based images instead of the text files with attributes. We are not being graded on the visual since we only have a few weeks to work on this section of the project and we are encouraged to share this information. SOF has always been my go to source for information and I'm hoping someone out there might have some ideas on where to start with this...
Essentially what I want to do is detect the shapes (?? convert them into 2D geometry) and then make some assumptions about attributes such as size, fill, placement etc, create a text file with these attributes and then using that, send it through my existing code based that I wrote for my other projects to solve the problems.
Any suggestions????
There are a lot of ways you can do it. One way is to find the contour of the shape then fit a polygon to it or a oval. If you git a polygon to it and there are 4 sides with almost equal length then its a square. The contour can be found with binary blobs (my recommendation for the above images) or canny edge.
http://boofcv.org/index.php?title=Example_Fit_Polygon
http://boofcv.org/index.php?title=Example_Fit_Ellipse
I've written a snake game in Java. What I also want to do is to create a demo for that (so snake would play by itself). I've written a simple demo, but snake dies pretty fast. So, is there any algorithms or something for that kind of problem? I believe it is a little bit similar to chess game problem? I want that snake would be alive as long as possible. Thank you.
The Google-sponsored AI Challenge ran a "Tron" game in 2010. You might get some good ideas from searching for solutions to that challenge.
If you just want a very simple strategy that makes a reasonable demo then you might try something like the following:
Never make a move that causes you to crash unless you have no other option
If your next move forces you to choose between two or more distinct (unconnected) spaces, always move into the larger of the two spaces. This will stop your snake from getting trapped too easily.
If you are moving along a wall, keep moving along the wall 98% of the time, following it around to the left or right as needed. This will help your snake look reasonably intelligent, and also conserve space in the playfield.
Otherwise move ahead 90% of the time, turn left and right randomly 5% of the time each (this will make your demo less boring).
Apart from that, I don't think a Chess-style AI approach (with a move search tree) would work very well. You wouldn't be able to easily search enough moves in advance.
This is not the answer you are looking for, but I post it because I would genuinely like to see you explore this algorithm further, modifying it until you find yourself with a pretty reasonable AI:
The simplest algorithm to solve this problem is the "go around the edge, and then squiggle downward" approach. Basically, you start out with a snake, get it so it is moving west, then hug the west wall, then the ceiling. Then you traverse over every possible square like a slinky until you get to the bottom, go west, and start all over again.
If you try, you can turn this into a really excellent AI :D
Without doing the work for you, I can tell you that the best way to start approaching a problem like this is to think about what the snake should do to survive as long as possible. What 'rules of thumb' should the snake follow in order to stay alive. For starters the snake should probably turn before it hits an obstruction, and towards a direction where it won't be boxed in. So, you can program the snake to turn when it is within one space of it's tail (or wall) and towards a direction with the greatest distance between it and other obstructions. Also, snake I believe is a game in which the computer can play perfectly and in your demo you may not want that so you can always throw in some randomness just to spice things up if things get too same-y.