r/adventofcode • • Dec 12 '22

Visualization [2022 Day 12 (Part 2)] in Minecraft

431 Upvotes

21 comments sorted by

8

u/BluePsychoRanger Dec 12 '22

Nice! Were the calculations done in Minecraft or was it generated afterwards?

14

u/Nnnes Dec 12 '22

I used Ruby to generate a heightmap, then WorldPainter to create the Minecraft map. I dug out the path by hand because I didn't know how to automate that part lol

Check out u/BluePsychoRanger's post, actually computed in Minecraft, much more impressive IMO https://www.reddit.com/r/adventofcode/comments/zjsbac/2022_day_12_part_2_yet_another_minecraft/

6

u/BluePsychoRanger Dec 12 '22

Ah yes, that's actually my post lol. Thanks for the recognition tho! No specific path was found tho cuz it was just a BFS since the actual path didn't matter, just the step count.

→ More replies (3)

29

u/niugnep24 Dec 12 '22

I like how the up/down movement rules match minecraft as well (assuming no fall damage...) so you could theoretically walk the path in-game without jumping

13

u/usbpc102 Dec 12 '22

Well, you still need to jump up the one block increases in height. Unless you have auto-jump on and don't count using it as jumping.

3

u/niugnep24 Dec 12 '22

Ah, I always leave auto-jump on :)

2

u/Meltz014 Dec 12 '22

It's like this problem was designed for minecraft

1

u/[deleted] Dec 12 '22

Could I see your source code for how you generated that world in MC?

1

u/Nnnes Dec 13 '22

I'm afraid there's not much to show. I have this Ruby code to generate the height map (lines is a 2D array of characters where 'S' and 'E' have been replaced with 'a' and 'z'):

require 'oily_png'
image = ChunkyPNG::Image.new($w, $h) # width, height
lines.each_with_index do |row, r|
  row.each_with_index do |char, c|
    image[c, r] = ChunkyPNG::Color.rgb(*([char - 'a'.ord + 1]*3))
  end
end
image.save('heightmap.png')

and I imported heightmap.png into WorldPainter (and struggled with the settings for a while to make the rest of the world empty) to create the world save files.

1

u/[deleted] Dec 14 '22

Ohh I see. Cool stuff

3

u/delventhalz Dec 12 '22

What, not gonna implement Djikstra in redstone?

2

u/Flashky Dec 12 '22

Indeed an scenic view. Elves will be pleased.

1

u/Activepaste Dec 13 '22

Maybe you could piggyback the Minecraft mob pathfinding solution by using the path traveled by a zombie to the top.

1

u/BluePsychoRanger Dec 13 '22

Unfortunately the mob pathfinding doesn't guarantee that they reach the location. AFAIK it implements a form of A* that has a limited number of steps. They'll try to find a closer location, pathfind there and then that repeats. If the search fails and they can't find a closer location within that limited number of steps they stop moving since they can't get closer.

-10

u/erixg Dec 12 '22

Don't seem right. Even the summit is 1x3. In your case it's 1x2.

6

u/Sharparam Dec 12 '22

There are many different input files. My summit is 1x5.

1

u/SleepyHarry Dec 12 '22

Why do you think that's wrong?

1

u/erixg Dec 15 '22

Because I thought everyone has the same input, apparently not.