AutoTile Editor Progress
I managed to get the auto tile editor working much better today!
Just by dragging the floor tile cursor around, I was able to create this layout in a matter of seconds:
The game basically paints the requested tile where the cursor is, figures out all allowed tile types in the surrounding tiles, and paints the best fit for each. The user can change which tile they paint with, and the game will do its best to figure stuff out behind the scenes.
The user can also erase tiles with the right mouse button, and the game will similarly tidy-up around the holes it creates, patching walls and adding corners. The user can also hit the "R" key to have the computer do a sweep of the whole map, cleaning up any issues it finds.
A big part of today's success is the style of the tileset. If you look at the image above, each tile is pretty much filled with one material type. I.e. a tile is either all wall or all floor. There are a few corner pieces that are exceptions, but the tiles are basically "solid."
The more complicated tiles I tried first were sort of "half-and-half" style. One side of the tile might be floor, and the other wall. Basically, take the above tileset, but offset the grid half a tile. I was thinking this would allow for more complex designs, but it didn't really make a huge improvement, and it just made the data that much harder to work with. Not to mention, the auto-tiling didn't work very well in most cases.
Once I got this new simpler tileset working, I decided to try an experiment: special-case tiles. If you look at the left side of the image above, there's a special corner piece that's more sloped than all the others. This is a tile that comes in two parts, and the game seemed to deal with it just fine. I simply had to setup the data such that the tile requires its partner adjacent to it, and the game does the rest.
That said, the data is starting to become a problem. Adding a new tile like this, I had to go through all the existing tiles and adjust their left, right, top, and bottom connection rules to include this tile. This won't be sustainable as the number of tiles grows, so I think I'll need to change the way each tile defines neighbor rules. Probably, I'll just change it from listing explicit tile IDs to instead list tile types. E.g. this tile's right side can connect to any tile with a blank left side, etc.
All of this is the groundwork for building the next step: tiles that act as resources and tools for crew. I want to be able to add things like sleeping berths and food dispensers, so I can further refine the AI simulator. And for that, I'll have to decide if these resources and tools are tiles, or separate objects on top of tiles.
These resources will probably have rules about how they can be placed in surrounding tiles, so on one hand, they're kind of like tiles. On the other hand, at least some will need to move around the ship independent of the ship's structure. And eventually, the crew will have carried equipment anyway, so it's a hill I'll have to climb no matter what.
More on that tomorrow!