# Tiled map generation now working

Working on my RTS game, and I now have a working tile based map.  It has working random generation, and a working A* pathfinder. Also has a working minimap.

The previous images show the minimap and map view zoomed at two different sizes.

The following image shows the visualization of the A* algorithm in action. for debug purposes each iteration of the algorithm is slowed down and the open set and closed set visualized as red and cyan tiles. The current node is depicted as the white tile.  The red tile not attached to the blob is the goal node. The start node was the highest point inside the gray rock formation.

The following is the final path from the above visualized run.

The following is several paths generated on the same map.  The two in the middle around the center rock position are so different because the path-finder was set to require 3 tile clearance for the top path, and therefore could not go through the gap the other path did.

# Been a while, Working on something new.

It’s been several month since I’ve posted anything, been working at Waldbaums, so I haven’t been doing much except that, and killing time with Cracked.com, Reddit, College Humor, and XKCD.

Then I had an idea for a simulation game, in which the temperature of the building would effect agent happiness. So I did a prototype in order to find a good way of representing heat flow, that would look “realistic” enough for a game, but still be fast enough to do in real time.  What I came up with is not really physically accurate, but it looks nice and behaves in a way people probably expect.

It essentially works by splitting the world into discreet tiles, each with a specific heat capacity and temperature.  Every step the average of the temperatures around a cell weighted by the specific heat capacity is taken to be the new heat of the cell.  In the case of a heating or cooling element (which can have any temperature) the new heat will always be the heat that the element is set to, but the average heat is used to determine how much energy the heating element requires.  the following are annotated screenshots of this prototype.

# Map Generation

Working on a RTS-like/City Sim-like game and working on getting a large map for it. My plan is that the game be tile based and completely procedurally generated. Working with some Simplex Noise, I’ve generated what I hope will be a the starting point of my levels, but I need to work on the scale. The generated images here have no scale, but they appear as though they would be in the scale of several (possibly hundred) square miles or km, which is impractical.  The goal is to have a tile equal about half a meter or 1.6 feet, about the width of a person.  That makes path finding and collision avoidance/detection easier.  My plan is also to make one pixel in the map correspond to one tile, this poses the problem that the below images would be 200 meters for most, the tiled ones were generated as 400×400 px, and the largest image would still only be half a km, at 1000×1000 px.  At the moment my noise is normalized to always contain [0,1] so it always looks similar, scale changes do make it look better, but even I try to get it to generated square at a much more detailed scale it still has large patches of ‘desert’ near water because of the way the noise is mapped to land, still thinking of a way to deal with this. I am thinking generating the noise for a larger area and using that to normalize a smaller actually used area.

This one is to show the way the tiles will hopefully look.

UPDATE: I’ve been tinkering and I got the following image for different levels of zoom, the left-most image is the landscape I’m thinking will be a mile or km width/height.  each set of images is scaled by two.

# Fluid-Based game progress

Well, I’ve been working on the idea of a Minecraft-like game (infinite procedurally generated world, with resource gathering and building) but instead of semi-fixed Voxel-based, I want to use fixed-size particles in full Smoothed Particle Hydrodynamics simulation, including heat transmission.  The idea is to create a world where you can shatter a chunk of the rock off with a tool to pick up, or create a heat source large enough to melt the rock, and gather the liquid.

This is obviously a very difficult proposition for many reasons, but mostly speed, as well as the problem of getting a good simulation of melting/freezing, the papers I’ve found that mention it don’t go into detail enough to implement. I’ve toyed with three versions of a simulator so far, but none of them are fast enough to do a full world with. And only one would support what I want to do right now, the slowest.

These are two screenshots of the original full simulation:

These shows two fluids, the pinker is denser and also more viscus and elastic. This simulation works nicely but is quite slow <250 particles runs at 4FPS as shown. It uses springs for the boundary conditions. The next two are another version of the same simulation.  It does not use full SPH and simply uses springs to prevent penetration:

This one has the same parameters except the boundary conditions are different, they are still springs, but there seems to be a bug in my implementation where there is a new boundary that keeps forcing the particles down. This however is much faster with nearly 500 particles running at 5FPS, about double the original, but it would require more work and code to get melting/freezing/solids and thus would slow down the code probably to the same as the original.

All those above used LWJGL for rendering.

This last one is done with JME3 to render and it’s built in JBullet library to do the physics, this has many drawbacks, density won’t cause a fluid to float on another, and melting/freezing and solids built of particles become problematic.

Because it uses JME3 the particles->FPS isn’t quite as obvious because it is showing ‘objects’ which is not the same thing.

This is one of the slowest projects I’m working on, because I keep putting it on the back-burner for other things that are more likely to be possible.  I’m thinking I should do it in C++ for speed, but I really prefer java.  I’ll probably keep working with the original, or second one, just to get a tech demo, albeit slow, that works.

# Web project progress is very slow.

Got some stuff added, the log-in screen is working, but the log-in servlet isn’t, it’s got something to do with the ajax parameter passing not working in POST, need to figure it out or swap it to GET.  Still no progress on getting the projection to work better for the graph.

# Web based pet-project

I’ve been working on this for quite some time, it’s been a pet project of mine since I finished my last web-based school project.  My goal is to turn it into a fully fledged school/homework help forum, but for now it’s an online calculator and graphing app with a toy BBCode editor.  I have some screenshots, but no running server to actually let anyone play with it.
These few are from the original incarnation:

The original incarnation also had the parse tree image included for debug purposes. It is in the following image:

That image uses the leaflet.js library for rendering of the graph, this works much smoother than anything I could have rolled on my own.  There is a current problem with the zooming with leaflet, I need to work out a good way to map the tile coordinates in x y and zoom that it generates to the 2D plane. It may require either editing the javascript to change the projection it uses or my image servlets to change how they process the tile coordinates, either way the math it what’s stumbling me.

On a different note, the BBCode translation works fairly well, though needs a tweak on how it treats whitespace. the following two images show the test that I have working, it auto-updates when the text area is chaned.

The last three (other than the img tag) are the main reasons I have rolled my own, they use the parser to generate MathML, and evaluate expressions.  The parser I used was written in Java, using a library from the book Building Parsers With Java by Steve Metsker.  I worked off the books Arithmetic Parser chapter and classes, and edited it heavily to change it from directly calculating values, to generating a re-usable parse tree, added the ability to store and use variable names, recognize graphs and recognize mathematical functions such as sine, cosine, tangent, logarithms, etc.

I have some of the forum related code in place, it’s a matter of generating test data (forums, threads, users), and getting the code to access and display it all, so far it only displays one or two of the approximately 8-10 different things.

# Updated my old site to link to this blog.

During my job search on Stony Brooks career site, I realized that in the list of references I could include this blog as a current indication of what I’m up to as well as a link to the few Google Code projects that were used as repositories for my school projects.

While doing so I realized that a google search of my e-mail, or my full name would be likely to turn up a google site I made about 5 years ago, that while demonstrating my love for programming was also quite juvenile, as only a male high school senior could be.  I have spent about an hour going through it and updating it. I did not update it to remove anything, but I added a disclaimer to the top of every page that it was indeed old, and does not represent my current views or the current quality of my new work. Most of the projects there were key in my teaching myself java, however they were made before my formal education in software design, and as such are dreadful to wade through the code in present day.

# Some noise tests

Not quite halfway done with that paper I mentioned earlier but decided a distraction was in order.

This is a project I’ve been toying with on and of for a long time.  I started toying with Perlin Noise because I hope to create a fully procedural game.  The noise would be useful for textures mainly but also landscapes and other various things.  So I made this program to play with how the noise behaves with different inputs. While doing so I found out  Simplex Noise is less expensive to compute so that is what this currently uses.

Feel free to play around with it, ask questions, I don’t care if you use it to make textures for yourself but I’d like recognition if you do. I’m going to open this to public comments so questions and comments can be asked and posted.

The in program help should be useful, but it doesn’t cover the gradient editor (far right in first screenshot). This is mainly because I got tired of writing help. If I get enough requests I’ll fix it.

My planned next evolution is to figure out how to make it generate tile-able noise as well as continuous noise.

 This is a screenshot of all the pieces
 This is a screenshot that has a more useful image, picture it as a height map of an environment where the blue would be water and white is top of mountains

These are other images produced by the program

 This could be a heat map of some kind, or a region map possibly red being desert green could be forest, blue water, and yellow deserted islands
 This is another like the above, but shows a more complicated landscape