ž ˆΒ‘St c@sΗddlTddlZdaetƒadZetadZda dd„Z dd „Z d d „Z d d „Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„ZeƒdS(i(u*Nii–icCs~xwtdtƒD]f}ttd|tƒtt|tƒƒjtƒtt|tdƒt|ttƒƒjtƒqWdS(Nii(urangeu BOARDSIZEuLineuPointuPPSu WINDOWSIZEudrawuwin(ui((u.\TicTacToe3.pyudrawGrids0udrawGridcCs%tt|tdt|tdƒS(ucoordinates of center of squarei(uPointuPPS(urowucol((u.\TicTacToe3.pyu rectCentersu rectCentercCstt|tt|tƒS(u'coordinates of top left of inset X or O(uPointuPPSuINSET(urowucol((u.\TicTacToe3.pyu rectUpperLeftsu rectUpperLeftcCs%tt|dtt|dtƒS(u+coordinates of bottom right of inset X or Oi(uPointuPPSuINSET(urowucol((u.\TicTacToe3.pyurectLowerRightsurectLowerRightcCs!tt|dtt|tƒS(u(coordinates of top right of inset X or Oi(uPointuPPSuINSET(urowucol((u.\TicTacToe3.pyurectUpperRight!surectUpperRightcCs!tt|tt|dtƒS(u*coordinates of bottom left of inset X or Oi(uPointuPPSuINSET(urowucol((u.\TicTacToe3.pyu rectLowerLeft%su rectLowerLeftcCsTtt||ƒt||ƒƒjtƒtt||ƒt||ƒƒjtƒdS(uDraw an X in the given squareN(uLineu rectUpperLefturectLowerRightudrawuwinu rectLowerLefturectUpperRight(urowucol((u.\TicTacToe3.pyudrawX+s(udrawXcCs+tt||ƒtdtƒjtƒdS(uDraw an O in the given squareiN(uCircleu rectCenteruPPSuINSETudrawuwin(urowucol((u.\TicTacToe3.pyudrawO0sudrawOcCsWxPtD]H}x?tD]7}||ddkr>t||ƒqt||ƒqWqWdS(u)Fill the board with alternating Xs and OsiiN(u BOARDRANGEudrawXudrawO(urowucol((u.\TicTacToe3.pyu fillBoard4s   u fillBoardcCsxtdƒ}|dkr=t|ƒattƒattantdttƒat ƒt ƒt j dƒtj ƒdS(Nu&Enter board size (Press Enter for 3): uuTicTacToe version 3i(uinputuintu BOARDSIZEurangeu BOARDRANGEuPPSu WINDOWSIZEuGraphWinuwinudrawGridu fillBoardutimeusleepuclose(uuserSize((u.\TicTacToe3.pyumain=s      umain(u zellegraphicsutimeu BOARDSIZEurangeu BOARDRANGEuPPSu WINDOWSIZEuINSETuNoneuwinudrawGridu rectCenteru rectUpperLefturectLowerRighturectUpperRightu rectLowerLeftudrawXudrawOu fillBoardumain(((u.\TicTacToe3.pyus$