NicMcPhee / pseudo-chess-puzzle

An experiment at evolving solutions to a calendar puzzle
MIT License
0 stars 0 forks source link

Get Quil code to run in a browser #10

Open NicMcPhee opened 9 years ago

NicMcPhee commented 9 years ago

I think I may be able to get the existing Clojure/Quil code to run in the browser via ClojureScript. A potentially major downside is that ClojureScript doesn't handle threads (because JS doesn't handle threads), so I'm not sure that this will run well, if it runs at all.

NicMcPhee commented 9 years ago

It wasn't hard to get the code to compile and run, but indeed the threading problem is fatal.

The only interesting thing I had to change in the code itself is to provide an implementation of index-of to replace my use of Java's .indexOf, since that didn't seem to compile properly in ClojureScript land.

The page then loads and displays the board, etc., but nothing ever changes. I think this is because either (a) the search just isn't happening or (b) somehow the search and the GUI aren't interacting well via the atom. There are ClojureScript examples out there with atoms, so I'm pretty sure the search isn't happening because main isn't being called, and I can't call it in something like setup without creating an icky threading problem.

I could "fix" this by bringing the search back into the Quil/GUI code, but that merges concerns in an icky way. I'm suspecting that the "real" fix is to generate a full client/server model, where the search is running on the server, and the client asks the server for updates and displays them. But that's more complicated than I have time for at the moment, so I'm probably going to wander away for now.

Sigh.