示例#1
0
def do():
    c = maze.Connect("admin", "runda")
    p = 0
    for i in tqdm(range(1_000_001)):
        p += 1
        if p > 1_000_000:
            while True:
                c.move("a")
        else:
            i = random.choice(["a", "d", "s", "w"])
            c.move(i)
示例#2
0
def do():
    try:
        c = maze.Connect('oof2win2', 'yyytyy')

        while True:
            for i in range(c.height):
                for i in range(c.width - 2):
                    c.move('w')
                    c.move('w')
                    c.move('d')
                for i in range(c.width - 2):
                    c.move('w')
                    c.move('w')
                    c.move('a')
    except:
        do()
示例#3
0
import sys
import time

import maze

c = maze.Connect("admin", "jakjako")
c.wait()

def neighbors(vertex):
    #finds the neighbors of the vertex
    graph = [
        [],                 #0 - just to not need to redo most of the things here
        [2],                #1
        [1, 6, 3],          #2
        [2, 4, 5, 6, 8],    #3
        [3],                #4
        [3],                #5
        [2, 3, 7, 8],       #6
        [6, 8],             #7
        [3, 6, 7, 9, 10],   #8
        [8],                #9
        [8],                #10
    ]
    return graph[vertex]


#should work for everything on Protab2k2k
def dfs(start, end):
    #finds the path from start to end in a graph using the function neighbors(). will run forever if a path doesnt exist
    visited = set()
    path = [start]
示例#4
0
from tqdm import tqdm
from collections import Counter
import maze
import keyboard
import time
import sys
import random

#CAUTION: DOESNT WORK AS OF NOW

c = maze.Connect("oof2win2", "vylet")
area = []

#chest = 3
#wall  = 2
#blank = 0

height = c.height
width = c.width
x = c.x()
y = c.y()
print(x, y)

area = c.get_all()
orig_area = area

print('done collecting')
area[x][y] = -5  #set the starting thing to already walked


#prints the area out as a list
示例#5
0
import sys, time
from tqdm import tqdm

import maze

# FIFO array of jump and run, set with 'w' and 'd'
path = []
# array of where it was tried to jump from. starts with -1 to keep the index in range
tried = []

c = maze.Connect("admin", "archeopteryx")

# gets the whole array and then gets only the bottom line, with 1s and 0s of land and lava
whole = c.get_all()
arr = []
for line in whole:
    arr.append(line[-1])
# arr is now the row of 1s and 0s of land and lava


def move(type: str, amnt: int):
    key = ""
    if type == 'jump': key = "w"
    elif type == 'walk': key = "d"
    for i in range(amnt):
        c.move(key)


def run():
    stack = dfs()
    for i in tqdm(range(c.width - 100)):
示例#6
0
import maze
c = maze.Connect("oof2win2", "vyhlidka")

if not c.move('s'):
    print('error moving, error code', error)
width = c.width()
height = c.height()
示例#7
0
import maze
import random

c = maze.Connect('admin', 'vylet')

field = c.get_all()

moje_x = c.x()
moje_y = c.y()

keyCombos = [(0, -1, "w"), (1, 0, "d"), (0, 1, "s"), (-1, 0, "a")]

positions = {"curr": [moje_x, moje_y]}


def canMove(x, y, amm):
    return (field[y][x] == 0 or field[y][x] == 3) and ([x, y] not in amm
                                                       and x > 0 and y > 0)


def move(x, y, amm):
    if canMove(x, y, amm):
        positions["curr"] = [x, y]
        amm.append([x, y])


def calcPath():
    ammunation = [[positions['curr'][0],
                   positions['curr'][1]]]  # You cannot make this sound cooler
    while True:
        for moveN in keyCombos:
示例#8
0
import maze, time

from collections import deque

c = maze.Connect("admin", "blizko")
print(c.width, c.height)

field = c.get_all()

keyCombos = [(0, -1, "w"), (1, 0, "d"), (0, 1, "s"), (-1, 0, "a")]

def findEnd():
    for i,f in enumerate(field):
        for j, h in enumerate(f):
            if h == 3:
                return [j, h]

def neighbors(v):
    x,y = v

    ne = []
    for k in keyCombos: 
        if 0 <= y + k[1] < len(field) and 0 <= x + k[0] < len(field[y]) and field[y + k[1]][x + k[0]] != 2:
            magicNumbers = (x + k[0], y + k[1])
            ne.append(magicNumbers)
    return ne

def bfs(start, end):
    queue = deque([start])
    beenTo = set()
    beenTo.add(tuple(start))
示例#9
0
from collections import deque
import maze
import time

c = maze.Connect('oof2win2', 'nejbliz')  

arr    = c.get_all()   #the whole map
width  = c.width
height = c.height

def neighbors(v: list):
    #returns the neigbors of the x y coords in an array
    #return as [[n1_x, n1_y]] etc.
    n = []
    #the following if loops are responsible for keeping the neighbors in the range of the map size
    #they go x first to let the code go from left to right first, so it doesn't just get the shortest path
    global width, height, arr
    
    if v[0]+1 < width and arr[v[0]+1][v[1]] != 2: #if it is inside the area and is free/available
        n.append((v[0]+1, v[1]))
    if v[0]-1 >= 0 and arr[v[0]-1][v[1]] != 2: 
        n.append((v[0]-1, v[1]))
    if v[1]+1 < height and arr[v[0]][v[1]+1] != 2: 
        n.append((v[0], v[1]+1))
    if v[1]-1 >= 0 and arr[v[0]][v[1]-1] != 2: 
        n.append((v[0], v[1]-1))
    #print(n)
    return n

def getPos(thing: int):
    #function that finds the object from a numberical value given and returns x, y coords of that specific (or first) object
示例#10
0
import maze
import time

c = maze.Connect("oof2win2", "mallet")
w = c.width
h = c.height

dir = ['d', 'a']
for i in range(h):
    line = []
    a = i % 2
    for j in range(w):
        line.append(c.get(c.x(), j))
    for j in range(w):
        if line[j] == 0:
            c.move(dir[a])
        if line[j] == 2:
            for k in range(20 * 5):
                c.move(dir[a])
    b = c.get(c.x(), c.y() + 1)
    print(b)
    if b == 2:
        for k in range(20):
            c.move('s')
    if b == 0:
        c.move('s')
示例#11
0
import sys
from tqdm import tqdm

import maze

# FIFO array of jump and run, set with 'w' and 'd'
path = []
# array of where it was tried to jump from. starts with -1 to keep the index in range
tried = []

c = maze.Connect("oof2win2", "archeopteryx")

# gets the whole array and then gets only the bottom line, with 1s and 0s of land and lava
whole = c.get_all()
arr = []
for line in whole:
    arr.append(line[-1])
# arr is now the row of 1s and 0s of land and lava

c.wait()


def run():
    stack = dfs()
    for i in tqdm(range(c.width)):
        diff = stack[i + 1] - stack[i]
        if diff == 1:
            c.move("d")
        elif diff == 4:
            c.move("w")
            c.move("w")
import time

import maze
from tqdm import tqdm

c = maze.Connect("admin", "velociraptor")

field = c.get_all()

jmpLen = 4

inp = []

jumps = []

# for every line in the playing array add the bottom row of actual places where you jump on
for line in field:
    inp.append(line[-1])
print("Aiming to hit:", len(inp))

# movement functions within the live maze


def jump():
    c.move("w")


def move():
    c.move("d")

示例#13
0
文件: walk.py 项目: zhangjinde/mazec
import sys, readchar, maze

if len(sys.argv) < 3:
    print('Usage: {} login code [server]'.format(sys.argv[0]))
    sys.exit(1)

try:
    if len(sys.argv) >= 4:
        c = maze.Connect(sys.argv[1], sys.argv[2], sys.argv[3])
    else:
        c = maze.Connect(sys.argv[1], sys.argv[2])

    while True:
        key = readchar.readchar()
        if key == '\x03':
            break
        if not c.move(key):
            print(c.error)

except maze.MazeException as e:
    print(e)
示例#14
0
import maze
import time

c = maze.Connect('oof2win2', 'vylet')

while True:
    a = input('input: ')
    if a == 'w':
        c.move('w')
    elif a == 'a':
        c.move('a')
    elif a == 's':
        c.move('s')
    elif a == 'd':
        c.move('d')
示例#15
0
import sys
import time

import maze

# FIFO array of jump and run, set with 'w' and 'd'
path = []
# array of where it was tried to jump from. starts with -1 to keep the index in range
tried = []

c = maze.Connect("oof2win2", "velociraptor")
# gets the whole array and then gets only the bottom line, with 1s and 0s of land and lava
whole = c.get_all()
arr = []
for line in whole:
    arr.append(line[-1])
# arr is now the row of 1s and 0s of land and lava


def run():
    stack = dfs()
    for i in range(c.width):
        print(i)  # progress bar
        diff = stack[i + 1] - stack[i]
        if diff == 1:
            c.move("d")
        elif diff == 4:
            c.move("w")
            c.move("w")
            c.move("w")
            c.move("w")
示例#16
0
import maze
import random

moves = ["w", "a", "s", "d"]

def canMove(x,y,field):
    return field[y][x] == 0 or field[y][x] == 3

c = maze.Connect('admin', 'tojedalka')


c.wait()
for i in range(300):
    moje_x = c.x()
    moje_y = c.y()
    if not c.move("d"):
        if not c.move("s"):
            if not c.move("a"):
                c.move("w")
while True:
    i = input("?")
    c.move(i)
示例#17
0
import maze
import time

c = maze.Connect('admin', 'velociraptor')

field = c.get_all()

inp = []


def nextPos():
    if inp[c.x() + 1] == 1 and inp[c.x() + 2] == 1 and inp[
            c.x() + 3] == 1 and inp[c.x() + 4] == 1:
        return False
    else:
        if inp[c.x() + 4] == 0:
            return False
        else:
            for i in range(4):
                if inp[c.x() + i] == 1 and inp[c.x() + 4] == 0:
                    if inp[c.x() + i + 4] == 0 and inp[c.x() + 4] == 1:
                        return False
                    elif inp[c.x() + i + 8] == 0 and inp[c.x() + 4] == 1:
                        return False
                    else:
                        return True


def willHit():
    def jump():
        c.move("w")
示例#18
0
from collections import deque
import maze
import time
import random

c = maze.Connect('oof2win2', 'runda')


def randomm():
    a = random.randint(-1000, 5000)
    b = random.randrange(-1000, 5000)
    return (a, b)


def goTo(gx, gy):
    while gx != 0 and gy != 0:
        print(c.x(), c.y())
        if gx > 0:
            c.move('w')
            gx -= 1
        elif gx < 0:
            c.move('s')
            gx += 1
        if gy > 0:
            c.move('d')
        elif gy < 0:
            c.move('a')


def randomPath():
    gx, gy = randomm()