Files
katrain-qt/common.py
T
2020-04-27 23:03:42 +02:00

29 lines
699 B
Python

from typing import List, Any, Tuple
OUTPUT_ERROR = -1
OUTPUT_INFO = 0
OUTPUT_DEBUG = 1
OUTPUT_EXTRA_DEBUG = 2
bot_strategy_names = {
"dev": "P:Noise",
"strong": "Policy",
"influence": "P:Influence",
"territory": "P:Territory",
"balanced": "P:Pick",
"weighted": "P:Weighted",
"local": "P:Local",
"tenuki": "P:Tenuki",
}
def var_to_grid(array_var: List[Any], size: Tuple[int, int]) -> List[List[Any]]:
"""convert ownership/policy to grid format such that grid[y][x] is for move with coords x,y"""
ix = 0
grid = [[]] * size[1]
for y in range(size[1] - 1, -1, -1):
grid[y] = array_var[ix : ix + size[0]]
ix += size[0]
return grid