Last active
April 9, 2022 19:23
-
-
Save devinrsmith/724c1f2dc5cc0614ee9dacd8ae05457e to your computer and use it in GitHub Desktop.
Script to create r/place uncontested pixels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://deephaven.io | |
from deephaven import agg, parquet, empty_table, merge | |
# Everything pre-whiteout | |
# https://www.reddit.com/r/place/comments/tzboys/the_rplace_parquet_dataset/ | |
place = parquet.read('2022_place_deephaven.parquet')\ | |
.where("k<155926002") | |
# 2000 x 2000 grid | |
all_pixels = empty_table(2000).view(["x1=(short)i"])\ | |
.join(empty_table(2000).view(["y1=(short)i"]), []) | |
# All pixels *not* present in the place table | |
unused_pixels = all_pixels\ | |
.where_not_in(place, ["x1", "y1"]) | |
# All pixels in the place table exactly once | |
one_and_done_pixels = place\ | |
.count_by("count", ["x1", "y1"])\ | |
.where("count == 1")\ | |
.view(["x1", "y1"]) | |
# Light pink background (255, 230, 238) | |
background_img = all_pixels.view(["x=x1", "y=y1", "rgb=16770798"]) | |
# White for unused (255, 255, 255) | |
unused_img = unused_pixels.view(["x=x1", "y=y1", "rgb=16777215"]) | |
# One and done (rgb) | |
one_and_done_img = place\ | |
.where_in(one_and_done_pixels, ["x1", "y1"])\ | |
.view(["x=x1", "y=y1", "rgb"]) | |
# Combine all, ensure unused and one-and-done pixels take precedence over background | |
uncontested_img = merge([background_img, unused_img, one_and_done_img])\ | |
.last_by(["x", "y"]) | |
write_image(uncontested_img, "/data/uncontested.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See output at https://www.reddit.com/r/place/comments/tzz6d9/uncontested_pixels/