chess/test.ipynb
{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"import chess\n",
"import chess.uci\n",
"import chess.pgn\n",
"import sys,os\n",
"import numpy as np\n",
"import torch\n",
"import io\n",
"import pandas as pd\n",
"import concurrent\n",
"import dill\n",
"%load_ext autoreload\n",
"\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"import torch,dill\n",
"import matplotlib.pyplot as plt\n",
"from oil.utils.utils import Eval, cosLr\n",
"from chess_dataset import ChessDataset, legal_opponent_moves,legal_moves"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"startfen = chess.Board().fen()\n",
"r = torch.arange(64)[:,None,None]"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"tensor([[0., 0., 0., ..., 0., 0., 0.]])"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"torch.sum(r.float()*legal_moves(startfen).float(),dim=0)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"tensor([[ 0., 0., 0., 0., 0., 0., 0., 0.],\n",
" [ 0., 0., 0., 0., 0., 0., 0., 0.],\n",
" [ 9., 9., 11., 11., 12., 19., 14., 21.],\n",
" [ 8., 9., 10., 11., 12., 13., 14., 15.],\n",
" [ 0., 0., 0., 0., 0., 0., 0., 0.],\n",
" [ 0., 0., 0., 0., 0., 0., 0., 0.],\n",
" [ 0., 0., 0., 0., 0., 0., 0., 0.],\n",
" [ 0., 0., 0., 0., 0., 0., 0., 0.]])"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"torch.sum(r.float()*legal_moves(startfen).reshape(64,8,8).float(),dim=0)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"tensor([[ 0., 0., 0., 0., 0., 0., 0., 0.],\n",
" [ 0., 0., 0., 0., 0., 0., 0., 0.],\n",
" [ 0., 0., 0., 0., 0., 0., 0., 0.],\n",
" [ 0., 0., 0., 0., 0., 0., 0., 0.],\n",
" [ 48., 49., 50., 51., 52., 53., 54., 55.],\n",
" [105., 49., 107., 51., 52., 115., 54., 117.],\n",
" [ 0., 0., 0., 0., 0., 0., 0., 0.],\n",
" [ 0., 0., 0., 0., 0., 0., 0., 0.]])"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"torch.sum(r.float()*legal_opponent_moves(startfen).reshape(64,8,8).float(),dim=0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}