;;; ----------------------------------------------------------------------
;;;
;;; TTTUTILS: Utilities for Tic-Tac-Toe
;;;
;;; ----------------------------------------------------------------------
;;;
;;; This file is part of ILOG Talk.
;;; Inquiries to ILOG S.A.
;;;              9 rue de Verdun, BP 85,
;;;              94253 Gentilly Cedex, France.
;;;
;;; Copyright (c) 1994-1996 by ILOG
;;; ----------------------------------------------------------------------
;;;

(defdynamic .*verbosep*
  ;; True if we want the game to print out lots of messages.
  t)

(defun .message (who string rest: args)
  ;; If the dynamic variable .*verbosep* is t, print out the message
  ;; to stderr.
  (assert (or (symbolp who) (stringp who)))
  (assert (or (messagep string) (stringp string)))
  (when (dynamic .*verbosep*)
    (apply #'fprintf (stderr)
	   (sprintf () "%s: %s" who (string string)) args)))

(defun .print-board (state)
  (when (dynamic .*verbosep*)
    (flet ((.pline (base)
		   (printf "  %c | %c | %c\n"
			   (sref state (i+ base 0))
			   (sref state (i+ base 1))
			   (sref state (i+ base 2))))
	   (.psep () (printf " ---+---+---\n")))
      (.pline 0)
      (.psep)
      (.pline 3)
      (.psep)
      (.pline 6))))

(defun .get-host-name ()
  (let* ((p (pipe))
	 (pn (start-process "uname -n" p)))
    (prog1 (read-line p)
      (waitpid pn))))

(defglobal .ttt-port
  ;; There is a meaning to this!
  0x1cac0e)

(defglobal .ttt-host
  (.get-host-name))

