Morendil comments on Prisoner's Dilemma (with visible source code) Tournament - LessWrong

47 Post author: AlexMennen 07 June 2013 08:30AM

You are viewing a comment permalink. View the original post to see all comments and the full post content.

Comments (232)

You are viewing a single comment's thread. Show more comments above.

Comment author: Morendil 08 June 2013 08:26:11AM *  1 point [-]

Tentatively: I'll paste "(YourCode TheirCode)" into the interpreter with DrRacket, with #lang scheme.

The most elegant, it seems to me, would be to require entires to be sumitted as a .rkt file that defines a module providing a single variable (possibly with a required name, eg "bot") that must be a quoted expression.

This makes it simple to call programs (eval the expressions), pass opponent's source code, or even provide programs with their own source code; and could be used to automate static checking of various constraints, such as the ban on file I/O.

It also allows more flexibility for submitters in constructing their entry, for instance I was able to considerably streamline the source code to the CliqueBot template:

(define matcher
'(let pattern-match ((pattern template) (value opponent))
(cond
((pair? pattern) (and (pair? value)
(pattern-match (car pattern) (car value))
(pattern-match (cdr pattern) (cdr value))))
((number? pattern) (case (+ pattern 1)
((1) #t)
((3) (equal? value template))
(else (and (number? value)
(= pattern value)))))
(#t (eq? pattern value)))))

(this is the "workhorse" part, providing the program as a quoted expression obviates the need for repeating it twice, as we can then leverage the quasiquote and unquote language features)

(define clique-templ
(quasiquote
(let ((template '2))
(lambda (opponent)
(if (unquote matcher)
'C
0)))))

(this is the "template", it will be expanded to include the program-matching portion)

(define clique-bot
(quasiquote
(let ((template (quote (unquote clique-templ))))
(lambda (opponent)
(if (unquote matcher)
'C
'D)))))

(this is the actual program, it both quotes (via inclusion of the template) and uses the program-matching part).

The top of the file would consist of the following declaration:

#lang scheme
(provide clique-bot)

...or if you're requiring that all entries use the same name "bot" (which could make it easier to administrate the actual running of the contest):

#lang scheme
(provide (rename-out (clique-bot bot)))