ž áSs c@sÙddlTddlZdaetƒadZetadZda dZ dd„Z d d „Z d d „Z d d„Zdd„Zdd„Zdd„Zdd„ZeegZdd„Zdd„ZeƒdS(i(u*Nii2iicCs~xwtdtƒD]f}ttd|tƒtt|tƒƒjtƒtt|tdƒt|ttƒƒjtƒqWdS(Nii(urangeu BOARDSIZEuLineuPointuPPSu WINDOWSIZEudrawuwin(ui((u.\TicTacToe5.pyudrawGrids0udrawGridcCs%tt|tdt|tdƒS(ucoordinates of center of squarei(uPointuPPS(urowucol((u.\TicTacToe5.pyu rectCentersu rectCentercCstt|tt|tƒS(u'coordinates of top left of inset X or O(uPointuPPSuINSET(urowucol((u.\TicTacToe5.pyu rectUpperLeft!su rectUpperLeftcCs%tt|dtt|dtƒS(u+coordinates of bottom right of inset X or Oi(uPointuPPSuINSET(urowucol((u.\TicTacToe5.pyurectLowerRight%surectLowerRightcCs!tt|dtt|tƒS(u(coordinates of top right of inset X or Oi(uPointuPPSuINSET(urowucol((u.\TicTacToe5.pyurectUpperRight)surectUpperRightcCs!tt|tt|dtƒS(u*coordinates of bottom left of inset X or Oi(uPointuPPSuINSET(urowucol((u.\TicTacToe5.pyu rectLowerLeft-su rectLowerLeftcCsTtt||ƒt||ƒƒjtƒtt||ƒt||ƒƒjtƒdS(uDraw an X in the given squareN(uLineu rectUpperLefturectLowerRightudrawuwinu rectLowerLefturectUpperRight(urowucol((u.\TicTacToe5.pyudrawX3s(udrawXcCs+tt||ƒtdtƒjtƒdS(uDraw an O in the given squareiN(uCircleu rectCenteruPPSuINSETudrawuwin(urowucol((u.\TicTacToe5.pyudrawO8sudrawOcCs|tS(uFFind out row or colum number that corresponds to this pixel coordinate(uPPS(u pixelCoord((u.\TicTacToe5.pyu boardCoord?su boardCoordcCstdƒ}|dkr=t|ƒattƒattantdttƒadd„tDƒa t ƒd}x|ttkrþtj ƒ}t |j ƒƒt |jƒƒ}}t ||tkrrt|d||ƒ|dt ||<|d}qrqrWtjd ƒtjƒdS( Nu&Enter board size (Press Enter for 3): uuTicTacToe version 5cSs#g|]}dd„tDƒ‘qS(cSsg|] }t‘qS((uEMPTY(u.0uj((u.\TicTacToe5.pyu Os u#main...(u BOARDRANGE(u.0ui((u.\TicTacToe5.pyu Os umain..iiii(uinputuintu BOARDSIZEurangeu BOARDRANGEuPPSu WINDOWSIZEuGraphWinuwinu squareStateudrawGridugetMouseu boardCoordugetYugetXuEMPTYudrawListutimeusleepuclose(uuserSizeu turnCountu clickPointurowucol((u.\TicTacToe5.pyumainCs$      % umainiÿÿÿÿ(u zellegraphicsutimeu BOARDSIZEurangeu BOARDRANGEuPPSu WINDOWSIZEuINSETuNoneuwinuEMPTYudrawGridu rectCenteru rectUpperLefturectLowerRighturectUpperRightu rectLowerLeftudrawXudrawOudrawListu boardCoordumain(((u.\TicTacToe5.pyus(