News for hackers. Stuff that matters.
Re:Show HN: JavaScript Battle – A daily artificial intellige... by drhayes9 on Tuesday October 07, 2014 @12:34PM (#8422139)
CoreWars but with JS and GitHub! Cool idea.

I'd be very interested in hearing about the server-side setup, especially around isolating the code so some rando doesn't "require('fs')" and do damage to the server. How are you isolating the brains from the sensitive game data and from each other? How long does a single game take to run given max users? How are you protecting against "while(true);"?

Here's a repo that looks related: https://github.com/JavascriptBattle/javascript-battle-webwor...

Re:Show HN: JavaScript Battle – A daily artificial intellige... by forrestbthomas on Tuesday October 07, 2014 @01:05PM (#8422339)
Thanks so much for the interest and the questions. You are correct in that the web-workers repo is related. Its the repo we use on the back end. To answer your questions in turn: "How are you isolating the brains from the sensitive game data and from each other?" - We are sandboxing each user's code in an isolated environment where a server listens for a POST request on a specified endpoint. That request carries the game data with it and after the user's code runs, the server sends back the result of that function, which is supposed to be a string (North, East, South, West, or Stay). The game data itself is update on our server, after receiving the response. "How long does a single game take to run given max users?" The games will take a maximum of 24 users, which will take a maximum of 30 minutes to run, if every user does something like "while(true)." Each server has a max-timeout setting of around 2 seconds. I hope that answers your questions and please feel free to offer any feedback. Thanks again!
Re:Show HN: JavaScript Battle – A daily artificial intellige... by qznc on Tuesday October 07, 2014 @03:06PM (#8423269)
So the AI can use up to 2 seconds of "thinking time" for each move on a some x86-server-like machine? Having played BitBath [0], I think this limit matters.

No matter how many turns are played, a match ends after 30 minutes? According to the rules, no team wins in this case?

[0] http://www.hacker.org/bitbath/

Re:Show HN: JavaScript Battle – A daily artificial intellige... by forrestbthomas on Tuesday October 07, 2014 @03:16PM (#8423328)
Thanks for the clarification. I wasn't very clear in my answer before. The game ends after a maximum of 1250 turns or when all of one team's heroes are killed. If the maximum turn is reached, the team with the most diamonds wins. If every player on the team took the full 2 seconds on every turn, the game would last around 30-40 minutes.
Re:Show HN: JavaScript Battle – A daily artificial intellige... by tokenizerrr on Tuesday October 07, 2014 @12:24PM (#8422084)
That's interesting, I like that everyone's code has to be public on github so if you get relentlessly destroyed you will at least have the chance to learn from how your opponent works.

I haven't yet tried the game itself, but the testing page mentioned on the frontpage seems rather important, and I think I'll hold off on trying the game until that is implemented.

Also I think it would be good to mention at what time (in which timezone) each day the code is pulled and the battles are run.

Re:Show HN: JavaScript Battle – A daily artificial intellige... by diggan on Tuesday October 07, 2014 @12:42PM (#8422201)
That the code is public could easily be manipulated, by commiting minified code instead. It doesn't make it non-copyable but mostly unreadable.

There is a small testing utility (called " test_your_hero_code.js") in the repository where you can make sure your hero is working as it should. But I'm also looking forward to a proper testing page where I can see the battle.

Interesting idea however, looking forward to having some free time to trying it out fully.

Re:Show HN: JavaScript Battle – A daily artificial intellige... by forrestbthomas on Tuesday October 07, 2014 @01:10PM (#8422389)
Thanks so much for the feedback. As you said, we do have a temporary testing utility for users while we finish up our testing site. Hope to see you soon!
Re:Show HN: JavaScript Battle – A daily artificial intellige... by forrestbthomas on Tuesday October 07, 2014 @01:07PM (#8422361)
That's really good feedback, thank you. We are currently running the game at close to midnight, Pacific Time. As far as the testing site, that should be coming soon, but feel free to try out our temporary testing suite in the meantime. The hero-starter repo has all the instructions for that. Thanks so much for your comments and feedback!
Re:Show HN: JavaScript Battle – A daily artificial intellige... by stephentmcm on Tuesday October 07, 2014 @11:49PM (#8425234)
Is there a place to comment on gameplay design? As looking at the current rules, if a 'Coward hero' just sits at a health well hitting it ever turn they can't be killed by a single enemy hero attacking? If I'm reading the rules correctly the attacking hero can hit 10 from 'moving' at the coward and 20 again at turn end for a total of 30, which the coward can heal by simply moving at the well?

Either way cool game/site will give spin up a Hero soon.

Re:Show HN: JavaScript Battle – A daily artificial intellige... by forrestbthomas on Wednesday October 08, 2014 @12:15AM (#8425281)
Thanks for the feedback. Feel free to use the 'contact us' link at the bottom of the page with any specific suggestions that you might have for gameplay. In the meantime, we hope you enjoy it! *Note: The way to beat the Coward is by collecting diamonds. The Coward won't collect any, so won't be contributing to the team's score.
Re:Show HN: JavaScript Battle – A daily artificial intellige... by erikb on Tuesday October 07, 2014 @05:00PM (#8423984)
What other games like this exist out there?
Re:Show HN: JavaScript Battle – A daily artificial intellige... by Houshalter on Tuesday October 07, 2014 @07:55PM (#8424652)
Re:Show HN: JavaScript Battle – A daily artificial intellige... by stevekemp on Thursday October 09, 2014 @11:47AM (#8433090)
http://fightcodegame.com/ is one I played a while ago.

Edit: I've got a bot ranked #237 still, a year on from its creation.

Re:Show HN: JavaScript Battle – A daily artificial intellige... by forrestbthomas on Tuesday October 07, 2014 @05:07PM (#8424016)
Thanks for the question. The comments below have a couple similar games, but we built JavaScript Battle because we felt it was unique. Let us know what you think!
Re:Show HN: JavaScript Battle – A daily artificial intellige... by gjtrowbridge on Tuesday October 07, 2014 @05:59PM (#8424266)
Vindinium, gameplay-wise, is definitely the most similar. (vindinium.org)
Re:Show HN: JavaScript Battle – A daily artificial intellige... by darylteo on Tuesday October 07, 2014 @09:41PM (#8424931)
Code & Conquer looks like vaporware at the moment, sadly :(
Re:Show HN: JavaScript Battle – A daily artificial intellige... by TomAnthony on Wednesday October 08, 2014 @04:21AM (#8425823)
Cool idea!

I registered yesterday but today I can't login. The 'login with github' button doesn't do anything (just reloads the page).

Also the leaderboard seems to breakdown if you interact with it for a bit - just stops updating.

Re:Show HN: JavaScript Battle – A daily artificial intellige... by gjtrowbridge on Wednesday October 08, 2014 @08:37AM (#8426543)
Strange. It seems to all be working at the moment, but we'll try to squash more of the bugs today--please feel free to email [email protected] if you're continuing to see problems.

Thanks for bearing with us!

Re:Show HN: JavaScript Battle – A daily artificial intellige... by TomAnthony on Wednesday October 08, 2014 @02:14PM (#8428465)
So - what happens is I get bounced through a few 302 redirects from github back to the page, but I remain not logged in. Then if I refresh the page it displays me as logged in then. Hope that helps. :)
Re:Show HN: JavaScript Battle – A daily artificial intellige... by forrestbthomas on Wednesday October 08, 2014 @02:27PM (#8428561)
Interesting...We'll take a look at that. Sounds like something with our OAuth redirect. Thanks so much for the update!
Re:Show HN: JavaScript Battle – A daily artificial intellige... by mooogs on Wednesday October 08, 2014 @12:07AM (#8425263)
Re:Show HN: JavaScript Battle – A daily artificial intellige... by forrestbthomas on Wednesday October 08, 2014 @12:16AM (#8425285)
Thanks for the note and the screenshot. Should be fixed now.
Re:Show HN: JavaScript Battle – A daily artificial intellige... by alxeder on Wednesday October 08, 2014 @08:11AM (#8426458)
Re:Show HN: JavaScript Battle – A daily artificial intellige... by gjtrowbridge on Wednesday October 08, 2014 @08:45AM (#8426579)
Thanks for the heads up--it looks like we have an infrequent but recurring bug that's causing this issue. We're working on a more permanent fix for the very near future, but for now it should all be working again.
Re:Show HN: JavaScript Battle – A daily artificial intellige... by mooogs on Wednesday October 08, 2014 @03:18AM (#8425651)
Yup fixed!
Re:Show HN: JavaScript Battle – A daily artificial intellige... by rasz_pl on Wednesday October 08, 2014 @01:09AM (#8425404)
>Each day your code will be assigned to a team at random

so today (500 diamonds vs 7) server randomly assigned one guy that dominates vs 10 pretty bad players?

Re:Show HN: JavaScript Battle – A daily artificial intellige... by gjtrowbridge on Wednesday October 08, 2014 @08:42AM (#8426568)
Yep, it is "luck of the draw", and the default hero brain, while very good at gathering diamonds, does tend to be vulnerable to the "assassin" roles.

Eventually we'd like to add a slightly smarter matchmaking system (assign users to games based on some sort of performance ranking perhaps?), but for now it's very possible to end up on a less-than-stellar team.

Re:Show HN: JavaScript Battle – A daily artificial intellige... by Kiro on Wednesday October 08, 2014 @04:31AM (#8425857)
What's so strange about that? The majority are probably bad players.
Re:Show HN: JavaScript Battle – A daily artificial intellige... by mweibel on Wednesday October 08, 2014 @02:02AM (#8425509)
Pretty awesome and good instructions on how to start!

What would be nice to see when the next battle will start (probably localized) :-)

Re:Show HN: JavaScript Battle – A daily artificial intellige... by gjtrowbridge on Wednesday October 08, 2014 @08:38AM (#8426555)
At the moment, the battles run a bit after midnight (PST) each day. Thanks for the feedback--we can make this a bit more obvious on the site.
Re:Show HN: JavaScript Battle – A daily artificial intellige... by FigmentEngine on Friday October 10, 2014 @10:37AM (#8437903)
any chance the console output of the battle can be sent to the account? this would make fixing bugs easier... or if "see todays battle" allows you to click on each hero and see there stats & console output.

really great by the way!

Re:Show HN: JavaScript Battle – A daily artificial intellige... by Mangalor on Tuesday October 07, 2014 @03:40PM (#8423500)
So Vindinium in JS. Not a bad idea.
Re:Show HN: JavaScript Battle – A daily artificial intellige... by gjtrowbridge on Tuesday October 07, 2014 @03:53PM (#8423586)
Yep! The gameplay is very similar, but the tech stack, signup process, method for participating, stats, etc are all different from Vindinium. But they were definitely our inspiration (as Forrest mentioned, we actually have an "Inspired by Vindinium" link in our footer).
Re:Show HN: JavaScript Battle – A daily artificial intellige... by forrestbthomas on Tuesday October 07, 2014 @03:46PM (#8423548)
Thanks! Inspired by it. There is a link at the bottom of the page to Vindinium, as well.
Re:Show HN: JavaScript Battle – A daily artificial intellige... by oakleon on Tuesday October 07, 2014 @03:02PM (#8423234)
The "see todays battle" renders incorrectly on chrome Version 38.0.2125.101 beta
Re:Show HN: JavaScript Battle – A daily artificial intellige... by gjtrowbridge on Tuesday October 07, 2014 @03:13PM (#8423307)
Thanks for the heads up--working on it now, should be back up in a couple minutes. I'll follow up when it is.
Re:Show HN: JavaScript Battle – A daily artificial intellige... by gjtrowbridge on Tuesday October 07, 2014 @03:16PM (#8423326)
It should be up again--let me know if you're still having trouble viewing it.
Re:Show HN: JavaScript Battle – A daily artificial intellige... by mmanfrin on Tuesday October 07, 2014 @03:10PM (#8423293)
Same for Version 37.0.2062.124, Firefox version 31.0, and Firefox 32.0.3
Re:Show HN: JavaScript Battle – A daily artificial intellige... by jabbrass on Tuesday October 07, 2014 @07:00PM (#8424472)
Awesome work, I think that this is a great way to ease into writing basic AI in JS.
Re:Show HN: JavaScript Battle – A daily artificial intellige... by gjtrowbridge on Tuesday October 07, 2014 @07:04PM (#8424488)
Thanks!
Re:Show HN: JavaScript Battle – A daily artificial intellige... by goldfeld on Tuesday October 07, 2014 @01:18PM (#8422443)
This is great! Would ClojureScript (or other languages compiling down) do?
Re:Show HN: JavaScript Battle – A daily artificial intellige... by gjtrowbridge on Tuesday October 07, 2014 @01:28PM (#8422520)
Thanks! ClojureScript (or Coffeescript, or anything other than JS) will not work "right off the bat", but you could compile to JavaScript on your end, then upload that compiled hero.js file to your github repository, and then THAT should work.

Hope that helps.