Welcome, Guest

Author Topic: Coding  (Read 97426 times)

Darvince

  • *****
  • Posts: 1807
  • two dimensional time
Re: Python
« Reply #30 on: October 23, 2012, 10:24:38 PM »
according to kip he is not going to learn java because
python can withstand my shitty syntax and programming stype
   >make ALL the variables global
[22:09]   Darvince   kol vh
   vh   >arrays? pffft just use 1000000 variables

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #31 on: October 23, 2012, 10:28:32 PM »
in this version the change -- sometimes

Code: [Select]
import random
import os

os.sys.setrecursionlimit(9000)

#counts stuck attempts
arrayfinish=[]

def setup():
    global n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz, xn, xp, yn, yp, zn, zp, n
    #position of bot
    posx=0
    posy=0
    posz=0
    #array for occupied spaces
    blockx=[]
    blocky=[]
    blockz=[]
    #n_x, n_y, n_z
    n_x = 0
    n_y = 0
    n_z = 0
    #step count
    n=0
    #directions = none
    xn=0
    xp=0
    yn=0
    yp=0
    zn=0   
    zp=0

#setting xn, xp, yn, yp, zn, and zp
def direct(n_x, n_y, n_z, posx, posy, posz):
    global xn, xp, yn, yp, zn, zp
    if (n_x < len(blockx) or n_y < len(blocky) or n_z < len(blockz)):       
        #check x n-egative and p-ositive side
        if posx - blockx[n_x] == 1 and posy == blocky[n_y] and posz == blockz[n_z]:
            xn = 1
        if posx - blockx[n_x] == -1 and posy == blocky[n_y] and posz == blockz[n_z]:
            xp = 1
        #check y n-egative and p-ositive side
        if posy - blockx[n_y] == 1 and posx == blocky[n_x] and posz == blockz[n_z]:
            yn = 1
        if posy - blockx[n_y] == -1 and posx == blocky[n_x] and posz == blockz[n_z]:
            yp = 1
        #check z n-egative and p-ositive side
        if posz - blockx[n_z] == 1 and posy == blocky[n_y] and posy == blockz[n_y]:
            zn = 1
        if posz - blockx[n_z] == -1 and posy == blocky[n_y] and posy == blockz[n_y]:
            zp = 1
        #advance one position and redo
        n_x=n_x+1
        n_y=n_y+1
        n_z=n_z+1
        print n_x, 'n_x'
        print len(blockx), 'len'
        print xn, xp, yn, yp, zn, zp, 'list'
        print posx, posy, posz
        #^always stays as zero
        direct(n_x, n_y, n_z, posx, posy, posz)
    else: bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z)
       

#bot movement
def bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z):
    #generate random direction
    direction=random.randint(0,5)
    #the directions
    if xn == 1 and xp == 1 and yn == 1 and yp == 1 and zn == 1 and zp == 1:
        finished(n)
    #check if direction is blocked, if not, move there.
    elif direction == 0 and xn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx-1
        n=n+1   
    elif direction == 1 and xp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx+1
        n=n+1
    elif direction == 2 and yn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy-1
        n=n+1
    elif direction == 3 and yp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy+1
        n=n+1
    elif direction == 4 and zn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz-1
        n=n+1
    elif direction == 5 and zp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz+1
        n=n+1
    #if the space is blocked, rerun
    else:
        bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z)
    xn=0
    xp=0
    yn=0
    yp=0
    zn=0
    zp=0
    n_x=0
    n_y=0
    n_z=0
    direct(n_x, n_y, n_z, posx, posy, posz)


    #after bot is stuck
def finished(steps):
    global posx, posy, posz, n
    arrayfinish.append(steps)
    posx=0
    posy=0
    posz=0
    n=0

def mainloop():
    global xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z
    setup()
    direct(n_x, n_y, n_z, posx, posy, posz)
    #bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z)
    finished(n)
    os.system('pause')
    print arrayfinish
    os.system('pause')


mainloop()

os.system('pause')

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #32 on: October 23, 2012, 10:33:58 PM »
still not working

Code: [Select]
import random
import os

os.sys.setrecursionlimit(9000)

#counts stuck attempts
arrayfinish=[]

def setup():
    global n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz, xn, xp, yn, yp, zn, zp, n
    #position of bot
    posx=0
    posy=0
    posz=0
    #array for occupied spaces
    blockx=[]
    blocky=[]
    blockz=[]
    #n_x, n_y, n_z
    n_x = 0
    n_y = 0
    n_z = 0
    #step count
    n=0
    #directions = none
    xn=0
    xp=0
    yn=0
    yp=0
    zn=0   
    zp=0

#setting xn, xp, yn, yp, zn, and zp
def direct(n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz):
    global xn, xp, yn, yp, zn, zp
    if (n_x < len(blockx) or n_y < len(blocky) or n_z < len(blockz)):       
        #check x n-egative and p-ositive side
        if posx - blockx[n_x] == 1 and posy == blocky[n_y] and posz == blockz[n_z]:
            xn = 1
        if posx - blockx[n_x] == -1 and posy == blocky[n_y] and posz == blockz[n_z]:
            xp = 1
        #check y n-egative and p-ositive side
        if posy - blockx[n_y] == 1 and posx == blocky[n_x] and posz == blockz[n_z]:
            yn = 1
        if posy - blockx[n_y] == -1 and posx == blocky[n_x] and posz == blockz[n_z]:
            yp = 1
        #check z n-egative and p-ositive side
        if posz - blockx[n_z] == 1 and posy == blocky[n_y] and posy == blockz[n_y]:
            zn = 1
        if posz - blockx[n_z] == -1 and posy == blocky[n_y] and posy == blockz[n_y]:
            zp = 1
        #advance one position and redo
        n_x=n_x+1
        n_y=n_y+1
        n_z=n_z+1
        print n_x, 'n_x'
        print len(blockx), 'len'
        print xn, xp, yn, yp, zn, zp, 'list'
        print posx, posy, posz
        #^always stays as constant!
        direct(n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz)
    else: bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z)
       

#bot movement
def bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z):
    #generate random direction
    direction=random.randint(0,5)
    #the directions
    if xn == 1 and xp == 1 and yn == 1 and yp == 1 and zn == 1 and zp == 1:
        finished(n)
    #check if direction is blocked, if not, move there.
    elif direction == 0 and xn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx-1
        n=n+1   
    elif direction == 1 and xp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx+1
        n=n+1
    elif direction == 2 and yn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy-1
        n=n+1
    elif direction == 3 and yp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy+1
        n=n+1
    elif direction == 4 and zn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz-1
        n=n+1
    elif direction == 5 and zp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz+1
        n=n+1
    #if the space is blocked, rerun
    else:
        bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z)
    xn=0
    xp=0
    yn=0
    yp=0
    zn=0
    zp=0
    n_x=0
    n_y=0
    n_z=0
    direct(n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz)


    #after bot is stuck
def finished(steps):
    global posx, posy, posz, n
    arrayfinish.append(steps)
    posx=0
    posy=0
    posz=0
    n=0

def mainloop():
    global xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z
    setup()
    direct(n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz)
    #bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z)
    finished(n)
    os.system('pause')
    print arrayfinish
    os.system('pause')


mainloop()

os.system('pause')

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #33 on: October 23, 2012, 10:37:26 PM »
worse, but better in a way

Code: [Select]
import random
import os

os.sys.setrecursionlimit(9000)

#counts stuck attempts
arrayfinish=[]

def setup():
    global n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz, xn, xp, yn, yp, zn, zp, n
    #position of bot
    posx=0
    posy=0
    posz=0
    #array for occupied spaces
    blockx=[]
    blocky=[]
    blockz=[]
    #n_x, n_y, n_z
    n_x = 0
    n_y = 0
    n_z = 0
    #step count
    n=0
    #directions = none
    xn=0
    xp=0
    yn=0
    yp=0
    zn=0   
    zp=0

#setting xn, xp, yn, yp, zn, and zp
def direct(xn, xp, yn, yp, zn, zp, n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz):
    if (n_x < len(blockx) or n_y < len(blocky) or n_z < len(blockz)):       
        #check x n-egative and p-ositive side
        if posx - blockx[n_x] == 1 and posy == blocky[n_y] and posz == blockz[n_z]:
            xn = 1
        if posx - blockx[n_x] == -1 and posy == blocky[n_y] and posz == blockz[n_z]:
            xp = 1
        #check y n-egative and p-ositive side
        if posy - blockx[n_y] == 1 and posx == blocky[n_x] and posz == blockz[n_z]:
            yn = 1
        if posy - blockx[n_y] == -1 and posx == blocky[n_x] and posz == blockz[n_z]:
            yp = 1
        #check z n-egative and p-ositive side
        if posz - blockx[n_z] == 1 and posy == blocky[n_y] and posy == blockz[n_y]:
            zn = 1
        if posz - blockx[n_z] == -1 and posy == blocky[n_y] and posy == blockz[n_y]:
            zp = 1
        #advance one position and redo
        n_x=n_x+1
        n_y=n_y+1
        n_z=n_z+1
        print n_x, 'n_x'
        print len(blockx), 'len'
        print xn, xp, yn, yp, zn, zp, 'list'
        print posx, posy, posz
        #^always stays as constant!
        direct(xn, xp, yn, yp, zn, zp, n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz)
    else: bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z)
       

#bot movement
def bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z):
    #generate random direction
    direction=random.randint(0,5)
    #the directions
    if xn == 1 and xp == 1 and yn == 1 and yp == 1 and zn == 1 and zp == 1:
        finished(n)
    #check if direction is blocked, if not, move there.
    elif direction == 0 and xn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx-1
        n=n+1   
    elif direction == 1 and xp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx+1
        n=n+1
    elif direction == 2 and yn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy-1
        n=n+1
    elif direction == 3 and yp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy+1
        n=n+1
    elif direction == 4 and zn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz-1
        n=n+1
    elif direction == 5 and zp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz+1
        n=n+1
    #if the space is blocked, rerun
    else:
        bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z)
    xn=0
    xp=0
    yn=0
    yp=0
    zn=0
    zp=0
    n_x=0
    n_y=0
    n_z=0
    direct(xn, xp, yn, yp, zn, zp, n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz)


    #after bot is stuck
def finished(steps):
    global posx, posy, posz, n
    arrayfinish.append(steps)
    posx=0
    posy=0
    posz=0
    n=0

def mainloop():
    global xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z
    setup()
    direct(xn, xp, yn, yp, zn, zp, n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz)
    finished(n)
    os.system('pause')
    print arrayfinish
    os.system('pause')


mainloop()

os.system('pause')

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #34 on: October 23, 2012, 10:52:40 PM »
Code: [Select]
import random
import os

os.sys.setrecursionlimit(9000)

#counts stuck attempts
arrayfinish=[]

def setup():
    global n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz, xn, xp, yn, yp, zn, zp, n
    #position of bot
    posx=0
    posy=0
    posz=0
    #array for occupied spaces
    blockx=[]
    blocky=[]
    blockz=[]
    #n_x, n_y, n_z
    n_x = 0
    n_y = 0
    n_z = 0
    #step count
    n=0
    #directions = none
    xn=0
    xp=0
    yn=0
    yp=0
    zn=0   
    zp=0

#setting xn, xp, yn, yp, zn, and zp
def direct(xn, xp, yn, yp, zn, zp, n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz):
    if n_x < len(blockx) and n_y < len(blocky) and n_z < len(blockz):       
        #check x n-egative and p-ositive side
        if (posx - blockx[n_x] == 1 and posy == blocky[n_y] and posz == blockz[n_z]):
            xn = 1
        if (posx - blockx[n_x] == -1 and posy == blocky[n_y] and posz == blockz[n_z]):
            xp = 1
        #check y n-egative and p-ositive side
        if (posy - blockx[n_y] == 1 and posx == blocky[n_x] and posz == blockz[n_z]):
            yn = 1
        if (posy - blockx[n_y] == -1 and posx == blocky[n_x] and posz == blockz[n_z]):
            yp = 1
        #check z n-egative and p-ositive side
        if (posz - blockx[n_z] == 1 and posy == blocky[n_y] and posy == blockz[n_y]):
            zn = 1
        if (posz - blockx[n_z] == -1 and posy == blocky[n_y] and posy == blockz[n_y]):
            zp = 1
        #advance one position and redo
        n_x=n_x+1
        n_y=n_y+1
        n_z=n_z+1
        print n_x, 'n_x'
        print len(blockx), 'len'
        print xn, xp, yn, yp, zn, zp, 'list'
        print posx, posy, posz
        #^always stays as constant!
        direct(xn, xp, yn, yp, zn, zp, n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz)
    else: bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z)
       

#bot movement
def bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z):
    #generate random direction
    direction=random.randint(0,5)
    #the directions
    if xn == 1 and xp == 1 and yn == 1 and yp == 1 and zn == 1 and zp == 1:
        finished(n)
    #check if direction is blocked, if not, move there.
    elif direction == 0 and xn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx-1
        n=n+1   
    elif direction == 1 and xp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx+1
        n=n+1
    elif direction == 2 and yn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy-1
        n=n+1
    elif direction == 3 and yp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy+1
        n=n+1
    elif direction == 4 and zn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz-1
        n=n+1
    elif direction == 5 and zp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz+1
        n=n+1
    #if the space is blocked, rerun
    else:
        bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z)
    xn=0
    xp=0
    yn=0
    yp=0
    zn=0
    zp=0
    n_x=0
    n_y=0
    n_z=0
    direct(xn, xp, yn, yp, zn, zp, n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz)


    #after bot is stuck
def finished(steps):
    global posx, posy, posz, n
    arrayfinish.append(steps)
    posx=0
    posy=0
    posz=0
    n=0

def mainloop():
    global xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z
    setup()
    direct(xn, xp, yn, yp, zn, zp, n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz)
    finished(n)
    os.system('pause')
    print arrayfinish
    os.system('pause')


mainloop()

os.system('pause')
« Last Edit: October 23, 2012, 10:59:59 PM by mudkipz »

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #35 on: October 23, 2012, 11:03:52 PM »
what i'm seeing is that xn = 1 does not seem to be effective.

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #36 on: October 24, 2012, 12:03:50 PM »
ok the cubes seem to have been working properly, they've moved in this order:

start
go left
to up
go left
go back
go back
go down
go right
go right
go right

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #37 on: October 24, 2012, 12:08:46 PM »
hmm this is strange:

blockx position changes 10 times (expected 6)
blocky position changes 4 times (expected 6)
blockz position changes 3 times (expected 6)
coincidence?

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #38 on: October 24, 2012, 01:03:45 PM »
updated version

Code: [Select]
import random
import os

#os.sys.setrecursionlimit(9000)
import pdb; pdb.set_trace()


#counts stuck attempts
arrayfinish=[]

def setup():
    global n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz, xn, xp, yn, yp, zn, zp, n, finish
    #position of bot
    posx=0
    posy=0
    posz=0
    #array for occupied spaces
    blockx=[]
    blocky=[]
    blockz=[]
    #n_x, n_y, n_z
    n_x = 0
    n_y = 0
    n_z = 0
    #step count
    n=0
    #directions = none
    xn=0
    xp=0
    yn=0
    yp=0
    zn=0   
    zp=0
    finish = False

#setting xn, xp, yn, yp, zn, and zp
def direct(xn, xp, yn, yp, zn, zp, n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz):
    #check x n-egative and p-ositive side
    if (posx - blockx[n_x] == 1 and posy == blocky[n_y] and posz == blockz[n_z]):
        print '---------------------------------------'
        xn = 1
        print xn
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    if (posx - blockx[n_x] == -1 and posy == blocky[n_y] and posz == blockz[n_z]):
        print '---------------------------------------'
        xp = 1
        print xp
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    #check y n-egative and p-ositive side
    if (posy - blockx[n_y] == 1 and posx == blocky[n_x] and posz == blockz[n_z]):
        print '---------------------------------------'
        yn = 1
        print yn
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    if (posy - blockx[n_y] == -1 and posx == blocky[n_x] and posz == blockz[n_z]):
        print '---------------------------------------'
        yp = 1
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    #check z n-egative and p-ositive side
    if (posz - blockx[n_z] == 1 and posy == blocky[n_y] and posy == blockz[n_y]):
        print '---------------------------------------'
        zn = 1
        print zn
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    if (posz - blockx[n_z] == -1 and posy == blocky[n_y] and posy == blockz[n_y]):
        print '---------------------------------------'
        zp = 1
        print zp
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    #advance one position and redo
    n_x=n_x+1
    n_y=n_y+1
    n_z=n_z+1
    print n_x, 'n_x'
    print len(blockx), 'len'
    print xn, xp, yn, yp, zn, zp, 'list'
   
#bot movement
def bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,finish):
    #generate random direction
    direction=random.randint(0,5)
    #the directions
    if xn == 1 and xp == 1 and yn == 1 and yp == 1 and zn == 1 and zp == 1:
        finish = True
    #check if direction is blocked, if not, move there.
    elif direction == 0 and xn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx-1
        n=n+1   
    elif direction == 1 and xp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx+1
        n=n+1
    elif direction == 2 and yn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy-1
        n=n+1
    elif direction == 3 and yp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy+1
        n=n+1
    elif direction == 4 and zn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz-1
        n=n+1
    elif direction == 5 and zp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz+1
        n=n+1
    else:
        #if error, rerun
        bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,finish)
    #reset variables
    xn = 0
    xp = 0
    yn = 0
    yp = 0
    zn = 0
    zp = 0
    n_x = 0
    n_y = 0
    n_z = 0

    #after bot is stuck
def finished(steps):
    global posx, posy, posz, n
    arrayfinish.append(steps)
    posx=0
    posy=0
    posz=0
    n=0

def mainloop():
    global xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z,finish
    setup()
    while finish == False:
        bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,finish)
        while n_x < len(blockx) and n_y < len(blocky) and n_z < len(blockz):
            direct(xn, xp, yn, yp, zn, zp, n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz)
    finished(n)
    print arrayfinish


mainloop()

os.system('pause')

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #39 on: October 24, 2012, 02:11:41 PM »
strange

when i run:

Code: [Select]
   while finish == False:
        print 'start loop'
        bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,finish)
        print 'finished bot'    
        while n_x < len(blockx) and n_y < len(blocky) and n_z < len(blockz):
            print 'start direct'
            direct(xn, xp, yn, yp, zn, zp, n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz)
            print 'finish direct'

start direct and finish direct are printed but start loop and finished bot don't. any help?


vvv full version of code vvv
Code: [Select]
import random
import os

#os.sys.setrecursionlimit(9000)
#import pdb; pdb.set_trace()


#counts stuck attempts
arrayfinish=[]

def setup():
    global n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz, xn, xp, yn, yp, zn, zp, n, finish
    #position of bot
    posx=0
    posy=0
    posz=0
    #array for occupied spaces
    blockx=[]
    blocky=[]
    blockz=[]
    #n_x, n_y, n_z
    n_x = 0
    n_y = 0
    n_z = 0
    #step count
    n=0
    #directions = none
    xn=0
    xp=0
    yn=0
    yp=0
    zn=0    
    zp=0
    finish = False

#setting xn, xp, yn, yp, zn, and zp
def direct(xn, xp, yn, yp, zn, zp, n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz):
    #check x n-egative and p-ositive side
    if (posx - blockx[n_x] == 1 and posy == blocky[n_y] and posz == blockz[n_z]):
        print '---------------------------------------'
        xn = 1
        print xn
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    if (posx - blockx[n_x] == -1 and posy == blocky[n_y] and posz == blockz[n_z]):
        print '---------------------------------------'
        xp = 1
        print xp
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    #check y n-egative and p-ositive side
    if (posy - blockx[n_y] == 1 and posx == blocky[n_x] and posz == blockz[n_z]):
        print '---------------------------------------'
        yn = 1
        print yn
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    if (posy - blockx[n_y] == -1 and posx == blocky[n_x] and posz == blockz[n_z]):
        print '---------------------------------------'
        yp = 1
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    #check z n-egative and p-ositive side
    if (posz - blockx[n_z] == 1 and posy == blocky[n_y] and posy == blockz[n_y]):
        print '---------------------------------------'
        zn = 1
        print zn
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    if (posz - blockx[n_z] == -1 and posy == blocky[n_y] and posy == blockz[n_y]):
        print '---------------------------------------'
        zp = 1
        print zp
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    #advance one position and redo
    n_x=n_x+1
    n_y=n_y+1
    n_z=n_z+1
    print n_x, 'n_x'
    print len(blockx), 'len'
    print xn, xp, yn, yp, zn, zp, 'list'
    
#bot movement
def bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,finish):
    #generate random direction
    direction=random.randint(0,5)
    #the directions
    print 'line 83'
    if xn == 1 and xp == 1 and yn == 1 and yp == 1 and zn == 1 and zp == 1:
        finish = True
        #check if direction is blocked, if not, move there.
    elif direction == 0 and xn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx-1
        n=n+1
        print 'line 93'
    elif direction == 1 and xp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx+1
        n=n+1
        print 'line 100'
    elif direction == 2 and yn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy-1
        n=n+1
        print 'line 107'
    elif direction == 3 and yp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy+1
        n=n+1
        print 'line 114'
    elif direction == 4 and zn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz-1
        n=n+1
        print 'line 121'
    elif direction == 5 and zp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz+1
        n=n+1
        print 'line 128'
    else:
        #if error, rerun
        bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,finish)
    #reset variables
    xn = 0
    xp = 0
    yn = 0
    yp = 0
    zn = 0
    zp = 0
    n_x = 0
    n_y = 0
    n_z = 0

    #after bot is stuck
def finished(steps):
    global posx, posy, posz, n
    arrayfinish.append(steps)
    posx=0
    posy=0
    posz=0
    n=0

def mainloop():
    global xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z,finish
    setup()
    print 'completed setup'
    while finish == False:
        print 'start loop'
        bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,finish)
        print 'finished bot'    
        while n_x < len(blockx) and n_y < len(blocky) and n_z < len(blockz):
            print 'start direct'
            direct(xn, xp, yn, yp, zn, zp, n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz)
            print 'finish direct'
    finished(n)
    print arrayfinish


mainloop()

os.system('pause')

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #40 on: October 24, 2012, 06:33:14 PM »
posx, posy, posz refuses to change

Code: [Select]
import random
import os

#os.sys.setrecursionlimit(9000)
#import pdb; pdb.set_trace()


#counts stuck attempts
arrayfinish=[]

def setup():
    global n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz, xn, xp, yn, yp, zn, zp, n, finish
    #position of bot
    posx=0
    posy=0
    posz=0
    #array for occupied spaces
    blockx=[]
    blocky=[]
    blockz=[]
    #n_x, n_y, n_z
    n_x = 0
    n_y = 0
    n_z = 0
    #step count
    n=0
    #directions = none
    xn=0
    xp=0
    yn=0
    yp=0
    zn=0   
    zp=0
    finish = False

#setting xn, xp, yn, yp, zn, and zp
def direct(xn, xp, yn, yp, zn, zp, n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz):
    #check x n-egative and p-ositive side
    if (posx - blockx[n_x] == 1 and posy == blocky[n_y] and posz == blockz[n_z]):
        print '---------------------------------------'
        xn = 1
        print xn
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    if (posx - blockx[n_x] == -1 and posy == blocky[n_y] and posz == blockz[n_z]):
        print '---------------------------------------'
        xp = 1
        print xp
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    #check y n-egative and p-ositive side
    if (posy - blockx[n_y] == 1 and posx == blocky[n_x] and posz == blockz[n_z]):
        print '---------------------------------------'
        yn = 1
        print yn
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    if (posy - blockx[n_y] == -1 and posx == blocky[n_x] and posz == blockz[n_z]):
        print '---------------------------------------'
        yp = 1
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    #check z n-egative and p-ositive side
    if (posz - blockx[n_z] == 1 and posy == blocky[n_y] and posy == blockz[n_y]):
        print '---------------------------------------'
        zn = 1
        print zn
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
    if (posz - blockx[n_z] == -1 and posy == blocky[n_y] and posy == blockz[n_y]):
        print '---------------------------------------'
        zp = 1
        print zp
        print '||||||||||||||||||||||||||||||||||||||||||||||||'
   
#bot movement
def bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,finish):
    #generate random direction
    direction=random.randint(0,5)
    #the directions
    print 'line 83'
    if xn == 1 and xp == 1 and yn == 1 and yp == 1 and zn == 1 and zp == 1:
        finish = True
        #check if direction is blocked, if not, move there.
    elif direction == 0 and xn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx-1
        n=n+1
        print 'line 93'
    elif direction == 1 and xp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx+1
        n=n+1
        print 'line 100'
    elif direction == 2 and yn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy-1
        n=n+1
        print 'line 107'
    elif direction == 3 and yp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy+1
        n=n+1
        print 'line 114'
    elif direction == 4 and zn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz-1
        n=n+1
        print 'line 121'
    elif direction == 5 and zp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz+1
        n=n+1
        print 'line 128'
    else:
        #if error, rerun
        bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,finish)
    #reset variables
    xn = 0
    xp = 0
    yn = 0
    yp = 0
    zn = 0
    zp = 0
    n_x = 0
    n_y = 0
    n_z = 0

    #after bot is stuck
def finished(steps):
    global posx, posy, posz, n
    arrayfinish.append(steps)
    posx=0
    posy=0
    posz=0
    n=0

def mainloop():
    global xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z,finish
    setup()
    print 'completed setup'
    #os.system('pause')
    while finish == False:
        print 'start loop'
        #os.system('pause')
        bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,finish)
        print 'finished bot'   
        while n_x < len(blockx) and n_y < len(blocky) and n_z < len(blockz):
            print 'start direct'
            direct(xn, xp, yn, yp, zn, zp, n_x, n_y, n_z, posx, posy, posz, blockx, blocky, blockz)
            #advance one position and redo
            n_x=n_x+1
            n_y=n_y+1
            n_z=n_z+1
            print n_x, 'n_x'
            print len(blockx), 'len'
            print xn, xp, yn, yp, zn, zp, 'list'
            print 'finish direct'
            print blockx, 'blockx'
            print blocky, 'blocky'
            print blockz, 'blockz'

    finished(n)
    print arrayfinish


mainloop()

os.system('pause')

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #41 on: October 24, 2012, 06:36:15 PM »
* the reason they're doing that is because block_move is not being run

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #42 on: October 24, 2012, 06:38:19 PM »
edit: ok block_move IS running but it isn't working right. this is block_move.

Code: [Select]
def bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,finish):
    #generate random direction
    direction=random.randint(0,5)
    #the directions
    print 'line 83'
    if xn == 1 and xp == 1 and yn == 1 and yp == 1 and zn == 1 and zp == 1:
        finish = True
        #check if direction is blocked, if not, move there.
    elif direction == 0 and xn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx-1
        n=n+1
        print 'line 93'
    elif direction == 1 and xp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posx=posx+1
        n=n+1
        print 'line 100'
    elif direction == 2 and yn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy-1
        n=n+1
        print 'line 107'
    elif direction == 3 and yp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posy=posy+1
        n=n+1
        print 'line 114'
    elif direction == 4 and zn == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz-1
        n=n+1
        print 'line 121'
    elif direction == 5 and zp == 0:
        blockx.append(posx)
        blocky.append(posy)
        blockz.append(posz)
        posz=posz+1
        n=n+1
        print 'line 128'
    else:
        #if error, rerun
        bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,finish)
    #reset variables
    xn = 0
    xp = 0
    yn = 0
    yp = 0
    zn = 0
    zp = 0
    n_x = 0
    n_y = 0
    n_z = 0

Darvince

  • *****
  • Posts: 1807
  • two dimensional time
Re: Python
« Reply #43 on: October 24, 2012, 06:40:34 PM »
ok when you're done with that you should code a bot that i can ctam with

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #44 on: October 24, 2012, 06:49:56 PM »
no this is my python queue:

bot simulation (current)
byetech (some sort of game)
collisions simulator (what the parabola problem was for)
n-dimensional n-body fundamental force simulator
evolution simulator
ctambot (if i get bored enough)

atomic7732

  • Universe Sandbox 1 Beta Team
  • *****
  • Posts: 3720
  • etched into the bark of the old oak trees
    • Paladin of Storms
Re: Python
« Reply #45 on: October 24, 2012, 07:03:45 PM »
my python no-particualr-order queue:

weather model
atlantic hurricane simulator (real time, possibly internet-based)
gravity simulator


Darvince

  • *****
  • Posts: 1807
  • two dimensional time
Re: Python
« Reply #46 on: October 24, 2012, 07:07:05 PM »
avg time for kip projects: 1 week, done

avg time for kalaprojects: 1 month
no, this is too hard: 3 months
dammit: never

atomic7732

  • Universe Sandbox 1 Beta Team
  • *****
  • Posts: 3720
  • etched into the bark of the old oak trees
    • Paladin of Storms
Re: Python
« Reply #47 on: October 24, 2012, 07:08:19 PM »
I've gotten several done though, like my cyclone product catcher...

Or at least to a functioning state. It's not really done.

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #48 on: October 25, 2012, 12:44:06 PM »
for darvince

(warning; single player only)

200 seconds for me
« Last Edit: October 25, 2012, 12:48:55 PM by mudkipz »

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #49 on: October 25, 2012, 12:54:45 PM »
this program; which does not have to print every single number it counts; can count to a billion in about 4 minutes


seriously, read the code, it actually does count.

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #50 on: October 25, 2012, 01:26:29 PM »
def asdf():
    s=time.time()
    randomfunction()
    a=time.time()
    print (a-s)*1000

useful to time stuff

however, if the function you are running is very short; like print 'hello world', i would run it 10 times + to get a accurate time, or else it'll come out very strange

time is in miliseconds.

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #51 on: October 25, 2012, 01:32:05 PM »
from the above^:

it takes about 410 milliseconds to square root 632 one million times with math.sqrt

it takes 100 milliseconds to square root 632 one million times with the ** power operator

conclusion: use power operator

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: Python
« Reply #52 on: October 25, 2012, 01:35:18 PM »
okok, can you stop saying how fast it goes or whatever?
« Last Edit: October 25, 2012, 01:53:23 PM by bong »

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #53 on: October 25, 2012, 01:54:28 PM »
no

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #54 on: October 25, 2012, 02:45:40 PM »
Code: [Select]
import os
import random
import math

#defines all the variables
emitter_xpos = 0
emitter_ypos = 0
emitter_zpos = 0
emitter_turnx = 0
emitter_turny = 0
emitter_moved = 0

#moves emitter forwards
def emitter_move_distance():
    global emitter_moved
    emitter_moved = (random.randint(50,100))/1000
    
#turns the emitter up down right or left
def emitter_turn_x():
    global emitter_turnx
    emitter_turnx = emitter_turnx + (random.randint(-500,500))/1000
def emitter_turn_y():
    global emitter_turny
    emitter_turny = emitter_turny + (random.randint(-500,500))/1000
#calculates new position of emitter
def emitter_pos():
    global emitter_xpos, emitter_ypos, emitter_zpos
    emitter_xpos = emitter_moved*math.sin(-(emitter_turny)+math.pi/2)*math.cos(emitter_turnx)+emitter_xpos
    emitter_ypos = emitter_moved*math.sin(-(emitter_turny)+math.pi/2)*math.sin(emitter_turnx)+emitter_ypos
    emitter_zpos = emitter_moved*math.cos(-(emitter_turny)+math.pi/2)+emitter_zpos

#runs entire thing
def move_emitter():
    emitter_move_distance()
    emitter_turn_x()
    emitter_turn_y()
    emitter_pos()



move_emitter()
    
print emitter_xpos
print emitter_ypos
print emitter_zpos

os.system('pause')

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #55 on: October 25, 2012, 02:59:50 PM »
working version (everything needs to be floated)
Code: [Select]
import time
import os
import random
import math

#defines all the variables
emitter_xpos = 0
emitter_ypos = 0
emitter_zpos = 0
emitter_turnx = 0
emitter_turny = 0
emitter_moved = 0

#moves emitter forwards
def emitter_move_distance():
    global emitter_moved
    emitter_moved_1000 = random.randint(50,100)
    emitter_moved = float(emitter_moved_1000)/1000
#turns the emitter up down right or left
def emitter_turn_x():
    global emitter_turnx
    emitter_turnx_1000 = random.randint(-500,500)
    emitter_turnx = float(emitter_turnx_1000)/1000 + emitter_turnx
def emitter_turn_y():
    global emitter_turny
    emitter_turny_1000 = random.randint(-500,500)
    emitter_turny = float(emitter_turny_1000)/1000 + emitter_turny
#calculates new position of emitter
def emitter_pos():
    global emitter_xpos, emitter_ypos, emitter_zpos
    emitter_xpos = emitter_moved*math.sin(-(emitter_turny)+math.pi/2)*math.cos(emitter_turnx)+emitter_xpos
    emitter_ypos = emitter_moved*math.sin(-(emitter_turny)+math.pi/2)*math.sin(emitter_turnx)+emitter_ypos
    emitter_zpos = emitter_moved*math.cos(-(emitter_turny)+math.pi/2)+emitter_zpos

#runs entire thing
def move_emitter():
    emitter_move_distance()
    emitter_turn_x()
    emitter_turn_y()
    emitter_pos()


x=0
while x<1000:
    move_emitter()
    x=x+1
   
print emitter_xpos
print emitter_ypos
print emitter_zpos

os.system('pause')

atomic7732

  • Universe Sandbox 1 Beta Team
  • *****
  • Posts: 3720
  • etched into the bark of the old oak trees
    • Paladin of Storms
Re: Python
« Reply #56 on: October 25, 2012, 03:14:23 PM »
for darvince

(warning; single player only)

200 seconds for me
74.72s

working version (everything needs to be floated)
Code: [Select]
import time
import os
import random
import math

#defines all the variables
emitter_xpos = 0
emitter_ypos = 0
emitter_zpos = 0
emitter_turnx = 0
emitter_turny = 0
emitter_moved = 0

#moves emitter forwards
def emitter_move_distance():
    global emitter_moved
    emitter_moved_1000 = random.randint(50,100)
    emitter_moved = float(emitter_moved_1000)/1000
#turns the emitter up down right or left
def emitter_turn_x():
    global emitter_turnx
    emitter_turnx_1000 = random.randint(-500,500)
    emitter_turnx = float(emitter_turnx_1000)/1000 + emitter_turnx
def emitter_turn_y():
    global emitter_turny
    emitter_turny_1000 = random.randint(-500,500)
    emitter_turny = float(emitter_turny_1000)/1000 + emitter_turny
#calculates new position of emitter
def emitter_pos():
    global emitter_xpos, emitter_ypos, emitter_zpos
    emitter_xpos = emitter_moved*math.sin(-(emitter_turny)+math.pi/2)*math.cos(emitter_turnx)+emitter_xpos
    emitter_ypos = emitter_moved*math.sin(-(emitter_turny)+math.pi/2)*math.sin(emitter_turnx)+emitter_ypos
    emitter_zpos = emitter_moved*math.cos(-(emitter_turny)+math.pi/2)+emitter_zpos

#runs entire thing
def move_emitter():
    emitter_move_distance()
    emitter_turn_x()
    emitter_turn_y()
    emitter_pos()


x=0
while x<1000:
    move_emitter()
    x=x+1
   
print emitter_xpos
print emitter_ypos
print emitter_zpos

os.system('pause')
what does it do

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #57 on: October 25, 2012, 03:45:48 PM »
i'm working on a game/simulation thingy.

there will be objects called bots inside a three dimensional space (although the physics in this space will be different). instead position being speed*time and speed being acceleration*time etc, there will be only position.)

the emitter is an object in this three dimensional space which randomly moves around (it's movement right now is a bit jerky and sudden atm, but that'll be fixed) Most importantly, the emitter is a source of energy for these bots. the energy from this emitter decreases as the square root of distance, 1/sqrt(x) as opposed to the usual 1/x^2

each bot has a laser, scanner, energy storage (capacitor), energy collection (some solar-panel-like device), a propulsion unit, and armor. more advances versions of these items will result in a more energy expensive and powerful bot, while some other bots might have a version 0 for these items (nonexistant). to prevent bots from gathering too close to the emitter to gain large quantities of energy and become invincible; getting too close to the emitter will damage a bot. the laser of a bot lessens it's power as 1/x (a bot twice as far as another will be half as damaging assuming the same laser level)

each bot is also preset with behavioral parameters such as hostility, when to attack depending on various parameters and scanners, how and if to cooperate, when to build more of themselves, and etc.

the scanner unit on a bot lets one bot determine all the parameters and settings of another bot.

energy is used when thrusting, shooting laser, activating armor, scanning, or giving energy to another bot, or constructing a new bot.
if a bot destroys another bot it will gain all the energy that the other bot had in it's energy storage unit. in addition energy can be gained with the energy collection units or given by another bot.

bots will also slowly lose energy over time; this provides incentive for not drifting off into isolation

a bot will be removed from the program if its structural integrity or energy is reduced to zero. a bot who has between 0 and full structural integrity will very slowly increase it's SI if it has energy.

the bot's parameters will be stored as an int; as well as the bot's preferred distance and location relative to the emitter. this way everyone can create a bot and compete.

i also might make it so that new bots being created will be mutated so as to have an evolution simulator

atomic7732

  • Universe Sandbox 1 Beta Team
  • *****
  • Posts: 3720
  • etched into the bark of the old oak trees
    • Paladin of Storms
Re: Python
« Reply #58 on: October 25, 2012, 04:07:50 PM »
Wow that sounds interesting.

vh

  • formerly mudkipz
  • *****
  • Posts: 1135
  • proxy proxshi
Re: Python
« Reply #59 on: October 26, 2012, 01:38:27 PM »
object1=[1,2,3]
object2=[3,4,5]
object3=[6,2,8]
allobjects=[object1, object2, object3]

how get the number 8 in this?