Example #1
0
def _status(args):
    path = raspberryturk.lib_path('status.txt')
    if args.watch:
        command = "watch -d -t -n 0.5 cat {}".format(path)
        os.system(command)
    else:
        with io.open(path, 'r', encoding='utf8') as f:
            print f.read()
Example #2
0
 def _write_status(self):
     b = game.get_board()
     cbm = self._chess_camera.current_colored_board_mask()
     cbm_board = pawn_board_from_colored_board_mask(cbm)
     pgn = game.pgn()
     formatted_datetime = time.strftime("%x %X")
     text = str("\n\n").join(
         [formatted_datetime,
          str(cbm_board), str(b), pgn])
     with io.open(lib_path('status.txt'), 'w', encoding='utf8') as f:
         f.write(text)
Example #3
0
import socket
import sys
import os
import logging
import argparse
from raspberryturk import lib_path, setup_console_logging, RaspberryTurkError

SERVER_ADDRESS = lib_path('human_player_uds_socket')


class HumanPlayer(object):
    def __init__(self):
        try:
            os.unlink(SERVER_ADDRESS)
        except OSError:
            if os.path.exists(SERVER_ADDRESS):
                raise
        self._sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
        self._sock.bind(SERVER_ADDRESS)
        self._sock.listen(1)

    def select_move(self, board):
        moves_dict = {str(move): move for move in board.legal_moves}
        move = None
        while move is None:
            connection, client_address = self._sock.accept()
            try:
                data = connection.recv(4)
                move = moves_dict.get(data, None)
                connection.sendall("selected move: {}".format(move))
            finally:
def _chessboard_perspective_transform_path():
    return lib_path('chessboard_perspective_transform.npy')