-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxmain
executable file
·36 lines (30 loc) · 1.22 KB
/
xmain
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#! /bin/sh
#|
exec racket -tm "$0" ${1+"$@"}
|#
#lang racket
;; ===================================================================================================
;; runs a complete sequential game with n players on localhost port 56789, compare with
;; $ ./xdist n
;; EXTERNAL SERVICES
(provide
;; StringN -> Void
;; accept a number beween MIN-PLAYERS and MAX-PLAYERS
main)
;; ===================================================================================================
;; DEPENDENCIES
(require "dealer.rkt" "player-external.rkt" "common.rkt")
;; ===================================================================================================
;; IMPLEMENTATION
(define (main n-string (name number->string))
(define n (string->number n-string))
(unless (and n (<= MIN-PLAYERS n MAX-PLAYERS))
(printf "usage `main.rkt n' for some n between ~a and ~a\n" MIN-PLAYERS MAX-PLAYERS)
(exit -1))
(define players (build-list n (lambda (i) (list (name i) (create-external)))))
(define dealer (create-dealer players))
(define results (send dealer run-game))
(printf "results\n------------------------\n")
(for ((r results))
(match-define `(,i ,id ,s) r)
(printf "~a player id: ~a score: ~a\n" i id s)))