Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: eri0o on Sun 18/08/2019 03:13:47

Title: [PLUGIN] agsfastwfc 0.1.0
Post by: eri0o on Sun 18/08/2019 03:13:47
I recently built a very experimental plugin to test some ideas, the AGS Fast Wave Function Collapse Plugin.

First some images to help explain the possibilities.

(https://raw.githubusercontent.com/ericoporto/agsfastwfc/master/example_demo_game.gif)

(https://raw.githubusercontent.com/ericoporto/agsfastwfc/master/example_img.png)

The plugin right now has only a simple interface like this:

Code (ags) Select
bool AgsFastWFC.Overlapping(
                  int destination, int sprite,
                  int seed,
                  bool periodic_input, bool periodic_output,
                  int N=3, int ground=0)



The algorithm can in some cases fail, depending on the configurations, this is why it returns either a true, for success, or false, for failure.

A GitHub Repository (https://github.com/ericoporto/agsfastwfc) is up to share the code and I added more information there too. You can also download the code as a zip (https://github.com/ericoporto/agsfastwfc/archive/master.zip). If you want to try the demo game, you can also download it for windows (https://github.com/ericoporto/agsfastwfc/releases/download/0.1.0/agsfastwfc_demo_windows.zip) or linux (64-bit only) (https://github.com/ericoporto/agsfastwfc/releases/download/0.1.0/agsfastwfc_demo_linux.tar.xz).

I did only the ags parts and picked the interesting algorithm from a very interesting implementation I found online, which is better explained in the GitHub repo. It's reasonably fast as you can notice when interacting with the demo.
Title: Re: Bitmap generation from a sprite with help of ideas from quantum mechanics
Post by: Kweepa on Sun 18/08/2019 03:33:48
 ??? :exploding brain emoji:
Title: Re: Bitmap generation from a sprite with help of ideas from quantum mechanics
Post by: Matti on Sun 18/08/2019 11:49:49
Interesting! I had fun trying out the demo  :)
Title: Re: Bitmap generation from a sprite with help of ideas from quantum mechanics
Post by: selmiak on Sun 18/08/2019 11:50:17
eri0o got hacked by the AI and is forced to do this now... 8-0
Title: Re: Bitmap generation from a sprite with help of ideas from quantum mechanics
Post by: eri0o on Sun 18/08/2019 13:34:36
Thank you guys for trying it out!

I need to figure out how to pass tilesets, thinking on creating a managed struct to describe each tile and pass an array of tiles but I don't know yet how to read this on the plugin side.

Below a gif of it working from the  algorithm original GitHub page (https://github.com/mxgmn/WaveFunctionCollapse). But the implementation used here is not the original.

(https://camo.githubusercontent.com/dc39c61e02aa67abd0f923628cf241120d14f517/687474703a2f2f692e696d6775722e636f6d2f734e75425653722e676966)
Title: Re: Bitmap generation from a sprite with help of ideas from quantum mechanics
Post by: Retro Wolf on Sun 18/08/2019 19:23:34
Not going to even try to understand how this works, but this stuff is right up my alley!
Title: Re: Bitmap generation from a sprite with help of ideas from quantum mechanics
Post by: eri0o on Thu 22/08/2019 13:49:13
I think it picks a tile of NxN size from the input image and places somewhere on the output image, and then it picks a tile of NxN size from the input image and places it on the output image with one of the borders of the tile being the same pixels (fitting, like with jigsaw pieces), and do this step a ton of times until the image is filled. But the algorithm appears to be optimized to do this blazingly fast (I think you can even hit it on each ags FRAME!) and also I haven't yet got bad outputs (like full black screen for the house example above)
Title: Re: [PLUGIN] agsfastwfc 0.1.0
Post by: Dualnames on Wed 04/09/2019 14:17:54
I'm not sure what this does, it seems to be creating a pattern?
Title: Re: [PLUGIN] agsfastwfc 0.1.0
Post by: eri0o on Wed 04/09/2019 14:45:14
You input a pattern (left) and set the rough size of a square tile, it will then replicate the pattern by matching pixels, overlapping the tiles. I could also support a non-overlapping tile generation - think like old Zelda games. There are more details on the original algorithm page, the difference is the implementation in use here is fast. The animated gif is a visualization, it actually happens in 2ms or less.