You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.2 KiB
Racket
32 lines
1.2 KiB
Racket
#lang racket
|
|
|
|
; runs all the players against each other as both first and second player.
|
|
|
|
(require "main.rkt" "players.rkt")
|
|
|
|
(define GAMES-PER-MATCH 100)
|
|
|
|
(define results (make-hash))
|
|
|
|
(define all-players (list player-random player-first player-last player-greedy player-nico player-generous player-horizontal player-vertical))
|
|
|
|
(define matchups (append (combinations all-players 2) (map reverse (combinations all-players 2)) (for/list ([p all-players]) (list p p))))
|
|
|
|
(for ([m matchups])
|
|
(hash-set! results m 0)
|
|
(for ([i (in-range GAMES-PER-MATCH)])
|
|
(define g (start-game (first m) (second m) 6 6))
|
|
(define current (hash-ref results m))
|
|
(hash-set! results m (if (> (first (GameState-scores g)) (second (GameState-scores g))) (+ current 1) current)) ; if p1 wins, increment the counter
|
|
(save-game! g (format "/tmp/games/~a vs ~a ~a.dbn" (player-name (first (GameState-players g))) (player-name (second (GameState-players g))) i))))
|
|
|
|
(print results)
|
|
|
|
(define csv (open-output-file "/tmp/games/results.csv"))
|
|
|
|
(display "Player 1,Player 2,P1 wins,P2 wins\n" csv)
|
|
|
|
(for ([(k v) (in-hash results)])
|
|
(display (format "~a,~a,~a,~a\n" (player-name (first k)) (player-name (last k)) v (- GAMES-PER-MATCH v)) csv))
|
|
|
|
(close-output-port csv) |