7 ms·
Show HN: GoCode.io – A Golang Game in the Browser
- empressplay 7y agoCool, but I can't seem to edit the code using Vivaldi, Chrome, Firefox or Safari (or anything?)
- everdev 7y agoIt requires JavaScript to run. It works for me in all browsers. Try editing the text on the white background. If you still have trouble you can contact me here: https://www.ever.io/ https://www.ever.io/
- palebluedot 7y agoI thought I had the same issue, until I realized that only certain lines are editable. On the initial page, only lines 13-16 allow editing, for instance.
- jxub 7y agoMe neither (and I don't have JS blocked or anything). Still can run the code though.
- everdev 7y agoAre you editing the code on the white background? Only certain sections are editable.
- K0SM0S 7y agoVery cool! I like that you don't actually fix bad code, you just hack the hell out of it to get to your objective. It's a fun and refreshing way to look at code when you're usually always striving for best practice, idiomatic, etc. Very game-y that way. :)
- TheDong 7y agoThis game reminds me a lot of untrusted [0], though it seems to be much less polished, and the solutions feel less interesting and elegant. [0]: https://alexnisnevich.github.io/untrusted/ https://alexnisnevich.github.io/untrusted/
- everdev 7y agoYes, I was inspired by it. It's a great game. Did you finish GoCode? The problems do get more challenging.
- TheDong 7y agoYup, assuming the Finale with rob is all there is to it. A couple of them were trickier (like in level 9, it was really not clear at all what the right output was supposed to be at first), but none of them seemed all that hard. None of them actually felt "fun". I think it mostly felt less polished due to things like the lack of music and the fact that Go itself is a bad language for this sort of thing. In Untrusted, there were often places where you could monkey-patch objects and come up with really creative solutions. There were some problems that I felt like I really had freedom to be creative. In this game, the imports were always out of bounds for editing, so I could never pull in 'unsafe' and have any real fun. All the solutions felt far too restrictive. Sure, there were multiple ways to hack around things, but it never felt like there was room for a spark of real creative joy. I think go is just a bad language for "fun". It's not optimized for being able to write interesting or elegant code. It's not optimized for having fun.
- shurcooL 7y agoNot to discount your point, but I want to offer my opinion which is different. I had fun _because_ it was more constrained. But I also like Go. As an example, I solved level 6 in what I understand to be an unconventional way: (spoiler alert) I realized I could “get out” of readCodesFromKeypad function scope by ending it early and then writing the start of another top level function. Once I had access to global scope, I could add an init() function to modify the “crypto/rand.Reader” variable and assign to it an io.Reader that I could control. I was on mobile so I decided to take a shortcut and just overwrite the global passcode variable instead. (end spoiler) I may have “cheated”, but it felt creative and in spirit of the game, and it got me to the next level.
- danschumann 7y agoMission 4? I should probably be overriding the interface or something right? gotta get a record function in there somehow.. not as easy as `camera.record = () => { return 'Idle' }`
- everdev 7y agoYou're on the right track :) In the top right, there's a lightbulb you can click to reveal a hint for each mission. For this level the tip says "RecordingDevice is an interface, so it should be possible to create your own type of Camera". On Reddit there's a thread that also contains some additional tips for some of the missions: https://www.reddit.com/r/golang/comments/c2hsaj/operation_go_programming_game_in_the_browser/ https://www.reddit.com/r/golang/comments/c2hsaj/operation_go...
- ddlutz 7y agoMaybe I'm an idiot, but I don't really get what level two is asking. I "solved it" in one line by directly returning the two numbers it's looking for. But that doesn't seem right at all.
- xmprt 7y agoIf it works then that's probably right. Based on the hint I'm guessing they want you to set up meters and seconds such that if flows through the if statement but that seems a bit pointless.
- ReverseCold 7y agoEverything until 12 was something that I could sort of get without knowing Go, and then the difficulty magically jumped (which is subjective, but still).
- xmprt 7y agoI'm surprised you got things like `init()`, interfaces, json.Marshal, and channels without knowing Go. I'm assuming you looked things up/used hints?
- johnmwilkinson 7y agoFun, but terrible on mobile
- Thorrez 7y agoIs there any programming that isn't terrible on mobile?
- fred256 7y agovar buttons = []string{"red", "blue", "green", "yellow", "purple"} > go run level_9.go Sending Code Sequence... 1 : red 2 : blue 3 : green 4 : yellow 5 : purple Sorry, that's not correct Not sure what the correct sequence is, if not that?
- bemidji 7y agoWhat are the concurrency guarantees of goroutines? ;)
- DuskStar 7y agoI'm confused here too - is there some other desired behavior? I thought the goal here was to avoid race conditions and just reproduce that order, since that's what's in the source code... > var buttons = []string{"red", "blue", "green", "yellow", "purple"}
- Thorrez 7y agoThere are none, right? So even if you add mutexes to the existing code in an attempt to remove race conditions, it will still have race conditions, and have no guaranteed output order, because you have no guarantee which order the goroutines will start in. The obvious way to solve it in order to get the answer shown in the source code is if x == 0 { *sequence = []Button{{"red"}, {"blue"}, {"green"}, {"yellow"}, {"purple"}} } return This way there is nothing concurrently touching sequence, nor is there anything concurrent touching rand, nor is anything relying on goroutine starting order, nor are there other race conditions. But yet the site says this is wrong.
- everdev 7y agoYou can click the lightbulb to get a hint. The way I solved it was with a Mutex.
- Thorrez 7y agoYeah I know about the hint. But the result the hint leads you to doesn't make sense. Using a Mutex removes data races, but it does not remove race conditions. By leaving the race condition in, the code is has output that cannot be relied on. But yet the challenge wants us to think that somehow the output has a specific value that can be relied on.
- deleted 7y ago[deleted]
- CriticalCathed 7y agoSolutions listed anywhere? I'm curious what the expected solutions are.
- wizardo 7y agoAre solutions listed anywhere ?
- everdev 7y agoNot officially, but there are some here: https://www.reddit.com/r/golang/comments/c2hsaj/operation_go_programming_game_in_the_browser/ https://www.reddit.com/r/golang/comments/c2hsaj/operation_go...
- abbeyj 7y agoThis was pretty enjoyable. It reminds me a bit of "return true to win" (https://alf.nu/ReturnTrue https://alf.nu/ReturnTrue). I think I cheated a bit on Level 7. I just copy-pasted the code that wrote to epochComms and changed it to write to interceptComms instead. I'm not quite sure what the intended solution is. On Level 12, does Secret.extHash serve any purpose? It never gets read. I was doing this on mobile (Chrome on Android) and I ran into a few odd problems. If you have two opening curly braces in a row and try to backspace to delete the first one, it instead inserts a newline and duplicates the rest of the line. That is, if you have "{{foo" with the cursor after the first curly brace and you press backspace you end up with two lines each saying "{foo". This doesn't happen for me on desktop. Copy-paste also seems to be broken on mobile. You can't select anything and trying to paste is just ignored. It would be nice if you go go back and view the hint after you've completed a level. Or even if you could try different solutions to a level after you've finished it. You may not always be happy with the first thing that works.
- everdev 7y agoThanks for the feedback! It uses the Ace Editor: https://ace.c9.io/ https://ace.c9.io/ I couldn't find a more mobile friendly code editor, but I'm happy to test out other recommendations as I'd love for it to be enjoyable on mobile too.
- thesephist 7y agoYou've probably run across it and maybe even tried it, but I use CodeMirror for Codeframe [0] and it works well on the every mobile device I've tested on, and is pretty customizable. [0] http://beta.codeframe.co/ http://beta.codeframe.co/
- xwowsersx 7y agoI tried typing full on mobile and it just kept deleting words.
- thunderrabbit 7y agoSame for me on Android 8 using Brave browser.
- xwowsersx 7y agoTried on Chrome and FF on Android. Can't type in either.
- Thorrez 7y agoThe idea that Epoch writes code under the fear that other parts of the code are malicious reminded me of https://thedailywtf.com/articles/Confessions-Hacker-Proof-Boolean https://thedailywtf.com/articles/Confessions-Hacker-Proof-Bo...
- n1try 7y agoVery cool hacking challenge! I solved all 12 levels with only looking at the very last hint... and "wasted" half of my Sunday :-D