Skip to content

Instantly share code, notes, and snippets.

@bgnori
Created May 10, 2012 15:45
Show Gist options
  • Save bgnori/2654031 to your computer and use it in GitHub Desktop.
Save bgnori/2654031 to your computer and use it in GitHub Desktop.
(defn block-categoly
;FIXME, stupid implementation.
;available options:
; :vacant :enterable :combustible
;usage:
; (block-categoly :vacant :enterable) => #{} of vacant and enterable
; (block-categoly :enterable :vacant) => #{} of vacant and enterable
;
[&keys]
(let [c (set keys)
data
[[Material/AIR #{:vacant :enterable}]
[Material/WATER #{:vacant :enterable}] ;flowing
[Material/LAVA #{:vacant :enterable}] ;flowing
[Material/FIRE #{:vacant :enterable}]
[Material/STATIONARY_WATER #{:enterable}] ; not vacant, we can have it.
[Material/STATIONARY_LAVA #{:enterable}] ; may be we need "obtainable" instead of "vacant" or unobtainable.
[Material/WEB #{:combustible :enterable}]
[Material/BROWN_MUSHROOM #{:combustible :enterable}]
[Material/RED_MUSHROOM #{:combustible :enterable}]
[Material/RED_ROSE #{:combustible :enterable}]
[Material/YELLOW_FLOWER #{:combustible :enterable}]
[Material/WHEAT #{:combustible :enterable}]
[Material/PUMPKIN_STEM #{:combustible :enterable}]
[Material/MELON_STEM #{:combustible :enterable}]
[Material/VINE #{:combustible :enterable}]
[Material/GRASS #{:combustible :enterable}]
[Material/DEAD_BUSH #{:combustible :enterable}]
[Material/SUGAR_CANE #{:combustible :enterable}]
[Material/LEAVES #{:combustible}]
[Material/MELON_BLOCK #{:combustible}]
[Material/PUMPKIN #{:combustible}]
[Material/WATER_LILY #{}]
[Material/CACTUS #{}]]
]
(set (take-nth 2
(filter (fn [pair]
(clojure.set/subset? (last pair) keys)) data)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment