Anyway, these days there are lots of games where you compete and even team up with strangers, e.g. Splatoon, League of Legends (LoL) and so on. I'd love to learn more about how these games match people up to try and maximise the user experience as I think we have a related problem with matching people up for pairing sessions in our "Agile Development using Ruby on Rails" MOOC. If Splatoon/LoL are the gaming equivalent of full screenshare pairing, then simpler games like letterpress would correspond to a sort of micro-pairing experience on a small toy problem.
Ever since I've looked into the different styles of ping-pong pairing I've been fascinated how protocols like "one undermanship" have a game like feel. They remind me somehow of turn based games like chess. So I keep thinking of a letterpress style micro-pair programming game where you are involved in light-weight ping-pong pairing sessions with people all round the world.
Maybe there's nowhere near the number of people interested in pair programming as there are in playing word games, so maybe there would never be the critical mass to make it fun, ... unless, robots? I finally spent some time on a micro-pairing robot on a plane recently. There are a couple of challenges; one is working out the rules of this ping-pong pairing game I'm imagining, and another is getting a robot to pair program sensibly with you.
An instance of a pairing game might run like this:
Spec involves input/output, e.g. 2 => 4, 3 => 6, 4 => 8 (in this case a numeric doubler). The "one undermanship" protocol involves writing the absolute minimum amount of code (which we could perhaps measure in terms of characters? code-complexity?)
Pair A writes:
describe 'doubler' do
it 'doubles a number' do
expect(double(2)).to eq 4
end
end
def double(number)
4
end
describe 'doubler' do
it 'doubles a number' do
expect(double(2)).to eq 4
end
it 'doubles a number' do
expect(double(3)).to eq 6
end
end
number*2
which would be fewer characters, but perhaps we can give them points for passing only the existing tests and not others?):def double(number)
4 if number == 2
6
end
describe 'doubler' do
it 'doubles a number' do
expect(double(2)).to eq 4
end
it 'doubles a number' do
expect(double(3)).to eq 6
end
it 'doubles a number' do
expect(double(4)).to eq 8
end
end
def double(number)
number * 2
end
def double(number)
4 if number == 2
6 if number == 3
8
end
So there's also the issue of coming up with a range of simple coding problems that make this more interesting than the most trivial cases - I guess there's enough complexity in a few basic arithmetic problems, and we can collect more over time - there are great repositories like code wars. Anyway, with any multi-player game we have the classic bootstrap problem that if we had a great game that lots of people were playing, then there would be lots of people to play with and it would be great; but initially there are no people playing it. So in the meantime can we scaffold the gameplay with pretend people? Can we write a robot pairer than can make a test pass, and generate a new chunk of code to move the ping pong on?
For a restricted set of cases I think the answer is yes. At least what I started on the plane was a chunk of code that would take and analyse a ruby exception and write the necessary code to make it pass. It's not very complex at the moment, it's basically this:
def fix_code(e)
if e.class == NoMethodError
/undefined method \`(.*)\' for main\:Object/ =~ e.message
eval "def #{$1}; 'robot method' ; end "
elsif e.class == ArgumentError
/wrong number of arguments \(given (.*), expected \d\)/ =~ e.message
num_args = $1.to_i # could use class or arg to auto-infer an approprate name?
arg_string = (0..num_args-1).map {|i| "arg#{i}"}.join(',')
/\(eval\)\:1\:in \`(.*)\'/ =~ e.backtrace.first
method_name = $1
eval "def #{method_name}(#{arg_string}); 'robot method' ; end"
else
puts "cannot handle error class #{e.class}; #{e.message}"
end
end
I guess the best initial interface would be to make it a command line game that you could play and the robot would edit the file that you are both working on perhaps? Having started it I'm kind of interested in extending it; we'll see if anyone else thinks this is anything other than mindless naval gazing :-)