Skip to content

Commit

Permalink
foo
Browse files Browse the repository at this point in the history
  • Loading branch information
arpruss committed Jul 14, 2016
1 parent c167db8 commit 47b2bf6
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 8 deletions.
Binary file modified python2-scripts.zip
Binary file not shown.
53 changes: 53 additions & 0 deletions python2-scripts/mcpipy/hanoi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from mc import *
from time import sleep

def drawPillar(n,h1,h2):
mc.setBlocks(pillarPos[n].x, pillarPos[n].y+h1, pillarPos[n].z,
pillarPos[n].x, pillarPos[n].y+h2, pillarPos[n].z, STONE)

def drawRing(n, height, ring):
size = ring
mc.setBlocks(pillarPos[n].x-size, pillarPos[n].y+height, pillarPos[n].z-size,
pillarPos[n].x+size, pillarPos[n].y+height, pillarPos[n].z+size, WOOL_RED)
drawPillar(n, height, height)

def eraseRing(n, height, ring):
size = ring
mc.setBlocks(pillarPos[n].x-size, pillarPos[n].y+height, pillarPos[n].z-size,
pillarPos[n].x+size, pillarPos[n].y+height, pillarPos[n].z+size, AIR)
drawPillar(n, height, height)

def moveRing(source, dest):
ring = pillars[source].pop()
eraseRing(source, len(pillars[source]), ring)
drawRing(dest, len(pillars[dest]), ring)
pillars[dest].append(ring)
sleep(delay)

def moveRings(source, dest, helper, count):
if count == 1:
moveRing(source, dest)
else:
moveRings(source, helper, dest, count-1)
moveRing(source, dest)
moveRings(helper, dest, source, count-1)

mc = Minecraft()

playerPos = mc.player.getPos()

delay = 0.25

pillarPos = [Vec3(playerPos.x-20,playerPos.y,playerPos.z-10),
Vec3(playerPos.x,playerPos.y,playerPos.z-10),
Vec3(playerPos.x+20,playerPos.y,playerPos.z-10)]

pillars = [ [8,7,6,5,4,3,2,1], [], [] ]

for i in range(3):
drawPillar(i,0,len(pillars[0])+1)

for i in range(len(pillars[0])):
drawRing(0, i, pillars[0][i])

moveRings(0, 2, 1, len(pillars[0]))
4 changes: 2 additions & 2 deletions python2-scripts/mcpipy/mcpi/security.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
AUTHENTICATION_USERNAME=None
AUTHENTICATION_PASSWORD=None
AUTHENTICATION_USERNAME=None
AUTHENTICATION_PASSWORD=None
4 changes: 2 additions & 2 deletions python2-scripts/mcpipy/minetris.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def drawNext(nextPieceState):
mc.setBlock(x+left, y+bottom, plane, nextPieceState.color)

def makePieceState():
n = 0 # randint(0, len(PIECES)-1)
n = randint(0, len(PIECES)-1)
return PieceState(PIECES[n], randint(0,3), Block(WOOL.id, (n+1) % 16))

def placePiece(state):
Expand Down Expand Up @@ -298,7 +298,7 @@ def game():
while not inputPause():
sleep(0.025)
clearInput()
restore(x, y)
restore(x, y, curPieceState)
descendTimer += time() - t0

if not fall:
Expand Down
Binary file modified python3-scripts.zip
Binary file not shown.
53 changes: 53 additions & 0 deletions python3-scripts/mcpipy/hanoi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from mc import *
from time import sleep

def drawPillar(n,h1,h2):
mc.setBlocks(pillarPos[n].x, pillarPos[n].y+h1, pillarPos[n].z,
pillarPos[n].x, pillarPos[n].y+h2, pillarPos[n].z, STONE)

def drawRing(n, height, ring):
size = ring
mc.setBlocks(pillarPos[n].x-size, pillarPos[n].y+height, pillarPos[n].z-size,
pillarPos[n].x+size, pillarPos[n].y+height, pillarPos[n].z+size, WOOL_RED)
drawPillar(n, height, height)

def eraseRing(n, height, ring):
size = ring
mc.setBlocks(pillarPos[n].x-size, pillarPos[n].y+height, pillarPos[n].z-size,
pillarPos[n].x+size, pillarPos[n].y+height, pillarPos[n].z+size, AIR)
drawPillar(n, height, height)

def moveRing(source, dest):
ring = pillars[source].pop()
eraseRing(source, len(pillars[source]), ring)
drawRing(dest, len(pillars[dest]), ring)
pillars[dest].append(ring)
sleep(delay)

def moveRings(source, dest, helper, count):
if count == 1:
moveRing(source, dest)
else:
moveRings(source, helper, dest, count-1)
moveRing(source, dest)
moveRings(helper, dest, source, count-1)

mc = Minecraft()

playerPos = mc.player.getPos()

delay = 0.25

pillarPos = [Vec3(playerPos.x-20,playerPos.y,playerPos.z-10),
Vec3(playerPos.x,playerPos.y,playerPos.z-10),
Vec3(playerPos.x+20,playerPos.y,playerPos.z-10)]

pillars = [ [8,7,6,5,4,3,2,1], [], [] ]

for i in range(3):
drawPillar(i,0,len(pillars[0])+1)

for i in range(len(pillars[0])):
drawRing(0, i, pillars[0][i])

moveRings(0, 2, 1, len(pillars[0]))
4 changes: 2 additions & 2 deletions python3-scripts/mcpipy/mcpi/security.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
AUTHENTICATION_USERNAME=None
AUTHENTICATION_PASSWORD=None
AUTHENTICATION_USERNAME=None
AUTHENTICATION_PASSWORD=None
4 changes: 2 additions & 2 deletions python3-scripts/mcpipy/minetris.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def drawNext(nextPieceState):
mc.setBlock(x+left, y+bottom, plane, nextPieceState.color)

def makePieceState():
n = 0 # randint(0, len(PIECES)-1)
n = randint(0, len(PIECES)-1)
return PieceState(PIECES[n], randint(0,3), Block(WOOL.id, (n+1) % 16))

def placePiece(state):
Expand Down Expand Up @@ -298,7 +298,7 @@ def game():
while not inputPause():
sleep(0.025)
clearInput()
restore(x, y)
restore(x, y, curPieceState)
descendTimer += time() - t0

if not fall:
Expand Down

0 comments on commit 47b2bf6

Please sign in to comment.