ž ºÂ¡S~ c@sÓddlTddlZdaetƒadZetadZda dd„Z dd „Z d d „Z d d „Z dd„Zdd„Zdd„Zdd„ZeegZdd„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.\TicTacToe4.pyudrawGrids0udrawGridcCs%tt|tdt|tdƒS(ucoordinates of center of squarei(uPointuPPS(urowucol((u.\TicTacToe4.pyu rectCentersu rectCentercCstt|tt|tƒS(u'coordinates of top left of inset X or O(uPointuPPSuINSET(urowucol((u.\TicTacToe4.pyu rectUpperLeftsu rectUpperLeftcCs%tt|dtt|dtƒS(u+coordinates of bottom right of inset X or Oi(uPointuPPSuINSET(urowucol((u.\TicTacToe4.pyurectLowerRightsurectLowerRightcCs!tt|dtt|tƒS(u(coordinates of top right of inset X or Oi(uPointuPPSuINSET(urowucol((u.\TicTacToe4.pyurectUpperRight"surectUpperRightcCs!tt|tt|dtƒS(u*coordinates of bottom left of inset X or Oi(uPointuPPSuINSET(urowucol((u.\TicTacToe4.pyu rectLowerLeft&su rectLowerLeftcCsTtt||ƒt||ƒƒjtƒtt||ƒt||ƒƒjtƒdS(uDraw an X in the given squareN(uLineu rectUpperLefturectLowerRightudrawuwinu rectLowerLefturectUpperRight(urowucol((u.\TicTacToe4.pyudrawX,s(udrawXcCs+tt||ƒtdtƒjtƒdS(uDraw an O in the given squareiN(uCircleu rectCenteruPPSuINSETudrawuwin(urowucol((u.\TicTacToe4.pyudrawO1sudrawOcCs|tS(uFFind out row or colum number that corresponds to this pixel coordinate(uPPS(u pixelCoord((u.\TicTacToe4.pyu boardCoord9su boardCoordcCsÞtdƒ}|dkr=t|ƒattƒattantdttƒat ƒd}xd|ttkrÂtj ƒ}t |j ƒƒt |j ƒƒ}}t|d||ƒ|d}q_WtjdƒtjƒdS(Nu&Enter board size (Press Enter for 3): uuTicTacToe version 4iiii(uinputuintu BOARDSIZEurangeu BOARDRANGEuPPSu WINDOWSIZEuGraphWinuwinudrawGridugetMouseu boardCoordugetYugetXudrawListutimeusleepuclose(uuserSizeu turnCountu clickPointurowucol((u.\TicTacToe4.pyumain>s      % umain(u zellegraphicsutimeu BOARDSIZEurangeu BOARDRANGEuPPSu WINDOWSIZEuINSETuNoneuwinudrawGridu rectCenteru rectUpperLefturectLowerRighturectUpperRightu rectLowerLeftudrawXudrawOudrawListu boardCoordumain(((u.\TicTacToe4.pyus&