
Ruby programming challenge as job application - reedlaw
http://smashingboxes.com/jobs/
======
cheald
If the purpose of the challenge is to win by showing off your knowledge of
Ruby...

    
    
        module Wizard
          def move; [:rest] end
          def stats; i = 1.0/0; { health: i, level: i, strength: i, defense: i, experience: i } end
          def suffer_damage(p); end
          def to_s; "Zhormenheimer the Illusionist" end
        end
    
    
        Zhormenheimer the Illusionist: {:health=>Infinity, :level=>Infinity, :strength=>Infinity, :defense=>Infinity, :experience=>Infinity}
        Zhormenheimer the Illusionist is the winner!
    

(Ruby really needs something like Lua's setfenv!)

~~~
reedlaw
Nice hack. Yes, this is not cheat proof by any means. But Ruby is by its
nature hard to prevent someone from doing whatever they want.

I did try to make it semi-cheat proof by using a delegator PlayerProxy that
sends method calls to the real Player objects. But if you're going to read the
stats of other players you must be able to call Player#stats somehow.

~~~
cheald
It might be worth defining some boundary conditions on what constitutes a
valid player. "May not touch any other game classes/modules, except for this
whitelist of methods" and "may not reimplement these methods" is a good start.
As-is, there is so little direction that I'd argue that my player is valid per
the letter of the rules. :P

Without those constraints, there are limitless ways to cheat, especially since
it's impossible to actually hide functionality in ruby (obligatory:
<https://github.com/fxn/i-told-you-it-was-private> ), so you have to have a
set of meta-constraints in place.

Regarding proxying, why not just use the Forwardable module? Though, even if
you did manage to hide the critical pieces from the Player, I'd just iterate
ObjectSpace to find a PlayerProxy that contains a reference to my Player. :P

~~~
reedlaw
You're right, but for me another challenge was to try to circumvent cheating.
If I see players that try to win by pure Ruby hackery I'd like to see if
there's a Ruby way to make sure that hackery doesn't work (inside Game,
Player, or PlayerProxy). Is there a way in Ruby to prevent a module from
overriding a method of the class in which its included?

~~~
cheald
Short answer: No. Nothing in Ruby is truly private, and even if you did manage
to hide references to something, you could always find it in ObjectSpace. I
could even undefine your Game class and replace it with my own (I reject your
reality, and substitute my own!)

To get true cheating prevention, you'd have to do something like spawn off
another Ruby process and use some kind of IPC to pass events to your "client"
process and receive actions back to your "server" process. All canonical state
would be held by the "server" process.

This is really the classic "don't trust the client" problem that all games run
into. :)

~~~
mooom
if you force move to be an arithmetic function with inputs the stats of the
game, then you can parse that the syntax of the move functions only involve
arithmetic operators and some math functions (max, min, ...). This way one
can't cheat in the game.

~~~
cheald
My #move method was perfectly innocuous; I cheated by making my player never
take damage, and by giving him infinite stats.

Parsing source code for "bad" stuff is generally an arms race you can't win.
For actual sandboxing you need a clean environment (hence, the reference to
Lua's setfenv).

------
dpritchett
_To submit a job application, please fork this repository and commit your
entry in the programming challenge. Then send us a pull request_ [on github]
_with a comment that says you’re looking for a job._

Unless I misread this the challenge is only available for people who are
publicly job hunting, which is a small percentage of eligible coders. I
believe I've seen this before as "tweet us your resume".

~~~
reedlaw
Good point. We got the idea for this challenge from this:
[http://www.chrisstucchio.com/blog/2012/one_hiring_filter_tha...](http://www.chrisstucchio.com/blog/2012/one_hiring_filter_that_works.html)

We debated how to implement this and decided on using github because of the
added bonus of being able to view github profiles as part of the screening
process.

If anyone's interested in a job but doesn't want to submit a public pull
request, please send your contest submission to reed@smashingboxes.com and let
us know if you want your code to be committed to our repo or not.

~~~
dpritchett
The _problem_ sounds super fun. I spent an evening in Ruby Warrior [1] just
for the fun of it a few months back and your challenge seems like it might be
an even more fun version of that. I'm sure you'll get some good submissions.

[1] <https://github.com/ryanb/ruby-warrior>

~~~
reedlaw
Yes, ruby-warrior was an inspiration. The challenge is just a bare minimal RPG
at the moment, but I hope to find time to improve it. To-dos:
<https://github.com/reedlaw/ruby-mmo/wiki>

------
hamburglar
Yeah, this has Kobayashi Maru written all over it.

------
borlak
the only winning move is not to play

------
QuarkSpark
The current fork status indicates 52 unemployed Rubyists?!!

------
nmjordan
good luck !

