Example #1
0
def doaction(action, piece):
	k = s = old = 0
	goal = piece[2] + action[0]
	r_p = numpy.rot90(piece[1],action[1])
	p = pt.getPiece()
	# if goal < 1:	goal = 1
	# elif goal > 9 and piece[0] == 1 and action[1] % 2:	goal = 9
	# elif goal > 8 and piece[0] == 1 and action[1] % 2 == 0:	goal = 6
	# elif goal > 8 and piece[0] != 1:	goal = 8

	if goal == p[2]:	k = 1

	if action[0] > 0 and goal != p[2]:
		pt.move('right')
	elif action[0] < 0 and goal != p[2]:
		pt.move('left')
	old = p[2]

	for i in range(len(p[1])):
		for j in range(len(p[1][i])):
			if r_p[i][j] != p[1][i][j]:
				s = 2
				break
			if s == 2:	break
		if s == 2:	break
	if s == 2:
		pt.rotate('ccw')
		s = 0
	else: s = 1

	if k == 1 and s == 1:	return 2
	else:
		return 1
Example #2
0
       [8,0,0,0,0,0,0,0,0,0,0,8],
       [8,0,0,0,0,0,0,0,0,0,0,8],
       [8,8,8,8,8,8,8,8,8,8,8,8],
       [8,8,8,8,8,8,8,8,8,8,8,8],
       [8,8,8,8,8,8,8,8,8,8,8,8],
       [8,8,8,8,8,8,8,8,8,8,8,8],
       [8,8,8,8,8,8,8,8,8,8,8,8],
       [8,8,8,8,8,8,8,8,8,8,8,8]]

b = pt.getBoard()

ans = pt.answer(pt.getBoard(),pt.getPiece()[1], pt.getPiece()[2], 0, 2)
#ans = pt.answer([2,3,4,5,4,3],pt.getPiece()[1], pt.getPiece()[2], 0, 2)

pprint(ans)
pt.rotate('ccw')
pt.rotate('ccw')

# メインループ
while(pt.alive()):
    #########################
    # ループごとの解析、操作をここに書く

    pt.drop()
    # 次のループへ
    pt.loop()
    step += 1


# 終了