3 ½©5YÐ ã@s–ddlZddlZdaetƒadZetadZda dZ dd„Z dd „Z d d „Z d d „Zdd„Zdd„Zdd„Zdd„ZeegZdd„Zdd„ZeƒdS)éNéédéécCslxftdtƒD]X}tjtjd|tƒtjt|tƒƒjtƒtjtj|tdƒtj|ttƒƒjtƒq WdS)z&Draw the horizontal and vertical linesrrN) ÚrangeÚ BOARDSIZEÚzgÚLineÚPointÚPPSÚ WINDOWSIZEÚdrawÚwin)Úi©rú./TicTacToe5.pyÚdrawGrids*rcCs$tjt|tdt|tdƒS)zcoordinates of center of squareé)rr r )ÚrowÚcolrrrÚ rectCentersrcCstjt|tt|tƒS)z'coordinates of top left of inset X or O)rr r ÚINSET)rrrrrÚ rectUpperLeft"srcCs$tjt|dtt|dtƒS)z+coordinates of bottom right of inset X or Or)rr r r)rrrrrÚrectLowerRight&srcCs tjt|dtt|tƒS)z(coordinates of top right of inset X or Or)rr r r)rrrrrÚrectUpperRight*srcCs tjt|tt|dtƒS)z*coordinates of bottom left of inset X or Or)rr r r)rrrrrÚ rectLowerLeft.srcCs@tjt||ƒt||ƒƒjtƒtjt||ƒt||ƒƒjtƒdS)zDraw an X in the given squareN)rr rrr rrr)rrrrrÚdrawX4srcCs$tjt||ƒtdtƒjtƒdS)zDraw an O in the given squarerN)rZCirclerr rr r)rrrrrÚdrawO9srcCs|tS)zFFind out row or colum number that corresponds to this pixel coordinate)r )Z pixelCoordrrrÚ boardCoord@srcCsÐtdƒ}|dkr(t|ƒattƒattatjdttƒa dd„tDƒa t ƒd}xl|ttkrºt j ƒ}t |jƒƒt |jƒƒ}}t ||tkrPt|d||ƒ|dt ||<|d}qPWt j ƒt jƒdS) Nz&Enter board size (Press Enter for 3): ÚzTicTacToe version 5cSsg|]}dd„tDƒ‘qS)cSsg|]}t‘qSr)ÚEMPTY)Ú.0Újrrrú Psz#main...)Ú BOARDRANGE)r!rrrrr#Pszmain..rrr)ÚinputÚintrrr$r r rZGraphWinrZ squareStaterZgetMouserZgetYZgetXr ÚdrawListÚclose)ZuserSizeZ turnCountZ clickPointrrrrrÚmainDs$ r)éÿÿÿÿ)Z zellegraphicsrÚtimerrr$r r rrr rrrrrrrrr'rr)rrrrÚs(