Skip to content

Instantly share code, notes, and snippets.

View selfsame's full-sized avatar

Joseph Parker selfsame

  • Clover Food Lab
View GitHub Profile

Problem 1 – What an Odd Bunch

Write a dfn that will return the first n odd numbers.

Test cases:

      {your_solution} 5 
1 3 5 7 9
pico-8 cartridge // http://www.pico-8.com
version 8
__lua__
-- todo
-- [ ] fix periodic_output (hack with larger wave/smaller output?)
-- [/] supply output grid to model, propagate to allow constraints
-- [x] remove ground arg
-- [ ] fix failure detection
-- [ ] demo: select input with right/left, z to generate/regenerate,
pico-8 cartridge // http://www.pico-8.com
version 8
__lua__
_ts = {}
function identity(o) return o end
function lerp(a,b,r) return a+(b-a)*r end
function pow(n) return function(v) return v^n end end
pico-8 cartridge // http://www.pico-8.com
version 8
__lua__
-- std fns
function dst(o1,o2)
return sqrt((o1.x-o2.x)^2+(o1.y-o2.y)^2)
end

How easy was it to implement in Unity? (I'm guessing, from the Unity fork you released, that you used C#)

Yes, Exutumno's algorithm is written in C# so it can run in Unity with a few tweaks. I changed the input/output format to use 2D GameObject arrays instead of bitmaps. Most of my work was creating Unity components to let the user configure the WFC output in the editor, without having to write code. There's also a tile painting component to make drawing the input sample easier.

Would the game have been possible without it? Or was there something you would have used as an alternative?

The traditional approach to this sort of output is to hand code algorithms that generate features, and combine them to

InvalidCastException: Cannot cast from source type to destination type.
arcadia/internal/hook_help$require_var_namespacesf__2735__2738.invoke (System.Object , System.Object , System.Object )
clojure/core$fn__41308fn__41313__41318.invoke (System.Object , System.Object )
clojure/core/protocols$iter_reduce__40655.invokeStatic (System.Object , System.Object , System.Object )
clojure/core/protocols$iter_reduce__40655.invoke (System.Object , System.Object , System.Object )
clojure/core/protocols$fn__40718__40723.invokeStatic (System.Object , System.Object , System.Object )
clojure/core/protocols$fn__40718__40723.invoke (System.Object , System.Object , System.Object )
clojure/core/protocols$fn__40577G__40566__40599__40602.invoke (System.Object , System.Object , System.Object )
clojure/core$reduce__41298.invokeStatic (System.Object , System.Object , System.Object )
clojure/core$reduce__41298.invoke (System.Object , System.Object , System.Object )
(ns deftests)
(spit "Assets/test1.clj"
(str "(ns test1)"
(reduce str (for [i (range 3000)]
`(def ~(gensym) [])))))
(aot-namespace "Assets/Arcadia/Compiled" 'test1)
OTD-STUDIO-01+Joe@OTD-STUDIO-01 MINGW64 /c/projects/joe/dev/unity/vanilla/clojure-clr (unity)
$ ./unity-build.sh
XBuild Engine Version 14.0
Mono, Version 4.8.0.0
Copyright (C) 2005-2013 Various Mono authors
Build started 3/22/2017 4:11:24 PM.
__________________________________________________
Project "C:\projects\joe\dev\unity\vanilla\clojure-clr\Clojure\build.proj" (Build target(s)):
Target Build: