#################################################
# hw6.py
#
# Your name:
# Your andrew id:
#################################################

import cs112_m20_unit6_linter
import copy

#################################################
# Helper functions
#################################################

def almostEqual(d1, d2, epsilon=10**-7):
    # note: use math.isclose() outside 15-112 with Python version 3.5 or later
    return (abs(d2 - d1) < epsilon)

import decimal
def roundHalfUp(d):
    # Round to nearest with ties going away from zero.
    rounding = decimal.ROUND_HALF_UP
    # See other rounding options here:
    # https://docs.python.org/3/library/decimal.html#rounding-modes
    return int(decimal.Decimal(d).to_integral_value(rounding=rounding))

######################################################################
# ignore_rest: The autograder will ignore all code below here
######################################################################

import basic_graphics

def drawSudokuBoard(canvas, width, height, board, margin):
    canvas.create_text(width//2, height//2,
        text="Implement drawSudokuBoard!", font="Arial 20 bold")

def drawChessBoard(canvas, width, height, board, color, margin):
    canvas.create_text(width//2, height//2,
        text="Implement drawChessBoard!", font="Arial 20 bold")

#################################################################
# Test Functions
# Note: You must look at the output of these and confirm
# they work visually.
# You are not required to write tests for any helper functions
# you write for graphics problems
#################################################################

def getSudokuBoard0():
    return [
      [ 1, 2, 3, 4, 5, 6, 7, 8, 9],
      [ 5, 0, 8, 1, 3, 9, 6, 2, 4],
      [ 4, 9, 6, 8, 7, 2, 1, 5, 3],
      [ 9, 5, 2, 3, 8, 1, 4, 6, 7],
      [ 6, 4, 1, 2, 9, 7, 8, 3, 5],
      [ 3, 8, 7, 5, 6, 4, 0, 9, 1],
      [ 7, 1, 9, 6, 2, 3, 5, 4, 8],
      [ 8, 6, 4, 9, 1, 5, 3, 7, 2],
      [ 2, 3, 5, 7, 4, 8, 9, 1, 6]
    ]

def getSudokuBoard1():
    return [
        [1,2,3,4],
        [3,4,5,6],
        [7,8,9,10],
        [11,12,13,14]
    ]

def getStandardChessBoard():
    return [
        ['♜','♞','♝','♛','♚','♝','♞','♜'],
        ['♟','♟','♟','♟','♟','♟','♟','♟'],
        [' ']*8,
        [' ']*8,
        [' ']*8,
        [' ']*8,
        ['♙','♙','♙','♙','♙','♙','♙','♙'],
        ['♖','♘','♗','♕','♔','♗','♘','♖']
    ]

def getSimplifiedChessBoard():
    return [
        ['♜','♞','♝','♛','♚','♝','♞','♜'],
        ['♟','♟','♟','♟','♟','♟','♟','♟'],
        [' ']*8,
        [' ']*8,
        [' ']*8,
        ['♙','♙','♙','♙','♙','♙','♙','♙'],
        ['♖','♘','♗','♕','♔','♗','♘','♖']
    ]

def getSolitaireChessBoard():
    return [
        [' ']*4,
        [' ','♝',' ',' '],
        ['♜','♟',' ',' '],
        [' ',' ',' ','♞'],
    ]

def testDrawSudoku():
    print("Testing drawSudokuBoard()...")
    print("Since this is graphics, this test is not interactive.")
    print("Inspect each of these results manually to verify them.")
    basic_graphics.run(getSudokuBoard0(), 10, drawFn=drawSudokuBoard)
    basic_graphics.run(getSudokuBoard1(), 10, drawFn=drawSudokuBoard)
    print("Done!")

def testDrawChessBoard():
    print("Testing drawChessBoard()...")
    print("Since this is graphics, this test is not interactive.")
    print("Inspect each of these results manually to verify them.")
    basic_graphics.run(getStandardChessBoard(), (0,112,255), 20,
        drawFn=drawChessBoard,width=500,height=500
    )
    basic_graphics.run(getSolitaireChessBoard(), (255,150,0), 0,
        drawFn=drawChessBoard,width=150,height=150
    )
    basic_graphics.run(getSimplifiedChessBoard(), (10,255,0), 30,
        drawFn=drawChessBoard,width=300,height=260
    )
    print("Done!")

#################################################
# testAll and main
#################################################

def testAll():
    testDrawSudoku()
    testDrawChessBoard()

def main():
    cs112_m20_unit6_linter.lint()
    testAll()

if __name__ == "__main__":
    main()
