<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Chessmaster Piece Tracker"""
import time


class ChessPiece(object):
    prefix = ''

    def __init__(self, position):
        self.position = position
        self.moves = []

    def algebraic_to_numeric(self, tile):
        axis_x = {0: 'a',
                  1: 'b',
                  2: 'c',
                  3: 'd',
                  4: 'e',
                  5: 'f',
                  6: 'g',
                  7: 'h'
                  }
        axis_y = {0: '1',
                  1: '2',
                  2: '3',
                  3: '4',
                  4: '5',
                  5: '6',
                  6: '7',
                  7: '8'
                  }
        
        tilelist = list(tile)
        self.newtile = {}
        keyindex = 0 
        for xkey, xvalue in axis_x.iteritems():
            if tilelist[0] == xvalue:
                keyindex = xkey
                self.newtile.update({xkey:0})
        for ykey, yvalue in axis_y.iteritems():
            if tilelist[1] == yvalue:
                self.newtile[keyindex] = ykey
                self.newtile = self.newtile.items().pop()
        if sum(self.newtile) >= 15:
            self.newtile = None
            return self.newtile
        else:
            return self.newtile
        
if __name__ == '__main__':
    piece = ChessPiece('g8')
    print piece.position
    print piece.algebraic_to_numeric('a2')
    print piece.algebraic_to_numeric('g8')
    print piece.algebraic_to_numeric('j9')<commit_msg>question<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Chessmaster Piece Tracker"""
import time
import pprint

class ChessPiece(object):
    prefix = ''

    def __init__(self, position):
        if not self.is_legal_move(position):
            excep = '`{}` is not a legal start position'
            raise ValueError(excep.format(position))
        else:
            self.position = position
            self.moves = []
            self.holdposition = position

    def algebraic_to_numeric(self, tile):
        axis_x = {'a': 0,
                  'b': 1,
                  'c': 2,
                  'd': 3,
                  'e': 4,
                  'f': 5,
                  'g': 6,
                  'h': 7
                  }
        axis_y = {'1': 0,
                  '2': 1,
                  '3': 2,
                  '4': 3,
                  '5': 4,
                  '6': 5,
                  '7': 6,
                  '8': 7
                  }
    
        tilelist = list(tile)
        newtile = []
        for item in tile:
            if item in axis_x:
                newtile.append(axis_x[item])
            elif item in axis_y:
                newtile.append(axis_y[item])
                newtile = tuple(newtile)
                self.position = newtile
            else:
                return None
        return newtile

    def is_legal_move(self, position):
        newposition = self.algebraic_to_numeric(position)
        if newposition is None:
            return False
        else:
            return True

    def move(self, position):
        newposition = self.prefix + position
        if self.is_legal_move(position):
            oldposition = self.prefix + self.holdposition
            newmove = []
            newmove.append(oldposition)
            newmove.append(newposition)
            newmove.append(time.time())
            newmove = tuple(newmove)
            self.moves.append(newmove)
            return self.moves
        
    


if __name__ == '__main__':
    piece = ChessPiece('a1')
    print piece.move('c4')
{'fraction_non_alphanumeric': 0.11419922949917446, 'fraction_numerical': 0.0170610897083104, 'mean_word_length': 1.1990320629159104, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7269146', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1035, 'n_words': 244}