得分:95
import mcpi.minecraft as minecraft
import mcpi.minecraftstuff as minecraftstuff
import mcpi.block as block
import time
import random
try_time = 20
point = 10
mc = minecraft.Minecraft.create()
pos = mc.player.getTilePos()
start_pos = pos
y_pos = pos.y
mc.setBlocks(pos.x-5,pos.y-1,pos.z-1,pos.x+5,pos.y+5,pos.z+31,block.GLASS.id)
count = 10
for i in range(10):
mc.setBlocks(pos.x-4,pos.y,pos.z,pos.x+4,pos.y+5,pos.z+30,block.AIR.id)
time.sleep(0.5)
count -= 1
mc.postToChat(count)
mc.player.setTilePos(start_pos)
mc.setBlocks(pos.x-5,pos.y-10,pos.z-1,pos.x+5,pos.y-1,pos.z+31,block.GRASS.id)
mc.setBlocks(pos.x-5,pos.y-1,pos.z+7,pos.x+5,pos.y-1,pos.z+7,block.STONE.id)
mc.setBlocks(pos.x-5,pos.y-1,pos.z+30,pos.x+5,pos.y-1,pos.z+30,block.DIAMOND_BLOCK.id)
while True:
try_time -= 0.1
pos = mc.player.getTilePos()
mc.postToChat(try_time)
if y_pos > pos.y:
mc.player.setTilePos(start_pos)
point -= random.randint(3,5)
try_time += 3
if mc.getBlock(pos.x,pos.y-1,pos.z) == block.STONE.id:
mc.setBlocks(pos.x-20,pos.y-2,pos.z+3,pos.x+20,pos.y-1,pos.z+6,block.AIR.id)
mc.setBlock(pos.x+random.randint(-3,3),pos.y-1,pos.z+5,block.COBBLESTONE.id)
mc.setBlocks(pos.x-20,pos.y-1,pos.z,pos.x+20,pos.y-1,pos.z,block.GRASS.id)
while not mc.getBlock(pos.x,pos.y-1,pos.z) == 57:
pos = mc.player.getTilePos()
mc.postToChat(try_time)
try_time -= 0.1
if y_pos > pos.y:
mc.player.setTilePos(start_pos)
point -= random.randint(3,5)
try_time += 3
point += try_time
mc.postToChat("Clearance!")
mc.postToChat("your score:%s"% int(round(point)))
point = int(round(point))
if point >= 22:
mc.postToChat("Very Good~")
mc.postToChat("Crafty Corssing")
break
此段程序在mc中建造了空间,倒计时10秒结束后,玩家往前移动到达终点,在这个过程中,玩家必须要经过一排石头路面,此时石头路面会小时,同时在前方生成一个鸿沟和一个石块,玩家必须利用石块加速跳跃过鸿沟到达终点才为胜利。
系统最终会给出得分和评级。
此段程序yijing非常完备,可以看出已经具有了一个程序员应该有的基本思维。