# Arup Guha
# 6/14/2017
# Draws a chessboard using the python turtle, adding x's in the forward diagonal.
# This board must be square.

# Edited in class on 6/10/2022 to add red checkers on every other square
# with no two adjacent squares having checkers.

import turtle

# Constants for our board
SIZE = 8
SQSIZE = 50
XSIZE = 42
DY = 30
XGAP = 10
STARTX = -200
STARTY = -200

def main():

    # Lot to draw so let's do it fast.
    turtle.speed(0)

    # Draw each row, from the bottom up.
    for row in range(SIZE+1):

        # Lift the pen, move to the bottom end, draw up.
        turtle.penup()
        turtle.setpos(STARTX, STARTY + SQSIZE*row)
        turtle.pendown()
        turtle.forward(SQSIZE*SIZE)

    # Face up.
    turtle.left(90)

    # Draw each column, from the bottom up, left to right.
    for col in range(SIZE+1):

        # Lift the pen, move to the bottom end, draw up.
        turtle.penup()
        turtle.setpos(STARTX + SQSIZE*col, STARTY)
        turtle.pendown()
        turtle.forward(SQSIZE*SIZE)

    turtle.fillcolor("red")
    
    # Loop to draw x's, from the bottom left to the top right.
    for row in range(SIZE):

        # Go to each square on this row.
        for col in range(SIZE):

            # This is how we check for a checkerboard pattern.
            if row%2 == col%2:

                # Get to right middle of square.
                myX = STARTX + (row+1)*SQSIZE
                myY = STARTY + col*SQSIZE + SQSIZE//2
                turtle.penup()
                
                turtle.setpos(myX, myY)
                turtle.pendown()

                # Draw a circle.
                turtle.begin_fill()
                turtle.circle(SQSIZE//2)
                turtle.end_fill()

main()
