This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import timeit | |
#STRING = 'addddddeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeewweeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffffffffffffffffffffffffffffffffffeeeeeeeeeeeeeeeeeeeeeeeeeerwerwerwerwetrwegfsghklujsahdflkiuahfgluhewihrlwelfhlwuhfawhrgfiuhagrliwrwreqwerqwerwefsdfasdfasdfasdfdsfddddddddddddddddeeeeeeeewwwwwwwwwwwwwddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd' | |
STRING = 'sss' | |
LOOP = 1000000 | |
TIMEIT_REPEAT = 30 | |
def test_join(): | |
data = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding=utf8 -*- | |
''' | |
* 參考 weijr 老師的 tetris in tkinter -- ``http://weijr-note.blogspot.tw/2007/04/tetris-program-in-lines.html`` | |
* full documents of Vpython -- ``http://vpython.org/contents/docs/visual/index.html`` | |
''' | |
# update: 2012.07.29 完成大部分功能 | |
# update: 2012.09.01 加入暫停與 hjkl 方向鍵控制 (Vim 操作練習?!) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import copy | |
import random | |
import sys | |
import Tkinter | |
#=============================================================================== | |
# global constant | |
#=============================================================================== | |
BOARD_WIDTH = 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding=utf8 -*- | |
import sys,random | |
from Tkinter import * | |
score,bw,bh,H,W=0,10,20,30,30 | |
blk = {0xf:"red",0x2e:"#0f0",0x27:"blue",0x47:"#ff0",0x66:"#0ff",0xC6:"#38f",0x6C:"#f0f"} | |
board = [ [0xf if j==bh else 0]*bw+[0xf]*2 for j in range(bh+2+1) ] | |
new_piece = lambda pc: ( [((z>>2)+1,z&3) for z in range(16) if (pc>>z)&1], 3, -2, pc ) | |
collide=lambda piece,px,py: [1 for (i,j) in piece if board[j+py][i+px]] #是否碰撞 | |
piece, px, py, pc = new_piece(random.choice(blk.keys())) # 第一個piece | |
def tick(e=None): |