Hacker News new | ask | show | jobs
by ijdykeman 1627 days ago
Author here. It's awesome to see my post on hn! Happy to answer questions.
5 comments

This is really cool! Thanks for the article

1) Is it possible that the algorithm will fail to find a suitable tile and needs to restart?

2) I don't understand, why or how you get those rectangular ponds and lava areas in the first youtube video. I expected them to be far more organic or am I missing something?

3) How would do you ensure connectivity of areas or points of interest? Any ideas? Would you path a way before or after running the algorithm?

> Is it possible that the algorithm will fail to find a suitable tile and needs to restart?

Yes, the algorithm can fail. Since it considers only local areas when making decisions, it can easily make a placement that dooms progress later on. The best way to guarantee success in a given amount of compute time is to make tile sets easier to solve, for example by making it possible to transition from any tile to any other in a few hops. But this limits the amount of structure in the output.

> I don't understand, why or how you get those rectangular ponds and lava areas in the first youtube video. I expected them to be far more organic or am I missing something?

It's possible to restrict the tile set so that only rectangular regions are allowed. You do this by creating only convex corners. Here's an example:

Imagine you only have 10 tiles. They are made up of Ground (#) and water (~), and you want rectangular areas of water.

your six tiles are

  ###   ~~~
  ###   ~~~
  ###   ~~~

  #~~  ~~#
  #~~  ~~#
  #~~  ~~#

  ~~~  ###
  ~~~  ~~~
  ###  ~~~

  ### ###
  #~~ ~~#
  #~~ ~~#

  #~~ ~~#
  #~~ ~~#
  ### ###
A valid tiling might be

  #########
  #~~~~~~~#
  #~~~~~~~#
  #~~~~~~~#
  #~~~~~~~#
  #~~~~~~~#
  #~~~~~~~#
  #~~~~~~~#
  #########
The above uses all tiles except the all ground tile.

I can extend that water rectangle in either direction, but I can't add a feature like

  #~~~~#####
  #~~~~#####
  #~~~~#####
  #~~~~#####
  #~~~~~~~~~
  #~~~~~~~~~
Because that bottom center tile that allows the bend in the water does not exist in your tile set. Adding more tiles like

> How would do you ensure connectivity of areas or points of interest? Any ideas? Would you path a way before or after running the algorithm?

Great question! Let's say you have points of interest A and B, sitting on the ground

  ### ###
  #A# #B#
  ### ###
You'll get a world with As and Bs scattered randomly. So let's connect them with a road (+)

  #+# ###
  #A# #B#
  ### #+#
Now you get worlds like

  ##########+#
  #B##B##B##A#
  #+##+##+####
  #+##+##+#### 
  #A##A##A##B# 
  ##########+# 
Repeating forever. But now add more road pieces

  #+# ###
  #A# #B#
  ### #+#

  #+# ###
  #+# +++
  #+# ###

  ### #+#
  #++ ++#
  #+# ###
Now you have roads that slope up and to the right, always starting at A and ending at B.

  ######
  ####B#
  ####+#
  ####+#
  #++++#
  #+####
  #+####
  #+####
  #+####
  #+####
  #A####
  ######

There are no dead ends because no road dead end tiles exist. Eliminating loops in the road while allowing any direction of travel is more complicated but possible.
This looks like a preview of Advent of Code 2022
Came across the post on Google when searching (out of sheer curiosity) for algorithms for generating tiled wallpaper-like patterns (as in real world wallpapers and upholstery).

This was a truly enjoyable read and such a well written article that I immediately thought others here would appreciate it, so thanks for writing it!

On another note https://generateworlds.com/ doesn't support HTTPS. If you need help getting a TLS certificate in place I'd be happy to help.
Thanks! I think I fixed it. Waiting on DNS.
Even more broken now :P
Amazing work.

I'm not a very visually creative person. I want to be able to make virtual worlds but the assets are the problem for me. I think this will help alleviate that issue so thank you. Bought a copy.

(I really want a little RPG about exploring.)

OpenGameArt.org (OGA) has a lot of assets available for gaming [0]. In particular Kenney has loads of 2d and 3d assets that can be used as the basis for a wide array of games [1] [2] [3].

OGA has many Zelda-like tilesets. Some of my favorites: [4], [5], [6], [7], [8], [9], [10]

Also note that there's a FOSS Zelda game engine called Solarus [11].

[0] https://opengameart.org/

[1] https://opengameart.org/users/kenney

[2] https://www.kenney.nl/

[3] https://twitter.com/KenneyNL

[4] https://opengameart.org/content/overhead-action-rpg-forest

[5] https://opengameart.org/content/zelda-like-tilesets-and-spri...

[6] https://opengameart.org/content/16x16-game-assets

[7] https://opengameart.org/content/rp-destiny-sprites-and-tiles...

[8] https://opengameart.org/content/zoria-tileset

[9] https://opengameart.org/content/gameboy-tileset

[10] https://opengameart.org/content/forest-tileset-new-and-old

[11] https://www.solarus-games.org/

Solarus looks utterly amazing. Thank you for directing me to that. LUA, too! So easy!

Thank you :-)

Don’ let that stop you! There are a ton of free assets both for Unity and Unreal. Check out e.g. the free category in the Unreal marketplace.

https://www.unrealengine.com/marketplace/

Search for the RPG category. There are whole RPG systems you can plug into Unreal which you can buy for laughably little money. (No affiliation, I just like what Epic is doing with the engine)

Oh, I know! I have a tonne of assets already. They just all feel disjointed and I'm bad at lighting :P
Did you use an constraint solver library like Z3 under the hood or roll your own?