timehome / game-off-2012

Write the best robot and win glory and fame!
http://fightcodegame.com/
91 stars 10 forks source link

Directions to spin up your own server #13

Open robwalch opened 11 years ago

robwalch commented 11 years ago

Not a bug. Feature / Documentation request. Might make a good blog post - "fightcodegame make a run for it!"

Some of these required sudo. Here's what I needed to do, since I had most of the nodejs requirements met:

brew install postgres

echo -e "127.0.0.1\tlocal.fightcodegame.com" >> /etc/hosts

gem install compass --pre gem install oily_png gem install terminal-notifier

make setup make compile make kill_postgre make postgre make drop make db make run

local.fightcodegame.com:3000/robots/create (setup one of two robots so site has some data)

Next step was to make the editor (create page) wider and taller, and give 'duck' the code of one of the top ranking robots. I also lowered bullet strength to 1 so that I could watch slower simulations.

alexanderzeillinger commented 11 years ago

Since the site is completely unreachable for days now I would also like to run it locally..

Can someone give me a tutorial on how to do this on Windows for someone with no experience with nodejs, ruby etc..?

robwalch commented 11 years ago

Can someone ... do this on Windows ... with no experience with nodejs, ruby etc..?

Urg... If I were you I'd get a heroku account and try to get it running there. Learning to install node and ruby on your own Windows machine is something you should only do first only if you are serious about doing web development that way.

Alternatively, maybe timehome will accept donations to scale their hosting plan, or after the contest is judged some enhancement to performance will make the site more responsive. I think (just guessing) that the players with the most points don't just have awesome Robot programs, they also make tons of page requests to earn points that use up lots of server resources.

alexanderzeillinger commented 11 years ago

Alright, I used Ubuntu in a VM and managed to get it to run. Now letting my own bot fight itself :-)

robwalch commented 11 years ago

Nice! Here's a patch of what I changed on my side to make the editor bigger and testing your bot easier (removed the timeout between fights, and lowered strength so battles last longer).

The only other bit not shown in this patch is that you want to change the contents of this tag in createRobot.ejs to use a more challenging 'duck' robot in the editor:

<script type="robot/script" id="duck-code">
diff --git a/fightcode/coffee/routes/fight.coffee b/fightcode/coffee/routes/fight.coffee
index cfece57..165eaf2 100644
--- a/fightcode/coffee/routes/fight.coffee
+++ b/fightcode/coffee/routes/fight.coffee
@@ -261,15 +261,15 @@ exports.createFight = (req, res) ->
     repository.findRobot(playerRobotId, (err, robot) ->
         robot.getLastFightDate((date) ->
             diff = Math.abs(new Date() - date)
-            if (diff < 30000)
-                res.redirect("/robots/timeout/#{ robot.id }")
-            else
-                repository.createFight((result) ->
-                    if result is 404
-                        res.send(404)
-                    else
-                        res.redirect("/robots/replay/#{ result.fight.id }")
-                )
+            # if (diff < 30000)
+            #     res.redirect("/robots/timeout/#{ robot.id }")
+            # else
+            repository.createFight((result) ->
+                if result is 404
+                    res.send(404)
+                else
+                    res.redirect("/robots/replay/#{ result.fight.id }")
+            )
         )
     )

diff --git a/fightcode/static/coffee/engine.coffee b/fightcode/static/coffee/engine.coffee
index 71ec079..0b97828 100644
--- a/fightcode/static/coffee/engine.coffee
+++ b/fightcode/static/coffee/engine.coffee
@@ -283,7 +283,7 @@ class BulletStatus extends ElementStatus
         @rectangle.setDimension(2, 2)

         @speed = 2
-        @strength = 20
+        @strength = 1
         @running = true

     isIdle: ->
diff --git a/fightcode/static/css/all.css b/fightcode/static/css/all.css
index 5c193b3..12ce081 100644
--- a/fightcode/static/css/all.css
+++ b/fightcode/static/css/all.css
@@ -133,7 +133,7 @@ a {
 }

 .span12, .container {
-  width: 940px;
+  width: 1600px;
 }

 [class*="span"] {
@@ -1821,12 +1821,12 @@ code, pre {
 }
 .create-robot-form .editor {
   border-left: 1px solid #000;
-  width: 468px;
+  width: 768px;
   position: relative;
   z-index: 20;
 }
 .create-robot-form .form-col, .create-robot-form .editor .CodeMirror-scroll {
-  height: 480px;
+  height: 800px;
 }
 .create-robot-form .form-col.error .CodeMirror-scroll, .create-robot-form .editor .CodeMirror-scroll.error .CodeMirror-scroll {
   -webkit-box-shadow: 0 0 25px red inset;
@@ -1839,11 +1839,15 @@ code, pre {
   box-shadow: 0 10px 20px red;
 }
 .create-robot-form .board {
-  width: 338px;
+  width: 800px;
+  height: 500px;
   border: 0;
   margin-top: 0;
   border-radius: 0;
 }
+.create-robot-form .board-container {
+  height: 500px;
+}
 .create-robot-form .buttons-bar {
   text-align: center;
   padding-top: 10px;
diff --git a/fightcode/static/css/bootstrap.min.css b/fightcode/static/css/bootstrap.min.css
index 17199ab..19fba88 100644
--- a/fightcode/static/css/bootstrap.min.css
+++ b/fightcode/static/css/bootstrap.min.css
@@ -31,8 +31,8 @@ a:hover{color:#e8d069;text-decoration:underline;}
 .row{margin-left:-20px;*zoom:1;}.row:before,.row:after{display:table;content:"";line-height:0;}
 .row:after{clear:both;}
 [class*="span"]{float:left;min-height:1px;margin-left:20px;}
-.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px;}
-.span12{width:940px;}
+.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:1600px;}
+.span12{width:1600px;}
 .span11{width:860px;}
 .span10{width:780px;}
 .span9{width:700px;}
@@ -654,7 +654,7 @@ button.btn.btn-mini,input[type="submit"].btn.btn-mini{*padding-top:1px;*padding-
 .navbar-fixed-top .navbar-inner,.navbar-static-top .navbar-inner{border-width:0 0 1px;}
 .navbar-fixed-bottom .navbar-inner{border-width:1px 0 0;}
 .navbar-fixed-top .navbar-inner,.navbar-fixed-bottom .navbar-inner{padding-left:0;padding-right:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}
-.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px;}
+.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:1600px;}
 .navbar-fixed-top{top:0;}
 .navbar-fixed-top .navbar-inner,.navbar-static-top .navbar-inner{-webkit-box-shadow:0 1px 10px rgba(0,0,0,.1);-moz-box-shadow:0 1px 10px rgba(0,0,0,.1);box-shadow:0 1px 10px rgba(0,0,0,.1);}
 .navbar-fixed-bottom{bottom:0;}.navbar-fixed-bottom .navbar-inner{-webkit-box-shadow:0 -1px 10px rgba(0,0,0,.1);-moz-box-shadow:0 -1px 10px rgba(0,0,0,.1);box-shadow:0 -1px 10px rgba(0,0,0,.1);}
alexanderzeillinger commented 11 years ago

Thanks, unfortunately when compiling the changes I get this error:

COMPASS output:

Error: Command failed: /bin/sh: 1: bundle: not found

Task "compass:dist" failed. Use --force to continue.

Any idea on how to fix this?

alexanderzeillinger commented 11 years ago

Ok, figured out I had to install the bundler gem, but now this:

COMPASS output:

Error: Command failed: /var/lib/gems/1.8/gems/bundler-1.2.3/lib/bundler/spec_set.rb:90:in `materialize': Could not find sass-3.2.2 in any of the sources (Bundler::GemNotFound)

sass 3.2.3 is installed and 3.2.2 cannot be found, what to do?

robwalch commented 11 years ago

There are a couple of version specific libs/gems being used. Use this site to help install the required versions http://rubygems.org/gems/sass/versions/3.2.2

alexanderzeillinger commented 11 years ago

Ok, got it to work, but the CSS changes are not working but instead were reset?! Also I had to npm install a dozen packets again, weird ecosystem.

Reduced damage works fine though. Did also notice the cannon is slightly misaligned for some reason.