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)
Related
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!
So I have a 10x10 grid which contains an enemy and the player, originally positioned at (0,0). The enemy needs to search for the player using dfs. The goal state will be constantly changing as the player will move and then the enemy will follow suit. I'm having problems with some of the tutorials that explain about directed trees and such. This is not suitable for this as the enemy may need to go back to a previously 'visited' square. Also a lot of the tutorials talk about adding connections explicitly in the code. This would be crazy with 100 potential positions?
I'm not looking for a code solution or anything like that, just a clear path to follow would be greatly appreciated.
Thank you
Look into linked nodes. Each one will have 4 node references in it (some of which will be null on the edges of your board), and maybe containsEnemy and containsPlayer booleans.
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 have just started learning basics about Graphics2D class, So far I am able to draw different objects and implements ActionListener to actually move them on screen by onKeyPress. So far so good, While I thought of doing something more complicated. I want to give a path to my object and animate it on that particular path only.
Something like, I will draw a line on sky and a plane should stick with that drawn line and keep it self to fly on that particular line. Now is it possible?
I don't need any sort of code, But few different method or ideas will let me get started working on this. A visualise elaboration of my idea is as below.
Start Point :
End Point :
Now as shown above, my yellow box(in future plane) should stick with given path while animating(path grey line)
My research so far,
I have searched my buzz words such as path in java, and found Path2D and GeneralPath classes, Does anyone know if I can use that to solve this.
Thanks
Great !
It reminds me of my first steps in IT. How much I enjoyed all this simple math stuff but that make things move on screen. :)
What you need is actually a linear interpolation . There are other sorts of interpolation and some api offer a nice encapsulation for the concept but here is the main idea, and you will quite often need this stuff :
you must rewrite your path
y = f (x )
as a function of time :
at time 0 the item will be on start position, at time 1 it will reach the end. And then you increment time (t) as you wish (0.001 every ms for instance).
So here is the formula for a simple linear path :
x = xstart + (xend-xstart) * t
y = ystart + (yend-ystart) * t
when t varies, you object will just move linearly along the path, linearly has speed will be constant on all the path. You could imagine some kind of gravtity attraction at end for instance, this would be modeled by a quadratic acceleration (t^2 instead of t) ...
Regards,
Stephane
First, make the ability to move from point a to point b. This is done with simple algebra.
Second, make the ability to take a path and translate it into points. Then when you're going to do curves, you're really just moving from point to point to point along that curve.
This is the most elementary way to do it and works for most instances.
What your talking about is simple 2D graphics and sprites. If that is all you need then for Java take a look at Java 2D Sprites If your leaning more towards or will eventually go with camera perspectives and wanting to view the animation from diferent angles the go with Java 3D from the OpenSource Java 3D.org. Either way what you want is a simple translating of the object along a line, pretty simple in either 2D or 3D.
You can try going trough the code of my open source college project - LANSim. It's code is available in Code menu. It does similar to what you are trying to do.
My group project at school is to implement a style of monopoly in which students can buy courses and land on various squares and move around the board. This is not a regular square board so we were wondering if anyone had any ideas on how we would implement an image map or something like it to create many clickable regions not in a perfect square. I have attached the image of the game board. Just a way to start is needed, not lots of code or anything as we all know java pretty well. If anyone has any ideas that would be great.
Image of board is here.
Java image maps can have polygonal clickable regions. As usual, Sun has an excellent tutorial.