
Post python code, python stuff, maybe even a python.

current work on a darvincian name generator, there's probably a way to optimize this way better, but i'm lazy

My "building image generator" or whatever it's generating.

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '72432'.

Darvincian Name Generator
It's not perfect, but the best i can do :P, sometimes, too many of the same letter shows up but it usually works well.
Haven't figured out how to use a while loop on the seperate blocks of code so i just made 2 programs one with 1 name out put another with 10 and i'll do one with 100 if anyone wants

lolidunno
health = 100
matthealth = 100
def promptaction():
act = raw_input("Wat do?") #run, fight
act.strip("\n")
return act
def action(thing):
modify = "%s" % thing
uppercase = modify.upper()
print "USER used %s!" % uppercase
if uppercase == "TAIL WHIP":
matthealth = matthealth  20
return "MATTY takes 20 damage."
elif uppercase == "PONY":
matthealth = matthealth  50
return "MATTY takes 50 damage."
elif uppercase == "MUD SLAP":
matthealth = matthealth  15
return "MATTY takes 15 damage."
elif uppercase == "CHAT":
matthealth = matthealth  45
return "MATTY takes 45 damage."
else:
print "Not a valid move."
print "A wild MATTY appeared!"
action = promptaction()
if action == "fight":
move = raw_input("TAIL WHIP, PONY, MUD SLAP, CHAT: ")
move.strip("\n")
print action(move)
if matthealth < 1:
print "MATTY fainted!"
else:
action = promptaction()
elif action == "run":
print "You got away!"
else:
print "fsjfkdsjfkdsk"
Did it in like 30 mins and it really doesn't work as intended yet, maybe I'll mess with it later
It should work if you paste and save the code... I didn't test it though, so no guarantees.
I really wanted it to be more of a surprise but that would require me NOT SHARING SOMETHING or not going to sleep.

asdf
*takes about 15 seconds to run so be patient*

When i code, it's a contest between me pressing the prtsc sysrq button as fast as humanly can, and that evil little black box of error messages trying to hide from me :P

When i code, it's a contest between me pressing the prtsc sysrq button as fast as humanly can, and that evil little black box of error messages trying to hide from me :P
open cmd and type C:\<python directory> file.py

the following code lets you measure the time elapsed since you last ran the function that resets the time. it works even when closed out and restarted because the time data is stored in a save.txt in the same directory as the .py
In addition, it will not be messed up even if you change your computer system time, the time is pulled from the internet. (you need the internet for this to work at all)
import ntplib
import time
import sys
import os
def tme():
global realtime
global computertime
global timeoff
c = ntplib.NTPClient()
response = c.request('europe.pool.ntp.org', version=3)
timeoff = response.offset
computertime = time.time()
realtime = timeoff+computertime
def wryte():
tme()
file = open ('save.txt', 'r+')
print file
wrytestring = repr(realtime)
file.write(wrytestring)
file.close()
os.system('cls')
print 'Time Reset'
def interval():
tme()
file = open ('save.txt', 'r+')
print file
lasttime = float(file.readline())
os.system('cls')
print 'Time elapsed:',realtimelasttime
file.close()
def run():
choice = int(input('1=reset, 2=elapsed time, 3=quit'))
if choice == 1:
wryte()
if choice == 2:
interval()
if choice ==3:
sys.exit()
x = 0
while (x == 0):
run()

I'm using your code above to download and display tropical product updates.

on dargen100: too much x, nawt enuf w.

import ntplib #http://pypi.python.org/pypi/ntplib/
import time
import sys
import os
import urllib2
from datetime import datetime
def tme():
global realtime
global computertime
global timeoff
c = ntplib.NTPClient()
response = c.request('europe.pool.ntp.org', version=3)
timeoff = response.offset
computertime = time.time()
realtime = timeoff+computertime
def wryte():
tme()
file = open ('save.txt', 'r+')
print file
wrytestring = repr(realtime)
file.write(wrytestring)
file.close()
os.system('cls')
print 'Time Reset'
print 'Time now:',realtime
d2 = datetime.fromtimestamp( int(float(realtime) ) )
print d2
def dfilewtpq():
file = urllib2.urlopen("http://weather.noaa.gov/pub/data/raw/wt/wtpq20.rjtd..txt")
output = open('wtpq20_1.txt','w+b')
output.write(file.read())
output.seek(0)
header = output.read(6)
output.seek(12)
newproducttime = output.read(6)
output.close()
output = open('wtpq20.txt','rb')
output.seek(12)
producttime = output.read(6)
output.close()
if newproducttime == producttime:
return "none"
elif newproducttime != producttime:
output = open('wtpq20.txt','w+b')
copy = open('wtpq20_1.txt','rb')
output.write(copy.read())
output.close()
copy.seek(56)
name = copy.readline()
name = name.strip('\n')
copy.seek(108)
location = copy.readline()
location = location.strip('\n')
copy.seek(132)
dir = copy.readline()
dir = dir.strip('\n')
copy.seek(145)
pres = copy.readline()
pres = pres.strip('\n')
copy.seek(158)
wind = copy.readline()
wind = wind.strip('\n')
update = "WTPQ20 %s %s %s %s %s" % (name, location, dir, pres, wind)
copy.close()
print "File updated."
return update
def checkfiles():
status = dfilewtpq()
tme()
d2 = datetime.fromtimestamp( int(float(realtime) ) )
if status != "none":
print "%s %s" % (d2,status)
else:
print d2,"checked"
def continual():
i = 0
while(i == 0):
checkfiles()
time.sleep(300)
def run():
wryte()
choice = int(input('1  time, 2  quit, 3  download WTPQ, 4  continual mode: '))
if choice == 1:
wryte()
if choice == 2:
sys.exit()
if choice == 3:
dfilewtpq()
if choice == 4:
os.system('cls')
continual()
x = 0
while (x == 0):
run()
I will add the ability for more products to be checked later.
Attatched: what a product looks like when caught

(http://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Ball_python_lucy.JPG/220pxBall_python_lucy.JPG)

(http://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Ball_python_lucy.JPG/220pxBall_python_lucy.JPG)
AAAAAAAAaaaaawwww Yeeeeaaaahhhh!!!11

you had to install ntplib to get it working right?

Yes.
darscript
(it was called comeon.py because it was my testing script for my cyclone thing and I was mad lol)

Version 1
It searches for west pacific, east pacific, and atlantic discussions and advisories.
Basically if there's a cyclone active, it prints relevant information from the advisory in the cmd, and it will display "...see text" for updated discussions.
(requires ntplib  http://pypi.python.org/pypi/ntplib/ (http://pypi.python.org/pypi/ntplib/) )

Yes.
darscript
(it was called comeon.py because it was my testing script for my cyclone thing and I was mad lol)
no it must post in ctam

http://www.learnpython.org/page/Loops (http://www.learnpython.org/page/Loops)
must complete exercise!
but how

.gif me ideas for a random text game with forumers in it.

1º Great Rule: Bla
2º Great Rule: Communism
3º Great Rule: Fiah Hate's Hellpotatoe Nations
4º Great Rule: Cyclones

ok someone can pretty up the time bars if they want to :P
this python script lets you input a time, and then shows a time bar, which slowly fills up and notifies you with a message of your choice when the time is completed.
input is in seconds

Since when do you guys specialize in python!?
I wouldn't mind learning XD

if you want to learn there are many sites that teach python; or you can just explore the documentation online.

this version makes a beeping noise when finished with timer (no additional installs needed other than python)
if anyone wants i'll make a version where you can select beep or not.

import random
i = 0
x = 100
file = open('file.txt', 'w+b')
while (x > 0):
i = i + 1
die1 = int(random.random()*5)
die2 = int(random.random()*5)
die3 = int(random.random()*5)
die4 = int(random.random()*5)
die5 = int(random.random()*5)
die6 = int(random.random()*5)
if die1 == die2:
if die1 == die3:
if die1 == die4:
if die1 == die5:
if die1 == die6:
print i
j = str(i) + "\n"
i = 0
x = x  1
file.write(j)
else:
pass
else:
pass
else:
pass
else:
pass
else:
pass
For kip.

and why the hell is the length of blockx increasing by more than 1 each time?
import random
import os
#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):
global xn, xp, yn, yp, zn, zp
if (n_x < len(blockx) or n_y < len(blocky) or n_z < len(blockz)):
#check x negative and positive 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 negative and positive 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 negative and positive 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'
#^should increase by 1, but it doesn't!
direct(n_x, n_y, n_x)
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.
if direction == 0 and xn == 0:
blockx.append(posx)
blocky.append(posy)
blockz.append(posz)
posx=posx1
n=n+1
if direction == 1 and xp == 0:
blockx.append(posx)
blocky.append(posy)
blockz.append(posz)
posx=posx+1
n=n+1
if direction == 2 and yn == 0:
blockx.append(posx)
blocky.append(posy)
blockz.append(posz)
posy=posy1
n=n+1
if direction == 3 and yp == 0:
blockx.append(posx)
blocky.append(posy)
blockz.append(posz)
posy=posy+1
n=n+1
if direction == 4 and zn == 0:
blockx.append(posx)
blocky.append(posy)
blockz.append(posz)
posz=posz1
n=n+1
if 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)
#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)
#bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z)
finished(n)
print arrayfinish
mainloop()
os.system('pause')

ok now this one gets stuck in an endless recursion on line 56
import random
import os
#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):
global xn, xp, yn, yp, zn, zp
if (n_x < len(blockx) or n_y < len(blocky) or n_z < len(blockz)):
#check x negative and positive 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 negative and positive 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 negative and positive 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'
direct(n_x, n_y, n_x)
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.
if direction == 0 and xn == 0:
blockx.append(posx)
blocky.append(posy)
blockz.append(posz)
posx=posx1
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=posy1
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=posz1
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)
#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)
#bot_move(xn,xp,yn,yp,zn,zp,n,posx,posy,posz,blockx,blocky,blockz,n_x,n_y,n_z)
finished(n)
print arrayfinish
mainloop()
os.system('pause')

in this version i've figured that the problem is caused by the if statements in direct not working properly
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):
global xn, xp, yn, yp, zn, zp
if (n_x < len(blockx) or n_y < len(blocky) or n_z < len(blockz)):
#check x negative and positive 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 negative and positive 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 negative and positive 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'
#^always stays as zero
direct(n_x, n_y, n_x)
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=posx1
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=posy1
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=posz1
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)
#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)
#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')

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

in this version the change  sometimes
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 negative and positive 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 negative and positive 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 negative and positive 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=posx1
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=posy1
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=posz1
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')

still not working
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 negative and positive 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 negative and positive 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 negative and positive 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=posx1
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=posy1
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=posz1
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')

worse, but better in a way
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 negative and positive 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 negative and positive 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 negative and positive 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=posx1
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=posy1
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=posz1
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')

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 negative and positive 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 negative and positive 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 negative and positive 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=posx1
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=posy1
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=posz1
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')

what i'm seeing is that xn = 1 does not seem to be effective.

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

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?

updated version
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 negative and positive 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 negative and positive 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 negative and positive 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=posx1
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=posy1
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=posz1
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')

strange
when i run:
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
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 negative and positive 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 negative and positive 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 negative and positive 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=posx1
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=posy1
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=posz1
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')

posx, posy, posz refuses to change
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 negative and positive 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 negative and positive 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 negative and positive 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=posx1
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=posy1
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=posz1
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')

* the reason they're doing that is because block_move is not being run

edit: ok block_move IS running but it isn't working right. this is block_move.
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=posx1
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=posy1
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=posz1
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

ok when you're done with that you should code a bot that i can ctam with

no this is my python queue:
bot simulation (current)
byetech (some sort of game)
collisions simulator (what the parabola problem was for)
ndimensional nbody fundamental force simulator
evolution simulator
ctambot (if i get bored enough)

my python noparticualrorder queue:
weather model
atlantic hurricane simulator (real time, possibly internetbased)
gravity simulator

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

I've gotten several done though, like my cyclone product catcher...
Or at least to a functioning state. It's not really done.

for darvince
(warning; single player only)
200 seconds for me

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.

def asdf():
s=time.time()
randomfunction()
a=time.time()
print (as)*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.

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

okok, can you stop saying how fast it goes or whatever?

no

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')

working version (everything needs to be floated)
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')

for darvince
(warning; single player only)
200 seconds for me
74.72s
working version (everything needs to be floated)
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

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 solarpanellike 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

Wow that sounds interesting.

object1=[1,2,3]
object2=[3,4,5]
object3=[6,2,8]
allobjects=[object1, object2, object3]
how get the number 8 in this?

oh i figured it out
allobjects[2][2]

someone tell me:
def countline():
count=0
for line in open('save.txt', 'r+'):
count = count + 1
return count
yeah so what name does python use to reference the file so i can close it like f.close()

if i take lines from a text file and append them to an array, they come out as strings.
for example if i have array
allobjects=[]
and then the line in my save.txt is [0,320,40,51]
allobjects.append(save.readline().rstrip())
print allobjects
['[0,320,40,51]']
i want it to be
[[0,320,40,51]]

why post question if no one but you can solve them?

why post question asking "why post question if no one but you can solve them" if other people can solve them.
your logic is like saying that if you don't know if people have the answer to your question, don't ask it.

because you might not have the answer and other ppl might.

why post question if no one but you can solve them?
because you might not have the answer and other ppl might.
you have just answered your own question.

i know, but no one else here knows python good enought to solve your python problems

proof?

godstab, greenland

updated code
and i figurd out the for statement :P
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()
allobjects=[]
#opening objects
def load_obj():
global allobjects
for line in open('save.txt', 'r+'):
derp = [int(x) for x in line.rstrip().split(",")]
allobjects.append(derp)
load_obj()
#collecting energy
def energy_collection(emitter_xpos, emitter_ypos, emitter_zpos):
global allobjects
for list in allobjects:
#list[4] is the distance
#list[5] is the energy collection unit
#list[6] is the enery stored
#list[7] is the maximum value of the energy storage unit
list[4] = ((list[0]emitter_xpos)**2+(list[1]emitter_ypos)**2+(list[2]emitter_zpos)**2)**0.5
list[6] = list[6]+list[5]/list[4]**0.5
if list[6] > list[7]:
list[6] = list[7]
energy_collection(emitter_xpos, emitter_ypos, emitter_zpos)
print allobjects
os.system('pause')

testplz

i've been busy
code for primality testing using the millerrabin probabilistic test:
import random
def primality(number, iterations): #insert a number and the amount of iterations for a return of True or False for primality
n = number
k = iterations
n_=n1 #supposed to write n1 as 2^s*d later; so substitute this instead
s=0
d=0
if n <= 1:
return False
if n == 3 or n == 2: #filters out numbers <= 3 because the primality test can't
return True
if n % 2 == 0:
return False
while n_ % 2 == 0: #making n_ into 2^s*d
s = s + 1
n_= n_/ 2
d = n_
while k != 0: #corresponds to line : LOOP: repeat k times:
k = k  1
a = random.randint(2, n2) # corresponds to : pick a random integer a in the range from 2 to n minus 2
x = pow(a,d,n) # corresponds to : x = a^d mod n
if x == 1 or x == n  1: #corresponds to : if x = 1 or x = n  1 then do next loop
continue # if this is true then go back to the while k!=0 loop
r = 1
for r in xrange (1,s): #do this from r = 1 to r = s  1
x = pow(x, 2, n) #corresponds to x = x^2 mod n
if x == 1: #corresponds to if x = 1 then return composite
return False
elif x == n  1: #if x = n  1, then it will ignore the if and break and go back to while k!=0 loop
break
else:
return False #composite
return True #return prime
code that factors smallest integer out of a number using a pollardbrent method, partly taken from comeoncodeon blog/wordpress thingy:
import random
import fractions
#come on code on wordpress blog
def pollard_brent(number): #returns a factor of an integer where number > 1 is True
if number % 2 == 0:
return 2
y = random.randint(1,number1)
c = random.randint(1,number1)
m = random.randint(1,number1)
g = 1
r = 1
q = 1
while g == 1:
x = y
for i in range(r):
y = (pow(y,2,number)+c) % number
k = 0
while k < r and g == 1:
ys = y
for i in range(min(m, rk)):
y = (pow(y,2,number)+c) % number
q = q*(abs(xy)) % number
g = fractions.gcd(q, number)
k = k + m
r = r * 2
if g == number:
while True:
ys = (pow(ys, 2, number)+c) % number
g = fractions.gcd(abs(xys), number)
if g > 1:
break
return g
i'm not sure how the above code works so don't ask me :P
and this is a prime factorization code; returns an array with (hopefully) all the prime factors of a number:
import random
import fractions
import os
def primality(number, iterations):
n = number
k = iterations
n_=n1
s=0
d=0
if n <= 1:
return False
if n == 3 or n == 2:
return True
if n % 2 == 0:
return False
while n_ % 2 == 0:
s = s + 1
n_= n_/ 2
d = n_
while k != 0:
k = k  1
a = random.randint(2, n2)
x = pow(a,d,n)
if x == 1 or x == n  1:
continue
r = 1
for r in xrange (1,s):
x = pow(x, 2, n)
if x == 1:
return False
elif x == n  1:
break
else:
return False
return True
def pollard_brent(number): #returns a factor of an integer where number > 1 is True
if number % 2 == 0:
return 2
y = random.randint(1,number1)
c = random.randint(1,number1)
m = random.randint(1,number1)
g = 1
r = 1
q = 1
while g == 1:
x = y
for i in range(r):
y = (pow(y,2,number)+c) % number
k = 0
while k < r and g == 1:
ys = y
for i in range(min(m, rk)):
y = (pow(y,2,number)+c) % number
q = q*(abs(xy)) % number
g = fractions.gcd(q, number)
k = k + m
r = r * 2
if g == number:
while True:
ys = (pow(ys, 2, number)+c) % number
g = fractions.gcd(abs(xys), number)
if g > 1:
break
return g
def prime_factorization(number, iterations):
n = number
primefactors = []
while primality(number, iterations) == False:
if number == 1:
break
factor = pollard_brent(number)
primefactors.append(int(factor))
number = number / factor
if number != 1 and n != number:
primefactors.append(int(number))
return primefactors
os.system('pause')
attached is a prime.py and a primefactorization.py
prime.py will tell you if a number is prime or even given an input. you may input through the terminal or by entering a number in a number.txt in the same directory as the prime.py file. i strongly suggest using notepad++ to input the number; notepad incorrectly warps large numbers.
the only input for primefactorization.py is with the terminal. a sorted array with all the prime factors should be returned. entering a number beyond 50 digits may result in several minutes of computation. it took my computer 5 minutes to calculate the prime factorizations for all the numbers from 2 to 1000000 excluding.
*A note on accuracy:
since the millerrabin test is probabilistic  that means, it relies on probability; there is a chance that when you run one of the scripts, you will get an incorrect result.
the probability that prime.py will result in a false positive; meaning that a composite number is designated prime is:
4^(k) where k is the amount of iterations running. running 10 iterations, which means a wrong result chance of 1 in 10,000 should be enough for most applications, but if necessary, you can run a thousand or a million trials which will give a false positive rate of one in a trillion or one in a septillion respectively. a prime number will never be mistakenly labeled as composite.
**the actual probability is significantly less than 4^(k), read here for further maths:
http://www.math.dartmouth.edu/~carlp/PDF/paper88.pdf (http://www.math.dartmouth.edu/~carlp/PDF/paper88.pdf)
because primefactorization.py relies on the millerrabin test, it will also have a chance of miscalculation; although the probability is a bit more complex to calculate it should be on the same order of magnitude as the false positive rate of the primality.py algorithm.
and post if you notice any bugs.

i just read the program names and not the post. :)

i ignore python things because idk how to work with 'em

ok you can download and install from here http://www.python.org/getit/releases/2.7.3/ (http://www.python.org/getit/releases/2.7.3/) (pick any one)
and then i recommend you install this: http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32218.winamd64py2.7.exe/download (http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32218.winamd64py2.7.exe/download)
then open python interpreter and you can try some basic commands like
print 'hello world'
or
print 5*3
etc

no thanks, this pc kant run python

really? have you tried? i'm pretty sure python can run on any computer that can run a browser :P

this pc kan't run a browser

then how are you on universe sandbox! what program do you use to search the internet

i'm using msdos kolno
this pc kant run internet

yes it can thats why you're posting herez1!

NO, THATS A DREAM!
i wonder if bla will delete our random posts or if he will make one topic with them...

^
yes bu go install pyfon

no, because i kant use internet

yes you can and that post above just prove it!

IM USING A PROXYPAPER!!!

YOU CANNOT USE THAT TO CONNECT TO BLACRAFT

semi working code
import random
import fractions
def primality(number, iterations): #converted from http://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test#Algorithm_and_running_time
n = number #number to test for primality
k = iterations #corresponds to line 'k, a parameter that determines the accuracy of the test
n_=n1 #n1 is substituted by n_, for later use when i need to write n  1 as 2**s * d,
s=0
d=0
if n == 3 or n == 2:
return True
if n % 2 == 0:
return False
while n_ % 2 == 0: #writes n  1 aka n_ as 2**s * d by dividing by two and checking if n_ is still even
s = s + 1
n_= n_/ 2
d = n_
while k != 0: #corresponds to line in pseudocode  Loop: repeat k times:
k = k  1
a = random.randint(2, n2) #picks random integer in range 2, n2
x = pow(a,d,n) # sets x to a^d mod n
if x == 1 or x == n  1: # corresponds to line in pseudocode if x = 1 or x = n  1 then do next Loop
continue
for r in xrange (1,s): #corresponds to line in pseudocode  for r = 1...s1
x = pow(x, 2, n) #sets x to x^2 mod n
if x == 1: #corresponds to line  if x = 1 then return composite
return False
elif x == n  1: #corresponds to line  if x = n  1 then do next Loop
break
else: #corrresponds to line  return composite
return False
return True #corresponds to line  return probably prime
def pollard_brent(number): #returns a factor of an integer: code from http://comeoncodeon.wordpress.com/2010/09/18/pollardrhobrentintegerfactorization/#viewSource
if number % 2 == 0:
return 2
y = random.randint(1,number1)
c = random.randint(1,number1)
m = random.randint(1,number1)
g = 1
r = 1
q = 1
while g == 1:
x = y
for i in range(r):
y = (pow(y,2,number)+c) % number
k = 0
while k < r and g == 1:
ys = y
for i in range(min(m, rk)):
y = (pow(y,2,number)+c) % number
q = q*(abs(xy)) % number
g = fractions.gcd(q, number)
k = k + m
r = r * 2
if g == number:
while True:
ys = (pow(ys, 2, number)+c) % number
g = fractions.gcd(abs(xys), number)
if g > 1:
break
return g
def prime_factorization(number, iterations): #returns list of prime factors of a number
n = number
primefactors = []
while primality(number, iterations) == False: # if number is not a prime number
if number == 1: # and if number is not 1
break
factor = pollard_brent(number) #factor the number
if factor != number and primality(factor, 10) == True: #if the factor is composite or equal to number then try again.
primefactors.append(int(factor)) # if factor is composite and not equal to number then add it to the list of prime factors
number = number / factor #set number to number/factor
if number != 1 and n != number: #if number is not 1 or n, then
primefactors.append(int(number)) #append it
return primefactors #return array with all the prime factors
def divisorlist(num): #returns list of proper divisors when given prime factors
#all the divisors of a number can be generated by multiplying the prime factors of the number in all possible ways
divisors=[]
f = lambda l: reduce(lambda z, x: z + [y + [x] for y in z], l, [[]]) #returns the set of all subsets of its argument http://wiki.python.org/moin/Powerful%20Python%20OneLiners
for list in f(prime_factorization(num,10)): #for all lists in the set of subsets that can be created from the list of the prime factors of num
n=1 #set n to one
for int in list: #then multiply all the numbers in each list
n = n * int
divisors.append(n) #and that is one possible divisor of num
if num in divisors: #remove num if it exists because only proper divisors needed
divisors.remove(num)
divisors_=[]
for int in divisors: #remove duplicates
if int not in divisors_:
divisors_.append(int)
divisors = divisors_
return divisors #return all the proper divisors
def subset(num): #figure out if a number is semiperfect or not
semiperfect = False
f = lambda l: reduce(lambda z, x: z + [y + [x] for y in z], l, [[]]) #creates all possible subsets,
for list in f(divisorlist(num)): #of the list of proper divisors
if sum(list) == num: #if the sum any list is equal to the number
semiperfect = True #then the number is semiperfect
return semiperfect
#weird number is both NOT semiperfect and abundant
for num in xrange(2,1000000):
if sum(divisorlist(num)) > num: #if the sum of proper divisors of num is larger than num then the number is abundant
if subset(num) is False: # if the num is NOT semiperfect subset(num) should be False
print num #if both of the above are true then the number is weird and print it.

at the beginning of every python code:
import alphabet
import dictionary
import english
import python
import x, y, z

import math
#http://www.onlineconversion.com/julian_date.htm
curtime = raw_input("Current Julian Date:")
curtime = float(curtime.strip("\n"))
we1399 = 2232023.896169
year = (curtimewe1399)/365.256363004
day = (yearmath.floor(year))*365 #actual days in the year, 616 being the year with 366
grade1 = (daymath.floor(day))*100
grade2 = (grade1math.floor(grade1))*1000
print "%d.%d %d %d" % (math.floor(year), math.floor(day), math.floor(grade1), math.floor(grade2)) #example 613.328 85 417
Soleani calendar date and time calculator
at the time of this post it was 613.320 27 520

ok now make it take take time.time() to find the current soleani date

I prefer to use Julian Date... because it's consistent... It didn't jump 11 days like the Gregorian.
unless time.time() is a JD or Unix time?

yeah unix time.

oh unix time doesn't count leap seconds this makes things to much simpler

well then if you want that I'll have to do a calculation of JD at the UNIX epoch
and then add a certain amount of Soleani years and that's kind of lame actually.

well i do want it and if you won't do it i will when i have time in the far future :P

this will generate a white png file, given the size you want it to be. the goal is to make a completely text based image editor
(jk)
oh you need the pypng module
import png
n = int(input('columns?'))
y = int(input('rows?'))
pixels = [[] for x in xrange(0,n)]
for x in xrange(0,y):
for list in pixels:
list.append(255)
png.from_array(pixels, 'L').save('image.png')

i've written something that will generate cryptographically strong prime numbers, generated from random noise and entropy from your computer
(if anyone wants me to make this print the primes to a file i'll do that too because theres's no copy in the python terminal)
a note about accuracy: an input of n will yield a false positive of a prime once in n^4. for example a value of 10 will yield once mistake per 10,000 trials. an input of 1000 will yield a mistake in 1 trillion trials.
average times to generate and print primes with an accuracy of 10 on a laptop: (times in miliseconds)
length 10: 2.5
length 50: 70
length 100: 500
length 200: 5400
YOU don't need any additional modules just python 2.7 to run this

with the attached file, figure out to add the text in all the population tags IF and only if the nation is in a certain region
notes:
derp = open('derp.xml', 'r')
derp = etree.parse(derp)
derp = derp.getroot()
print derp[n][n].text #where n is index to extract text from given location

haven't tested this code yet; if it works i will be elated
import os
from lxml import etree
derp = (etree.parse(open('derp.xml ','r'))).getroot()
pop1, pop2, pop3, pop4, pop5, pop6, pop7, pop8, pop9 = 0,0,0,0,0,0,0,0,0
for x in xrange(0,len(derp)):
if derp[x][7].text == 'The Pacific':
pop1 = pop1 + derp[x][8]
if derp[x][7].text == 'The North Pacific':
pop2 = pop2 + derp[x][8]
if derp[x][7].text == 'The South Pacific':
pop3 = pop3 + derp[x][8]
if derp[x][7].text == 'The East Pacific':
pop4 = pop4 + derp[x][8]
if derp[x][7].text == 'The West Pacific':
pop5 = pop5 + derp[x][8]
if derp[x][7].text == 'The Rejected Realms':
pop6 = pop6 + derp[x][8]
if derp[x][7].text == 'Balder':
pop7 = pop7 + derp[x][8]
if derp[x][7].text == 'Osiris':
pop8 = pop8 + derp[x][8]
if derp[x][7].text == 'Lazarus':
pop9 = pop9 + derp[x][8]
print pop1, 'The Pacific'
print pop2, 'The North Pacific'
print pop3, 'The South Pacific'
print pop4, 'The East Pacific'
print pop5, 'The West Pacific'
print pop6, 'The Rejected Realms'
print pop7, 'Balder'
print pop8, 'Osiris'
print pop9, 'Lazarus'
print pop1+pop2+pop3+pop4+pop5+pop6+pop7+pop8+pop9, 'Total'
os.system('pause')
os.system('pause')
os.system('pause')

OMG THIS IS THE FIRST significant (if you call 30 lines significant) piece of code that has ever run perfectly on the first try with no issues i am so happy. now going to run it on the 5.5 million line daily data dump and hope it works equally well

this python topic: me talking to myself. if anyone else reads this reply please reply to it so i know this topic hasn't just become a notepad for myself

two erros in the above program, which were forgetting the .text and to int() the entire thing

fixed version
import os
from lxml import etree
derp = (etree.parse(open('nations.xml ','r'))).getroot()
pop1, pop2, pop3, pop4, pop5, pop6, pop7, pop8, pop9 = 0,0,0,0,0,0,0,0,0
for x in xrange(0,len(derp)):
if derp[x][7].text == 'The Pacific':
pop1 = pop1 + int(derp[x][8].text)
if derp[x][7].text == 'The North Pacific':
pop2 = pop2 + int(derp[x][8].text)
if derp[x][7].text == 'The South Pacific':
pop3 = pop3 + int(derp[x][8].text)
if derp[x][7].text == 'The East Pacific':
pop4 = pop4 + int(derp[x][8].text)
if derp[x][7].text == 'The West Pacific':
pop5 = pop5 + int(derp[x][8].text)
if derp[x][7].text == 'The Rejected Realms':
pop6 = pop6 + int(derp[x][8].text)
if derp[x][7].text == 'Balder':
pop7 = pop7 + int(derp[x][8].text)
if derp[x][7].text == 'Osiris':
pop8 = pop8 + int(derp[x][8].text)
if derp[x][7].text == 'Lazarus':
pop9 = pop9 + int(derp[x][8].text)
print pop1, 'The Pacific'
print pop2, 'The North Pacific'
print pop3, 'The South Pacific'
print pop4, 'The East Pacific'
print pop5, 'The West Pacific'
print pop6, 'The Rejected Realms'
print pop7, 'Balder'
print pop8, 'Osiris'
print pop9, 'Lazarus'
print pop1+pop2+pop3+pop4+pop5+pop6+pop7+pop8+pop9, 'Total'
os.system('pause')
os.system('pause')
os.system('pause')

this python topic: me talking to myself. if anyone else reads this reply please reply to it so i know this topic hasn't just become a notepad for myself
I read it. So the program above finds out the population of a region?

yeah, based on the nations.xml daily dump.

i have reeded it

well it turns out that the code can't load the entire 5.5 million line xml file at once so i manually split the file into 6 million line chunks. the code runs through each one. I also optimized the code and reduced the amount of time needed by looking through the region.xml file for that day which i also downloaded. since nations are grouped by regions, i can search put region if statements in the order that they appear in the xml file to save time. also i put a counter in there that causes the program to ignore the if statement if all the nations in that region have already been counted.
it took about 3 hours to go through 1.1 million lines with my previous script, lets see about this one.
import os
import time
start = time.time()
from lxml import etree
p1,p2,p3,p4,p5,p6,p7,p8,p9 = 0,0,0,0,0,0,0,0,0
pop1, pop2, pop3, pop4, pop5, pop6, pop7, pop8, pop9 = 0,0,0,0,0,0,0,0,0
def count():
global p1,p2,p3,p4,p5,p6,p7,p8,p9,pop1,pop2,pop3,pop4,pop5,pop6,pop7,pop8,pop9,derp
for x in xrange(0,len(derp)):
if p2 < 5590 and derp[x][7].text == 'The North Pacific':
pop2 = pop2 + int(derp[x][8].text)
p2 = p2 + 2
elif p4 < 5100 and derp[x][7].text == 'The East Pacific':
pop4 = pop4 + int(derp[x][8].text)
p4 = p4 + 4
elif p5 < 4929 and derp[x][7].text == 'The West Pacific':
pop5 = pop5 + int(derp[x][8].text)
p5 = p5 + 5
elif p9 < 3299 and derp[x][7].text == 'Lazarus':
pop9 = pop9 + int(derp[x][8].text)
p9 = p9 + 9
elif p1 < 4928 and derp[x][7].text == 'The Pacific':
pop1 = pop1 + int(derp[x][8].text)
p1 = p1 + 1
elif p8 < 2774 and derp[x][7].text == 'Osiris':
pop8 = pop8 + int(derp[x][8].text)
p8 = p8 + 8
elif p3 < 4963 and derp[x][7].text == 'The South Pacific':
pop3 = pop3 + int(derp[x][8].text)
p3 = p3 + 3
elif p6 < 1424 and derp[x][7].text == 'The Rejected Realms':
pop6 = pop6 + int(derp[x][8].text)
p6 = p6 + 6
elif p7 < 2779 and derp[x][7].text == 'Balder':
pop7 = pop7 + int(derp[x][8].text)
p7 = p7 + 7
print pop2/1000,pop4/1000,pop5/1000,pop9/1000,pop1/1000,pop8/1000,pop3/1000,pop6/1000,pop7/1000
for x in xrange(1,7):
filename = 'nations'+str(x)+'.xml'
herp = open(filename, 'r')
derp = (etree.parse(herp)).getroot()
herp.close()
count()
print pop1, 'The Pacific'
print pop2, 'The North Pacific'
print pop3, 'The South Pacific'
print pop4, 'The East Pacific'
print pop5, 'The West Pacific'
print pop6, 'The Rejected Realms'
print pop7, 'Balder'
print pop8, 'Osiris'
print pop9, 'Lazarus'
print pop1+pop2+pop3+pop4+pop5+pop6+pop7+pop8+pop9, 'Total'
print 'time', time.time()start
derp = None
os.system('pause')
os.system('pause')
os.system('pause')
/me congratulates self on nifty for loop that runs through each file automatically.

revised version:
import os
import time
start = time.time()
from lxml import etree
p1,p2,p3,p4,p5,p6,p7,p8,p9 = 0,0,0,0,0,0,0,0,0
pop1, pop2, pop3, pop4, pop5, pop6, pop7, pop8, pop9 = 0,0,0,0,0,0,0,0,0
def count(p):
global p1,p2,p3,p4,p5,p6,p7,p8,p9,pop1,pop2,pop3,pop4,pop5,pop6,pop7,pop8,pop9,derp
for x in xrange(0,len(derp)):
if p2 < 5590 and derp[x][7].text == 'The North Pacific':
pop2 = pop2 + int(derp[x][8].text)
p2 = p2 + 2
elif p4 < 5100 and derp[x][7].text == 'The East Pacific':
pop4 = pop4 + int(derp[x][8].text)
p4 = p4 + 4
elif p5 < 4929 and derp[x][7].text == 'The West Pacific':
pop5 = pop5 + int(derp[x][8].text)
p5 = p5 + 5
elif p6 < 1424 and derp[x][7].text == 'The Rejected Realms':
pop6 = pop6 + int(derp[x][8].text)
p6 = p6 + 6
elif p9 < 3299 and derp[x][7].text == 'Lazarus':
pop9 = pop9 + int(derp[x][8].text)
p9 = p9 + 9
elif p1 < 4928 and derp[x][7].text == 'The Pacific':
pop1 = pop1 + int(derp[x][8].text)
p1 = p1 + 1
elif p8 < 2774 and derp[x][7].text == 'Osiris':
pop8 = pop8 + int(derp[x][8].text)
p8 = p8 + 8
elif p3 < 4963 and derp[x][7].text == 'The South Pacific':
pop3 = pop3 + int(derp[x][8].text)
p3 = p3 + 3
elif p7 < 2779 and derp[x][7].text == 'Balder':
pop7 = pop7 + int(derp[x][8].text)
p7 = p7 + 7
print pop2/1000,pop4/1000,pop5/1000,pop6/1000,pop9/1000,pop1/1000,pop8/1000,pop3/1000,pop7/1000, p
for x in xrange(1,7):
filename = 'nations'+str(x)+'.xml'
herp = open(filename, 'r')
derp = (etree.parse(herp)).getroot()
herp.close()
p = x
count(p)
print pop1, 'The Pacific'
print pop2, 'The North Pacific'
print pop3, 'The South Pacific'
print pop4, 'The East Pacific'
print pop5, 'The West Pacific'
print pop6, 'The Rejected Realms'
print pop7, 'Balder'
print pop8, 'Osiris'
print pop9, 'Lazarus'
print pop1+pop2+pop3+pop4+pop5+pop6+pop7+pop8+pop9, 'Total'
print 'time', time.time()start
derp = None
os.system('pause')
os.system('pause')
os.system('pause')

well fail, nsdossier already lists this info. edit: ahha, it can't process regions with 2k+ nations i win!

welp, after removing all bugs, i have started the first test run

absolution ns tracker seems to have gone down

now on part 2/6

damnit, i ran it, and it came up with a bunch of wrong answers

well its not working so i've simplified it to test one region at a time and see what was wrong.

how long does it take for 1 nation about? and how many nations total?

>nations?
i'm adding up regions

this is pretty epic
import os
import itertools as it
import networkx as nx
import matplotlib.pyplot as plt
derp = list(range(100))
def findsubsets(s,m):
return list(set(it.combinations(s,m)))
herp = findsubsets(derp,2)
for list in herp:
list = tuple(list)
G=nx.Graph()
G.add_nodes_from(derp)
G.add_edges_from(herp)
nx.draw_spring(G)
plt.show()

WIP, this prints out a list of all the embassy connections in nationstates
import os
import itertools as it
import networkx as nx
import matplotlib.pyplot as plt
from lxml import etree
herp = open('regions.xml', 'r')
derp = (etree.parse(herp)).getroot()
herp.close()
embassylist = []
for element in derp:
if len(element[9]) > 0:
name = element[0].text
length = len(element[9])
for x in xrange(0,length):
emb = element[9][x].text
perp = [name, emb]
embassylist.append(tuple(perp))
dictsort = {}
for x in embassylist:
dictsort[x]=1
embassylist = list(dictsort.keys())
print len(embassylist)
print embassylist

holykute

problem: networkx's graph layout doesn't work well  all nodes are locked on the origin for some reason
plan:
first use lxml to parse the nationstates region files
use networkx to create a graph with nodes as regions and edges as embassies
use networkx to convert the thing to graphml
since graphml is in xml format, somehow save it.
using jython, open graphml file
somehow import it into gephi and display it.

when will you update baitech? i am getting
BORED OUT OF MY
MIND!!!!!!!!!!!

hmm i've got python to trim out the [time] thing in the chatlog easily, but how to find spam and filter that out? i don't want darvince saying j8453hjfg3ovrrtes in the wordle 1 million times

<+what about usernames>

i can split at the '>'

derp

senary converter
dec to base/base to dec converter

*downloads so it doesn't say 0 downloaded times*
hmm what is dec and base?

decimal
base

ok so i was interested in how nations would be split into two alliance groups like the axis and allied in ww2 or something. so i wrote a script that generated optimal alliances based on relations data from here: https://docs.google.com/spreadsheet/ccc?key=0AqXNpALRcpv9dEptQVhHZWVNdlVqWTlDMHB2bUpUU0E
if all the nations are put into one alliance, the integrity value is 0, so it could break apart easily. using python i ran through all the 256 combinations and found the optimal sorting of
alliance 1: blaland + aeridani + ska + kallisto
with an integrity value of 266
alliance 2: aeridani + bielosia + ethanthova + kaeshar
with an integrity value of 218
integrity value is basically just all the relations of all the nations with all the other nations in the same alliance combined.
this uses bruteforce search but it takes like under a millisecond so i don't even care.
if you want to run a test with modified relations you can edit the file yourself or ask if you have any questions

It would be cool if you could make something extracting data points from selected nations' economy graphs and using it for some economic model like "Blaist NS GDP calculation".
http://universesandbox.com/forum/index.php/topic,5461.msg77727.html#msg77727 (http://universesandbox.com/forum/index.php/topic,5461.msg77727.html#msg77727)

it would. i'm trying something with that right now...^

well i made something that prints out numbers to make it easier to input into your economic model. it could be adjusted to print out into a text file where you could copy and paste straight into the spreadsheet cells directly. you should mess around with the files to adjust which nations are extracted or not. also you should leave the time.sleep(10) in because there's a rate limit of 10 requests per minute on ns. (so you could lower it to 6 or something i guess)
oh and if you change the display value to too high it'll break
luckily since ns keeps the economy data for like several months you can just run it once in a long while and plug

Nice, on the graph page it stores all the data points though. If there was a way to extract that it would be nicer.
Atm I can't edit Python code it seems, my IDLE must be broken or something. Idk.

notepad also works
and yes, the script takes the numbers from the data from the graph page. i don't get what you want to 'extract' exactly.

Got IDLE to work now.
From
luckily since ns keeps the economy data for like several months you can just run it once in a long while and plug
it just sounded like old graph data was deleted from whereever you got it from. I see that's not the case.
If you put this thing in
if display > 0:
for x in range(2,2+display):
print str(content[x]),
time.sleep(0.05)
print '\n'
you can see that it crashes when it reaches the amount of days the nation has existed. If there were a way to extract that number and ensure that "display" wouldn't be used if it were higher...
If there is a method to count commas in the "content" data, that should work.

content is a list so len(content) will tell you the amount of values stored and you can add an if statement to prevent that from happening.

vh is off. a python expert

I made it automatically extract all the numbers by using the comma count method.

instead of doing
display = int(str(content).count(",")) #Number of commas in data.
print element+': '+str(content[1])
print 'previous days',
if display > 0:
for x in range(2,2+display):
print str(content[x]),
print '\n'
maybe a better way would be
print element+': '+str(content[1])
print 'previous days',
for int in content:
print str(int),
print '\n'
because you're going to iterate over all the stuff in content anyways

i was going spend forever, but then i used python's calculator!

Ok.

hmm...
okay, long conversation with kip and it turned out that i read the problem wrong.
[11:02] <+Gunner55555> i read the question wrong
[11:02] <+Gunner55555> ops
so 3 to the power of negative 2 would be
3**2
right?"
so how do you make it so that the calculator does not round? because
684/41 does not equal 683/41

it's not a 'calculator'
You need to use nonintegers (684.0/41.0)

ok.
but i mainly use it as a calculator, so
and, it saves a lot more time than typing 'interpeter'

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '99761'.

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '99768'.

putting this here because if I need it in the future I'm more likely to find it here than in the NS map and roleplay
Soleani Word Generator
Disclaimer: Do not use this for Soleani words. I am very picky about what is a word these are all POTENTIAL words, though not all words are canon. Some of them suck. Badly. Ask atomic before use.
this code is free to use if you want to generate words with a similar structure
In case you find yourself running over your tounge this might help... or make it harder idk:
j is an english y consonant sound (like in scandinavian languages)
and ii is eyeeh
ai is eye
ei is ay
ie is ee
ae is another ay

added more strings.
now prints long and short words

gives rectangular coordinates that draw a circle
outputs at circle_draw.txt

from Tkinter import *
value = " "
class App:
def __init__(self, master):
frame = Frame(master)
frame.pack()
self.button = Button(frame, text="delete", fg="red", command=self.delete)
self.button.grid(row=1, column=0)
self.w = Canvas(frame, height=300, width=600)
self.w.grid(row=0, column=0, columnspan=2)
self.hi_there = Button(frame, text="Submit", command=self.update)
self.hi_there.grid(row=1, column=1)
self.input = Entry(frame)
self.input.grid(row=2, column=0, columnspan=2)
def update(self):
value = self.input.get()
value = value.split(" ") #how to put in XXX YYY TEXT
#load positions from a text file and put it in a picture on the canvas
#instead of value[2] paste an image
#be able to pan and scale the picture in the canvas
#convert an input of lat long to x y on the canvas
id = self.w.create_text(value[0], value[1], text=value[2])
print "Generated text %d." % id
def delete(self):
self.w.delete(ALL)
root = Tk()
app = App(root)
root.mainloop()
for ircclientmaking kips

Tkinter?

content of this message: http://pastebin.com/U99v45h0 (http://pastebin.com/U99v45h0)

woah did you learn that by tutorials or by asking kip?

/// dump http://ubuntuforums.org/showthread.php?t=1493702 (http://ubuntuforums.org/showthread.php?t=1493702)
#!/usr/bin/env python
import sys
import socket
import string
HOST="irc.freenode.net"
PORT=6667
NICK="asdf"
IDENT="asdf"
REALNAME="asdf"
CHAN="#asdf"
readbuffer=""
s=socket.socket( )
s.connect((HOST, PORT))
s.send("NICK %s\r\n" % NICK)
s.send("USER %s %s bla :%s\r\n" % (IDENT, HOST, REALNAME))
s.send("JOIN :%s\r\n" % CHAN)
s.send("PRIVMSG %s :%s\r\n" % (CHAN, "Hello There!"))
s.send("PRIVMSG %s :%s\r\n" % (CHAN, "I am a bot"))
while 1:
readbuffer=readbuffer+s.recv(1024)
temp=string.split(readbuffer, "\n")
readbuffer=temp.pop( )
for line in temp:
line=string.rstrip(line)
line=string.split(line)
if(line[0]=="PING"):
s.send("PONG %s\r\n" % line[1])

dump http://www.madsoft.org/2008/05/09/easilycreateircbotsinpythonwithpybotlib/ (http://www.madsoft.org/2008/05/09/easilycreateircbotsinpythonwithpybotlib/)

woah did you learn that by tutorials or by asking kip?
I used a bot tutorial and used prior python knowledge and googling for the rest. Also I forgot it needs three imports which I will add when I get home.

soket sys and string right?

import socket
import random
import urllib2

so do you make the stuff you're importing (modules, i tihnk) or is it already in python or do you download it off the internet?

modules yes
some you have to download but the creator will tell you if you need to, most are builtin

eu3 province generator
http://pastebin.com/aNMLARVK (http://pastebin.com/aNMLARVK)
it just prints out strings to the terminal and doesn't have a history section yet but i'll fix that

alliance (which is a list) contains lists of tags. this script prints out all possible alliances between the members of each list.
alliances = []
alliance1 = ['tag','doo','poo']
alliance2 =['forever','alone']
alliances.append(alliance1)
alliances.append(alliance2)
def create_alliance(tag1,tag2):
return 'alliance = {' +'\n'+'\t'+'first = ' + tag1 + '\n'+'\t'+'second = ' + tag2+'\n'+'\t'+'start_date = 1399.1.1'+'\n'+'\t'+'end_date = 1822.1.1'+'\n'+'}'
for list in alliances:
alllist = []
for x in xrange(0,len(list)):
for y in xrange(0,len(list)):
if x != y:
temp = [x,y]
temp.sort()
alllist.append(tuple(temp))
for element in alllist:
print create_alliance(list[element[0]],list[element[1]])

til if you have a list with type1, type2, and type3 objects and you do
for type1 in list:
print list
it'll print all the items of any type

write a
<title of program> for n00bs
guide

a thing that i will use in the future
updated code for kips:
def char_replace(syl, fulltxt, rep):
j = 0
for i in fulltxt:
if fulltxt[j] == syl:
fulltxt[j] = rep
else:
pass
j += 1
return fulltxt
def conv_to_out(txt):
out = ""
j = 0
for i in txt:
out += i
return out
text = raw_input("Enter text: ")
text = text.split(' ')
#things to change
text = char_replace('ka', text, unichr(57344))
# most likely always the last 2
text = char_replace(' ', text, '')
text = char_replace('/', text, ' ')
text = conv_to_out(text)
text = text.encode('utf8')
#print text
f = open('pony.txt','w+b')
f.write(text)

wow 5 characters what a pro

nbody 2d gravity simulator in the works
g = 6.67384
list = []
def calc_grav(m1, m2, r):
f = g*((m1*m2)/r**2)
return f
class object:
lx = 0
ly = 0
lr = 0
lt = 0
mass = 0
vx = 0
vy = 0
vr = 0
vt = 0
def __init__(self, x, y, r, t, m, vx, vy, vr, vt):
self.lx = x
self.ly = y
self.lr = r
self.lt = t
self.mass = m
self.vx = vx
self.vy = vy
self.vr = vr
self.vt = vt
#generate two test objects
sun = object(0.0, 0.0, 0.0, 0.0, 1000.0, 0.0, 0.0, 0.0, 0.0)
pl1 = object(1000.0, 0.0, 1000.0, 0.0, 10.0, 0.0, 40.0, 40.0, 90.0)
pl2 = object(2000.0, 0.0, 2000.0, 0.0, 15.0, 0.0, 15.0, 15.0, 90.0)
list.append(sun)
list.append(pl1)
list.append(pl2)
#calculate distance
#insert method thing here
d = sun.lx  pl1.lx #temporary
#calculate gravitational force
i = 0
combos = []
for o in list:
j = 0
for p in list:
# print "%s, %s" % (i, j)
if i >= j:
pass
else:
print calc_grav(o.mass, p.mass, d)
j += 1
i += 1

sfdjkasl

i spy redit

damn i lost like 6 links to ircbots
now i have to look them up again

what is my port

help
while 1: # Be careful with these! it might send you to an infinite loop
ircmsg = ircsock.recv(2048) # receive data from the server
ircmsg = ircmsg.strip('\n\r') # removing any unnecessary linebreaks.
print(ircmsg) # Here we print what's coming from the server
if ircmsg.find(":Hello "+ botnick) != 1: # If we can find "Hello Mybot" it will call the function hello()
hello()
if ircmsg.find("PING :") != 1: # if the server pings us then we've got to respond!
ping()
if data.find ( 'PING' ) != 1:
irc.send ( 'PONG ' + data.split() [ 1 ] + '\r\n' )
if data.find ( '!kolok quit' ) != 1:
irc.send ( 'PRIVMSG ##Universesandbox :Fine, if you dont want me\r\n' )
irc.send ( 'QUIT\r\n' )

the indents are spaces either indent with spaces or change them all to tabs

so do i like tab after the colon or??

everywhere there is an indent, remove it, and tab

it's a prototype for god's sake!

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '102879'.

wow that's amazing

wow that's amazing

wow that's amazing
why did that sound sarcastic

i'm done.
the image takes a few minutes to generate. (a bit less than 10)
the number of provinces increases the time needed linearly
the map size increases the time quadratically, but changing the map size increases the provinces too which means it's really n^3

wow that's amazing
why did that sound sarcastic
probably because you always percieve my sarcasm as nonsarcastic
because that wasn't sarcasm

here's an image that was generated and i resized to 10%

ispythecolorsofbla

that works
i will work on the file generation this weekend
you might have to remind me, and not today, on saturday please

Lame Curves
Circular Arcs are just ONE Form of the Lame Curves.
I "Invented" these in 1992  but found out two weeks back, that they had already been invented
Boo Hoo :( :( :( :(.
To generate ONE Quadrant  where X and Y are both Positive with respect to the "centre" of the figure ( 0,0 ).
And using a "normalised" Figure  1 Wide, 1 High.
Pythagorus gives us that any point on a Circular sweep will be given by Y = ( 1^2  x^2 )^0.5.
Where 1 is the Hypotenuse ( Radius ).
To alter the "normalised" figure to an Oval, the Values of XScale and YScale should be different.
In creasing both Xscale and Yscale by the same amount gives simply a larger figure.
For X = 0 to 1 Step 0.000001
Y = SQRT ( 1  X^2 ):
XPlot = X*Xscale: YPlot = Y*YScale:
Plot Xplot, YPlot:
Next X
For the Full Circle, we need to "handle" Negative X and Y Values.
So  we get 
For X = 0 to 1 Step 0.000001
Y = SQRT ( ABS ( 1  X^2 ):
XPlot = X*Xscale: YPlot = Y*YScale:
Plot Xplot, YPlot:
Next X
For X = 0 to 1 Step 0.000001
Y = SQRT ( ABS ( X^2  1 ):
XPlot = X*Xscale: YPlot = Y*YScale:
Plot Xplot, YPlot:
Next X
For X = 0 to 1 Step 0.000001
Y = SQRT ( ( 1  X^2 ):
XPlot = X*Xscale: YPlot = Y*YScale:
Plot Xplot, YPlot:
Next X
For X = 0 to 1 Step 0.000001
Y = SQRT ( ABS ( X^2  1 ):
XPlot = X*Xscale: YPlot = Y*YScale:
Plot Xplot, YPlot:
Next X
Now  What use is that ??
Well  for a CIRCLE  Not a LOT.
However  the critical change is if we place the Circle in "distorted" 3D Space.
If instead of SQRT ( Square Root ) and ^2 ( Square ) which are true for a Circle  we substitute
The "Power" of 1/N and the "Power" of N.
Then strange things happen to our curved figure.
The "program" for the First Quadrant then becomes 
For X = 0 to 1 Step 0.000001
Y = ( 1  X^N )^1/N:
XPlot = X*Xscale: YPlot = Y*YScale:
Plot Xplot, YPlot:
Next X
As N is reduced to a little less than 2  the curves start to "flatten" in each Quadrant, although the Rate of Change of Curvature remains consistent. They also become a little "sharper" at the meeting of Quadrants
As N is increased to a liitle more than 2  the curves become "sharper"in each Quadrant, although the Rate of change of Curvature remains consistent. They also become "flatter" at the meeting of Quadrants.
The Lame Curves are ALWAYS Transition Curves  with no points of sudden acceleration or sudden develeration of curvature.
At modest values of N  they could be used to lay out Roads or the curves of Railway Track.
How about bigger changes in the value of N 
At exactly N =1  we get a diamond shape, a square rotated by 45 degrees.
At truly Massive values of N ( up to 10^30 )  we get an almost Square, with very slightlty curved sides asnd nearly sharp, curved corners.
At truly Miniscule values of N ( down to 1/10^30 )  we get an almost cross ( or crux )  except that the middle is slighty fatter than the intersection of two straight lines, it actually comprises a very slightly curving line in each Quadrant, which turns through 90 degrees in an incredibly tight curve, very near to the centre.
A wide range of these Curves can be used for Transition Curves with different "orders" of Curvature, in a number of applications.
For example  to create a range of "Ship Curves" for layingout a Scale Drawing of a Ship's Hull  the Values of Xscale ( length ) and YScale ( half beam ) can be set to the desired values for the Drawing.
By changing the values of N through a range of values the  both "convex" and "concave" transition curves or useful Ship Curves can be generated.
Okay  this all sounds like fancy theory.
However  I have tried this, and it does work.
I Ran this as a Program, many times in 1992 on the Mainframe Computer at Thames Polytechnic.
With Step Values as small as 1/10^12 and values of 'N' from 10^40 down to 1/10^40 
in both directions ( massive and miniscule values of 'N' ).
As I have already implied  Values of 'N' ( the "order" of the Curves ) between 10 and 1/10 are more useful than the more extreme examples.
I have also Run this as a Program on my BBC Microcomputer  although the range of values of 'N' and the maximum number of Steps had to be reduced seriously.
In all cases, the Program worked exactly as Predicted, and as Described above.

Re: A Random Word Generator 
One of those would immensely useful.
I am running a Sci Fi Game  some Human Star Systems, some Alien Star Systems.
The Names of Planets, Continents, Cities all have to be "Invented" in many cases 
a Random Word Generator may help makr my Job easier.

cute
the wikipedia page on the curves you described in general is here
http://en.wikipedia.org/wiki/Superellipse (http://en.wikipedia.org/wiki/Superellipse)

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '102925'.

don't we all

TIL god has a sake

Re: A Random Word Generator 
One of those would immensely useful.
I am running a Sci Fi Game  some Human Star Systems, some Alien Star Systems.
The Names of Planets, Continents, Cities all have to be "Invented" in many cases 
a Random Word Generator may help makr my Job easier.
kip and I both made different generators but they only generate words based on our conlangs, if you could even call Kip's that

before

after

ispythecolorsofbla

partially finished thing
i will probably do python all week because i do not productive on weekends at all

i fixed the memory error by splitting the gigabyte list into it's elements and pickling each
you can see all the times when the program crashed here, it's currently running smoothly
(http://i.snag.gy/VyncH.jpg)

whats up with the red line

import random
import math
all = []
class particle:
x = 0.0
y = 0.0
def __init__(self, x, y):
self.x = x
self.y = y
def distance(x1, x2, y1, y2)
x = math.fabs(x2  x1)
y = math.fabs(y2  y1)
math.hypot(x, y)
def interact(obj1, obj2):
force = 1/(distance(obj1.x, obj2.x, obj1.y, obj2.y) ** 2)
#find the direction both objects are going somehow and then make them attract
w = "%s\t%s\t\n" % () #bakjfdsjk
f.write(w)
n = int(raw_input("Number of particles: "))
for x in xrange(0,n):
all.append(particle(random.random()*7, random.random()*7))
i = 0
f = open('data.txt', 'w')
for x in all:
w = "%s\t%s\t%s\t" % (i, x.x, x.y)
f.write(w)
i += 1
f.write("\n")
i = 0
for x in all:
j = 0
for y in all:
if i <= j:
interact(x, y)
else:
pass
j += 1
i += 1
f.close()
print "done"
stupid particle kind of like the stupid other simulator actually i stopped at the same point, finding out which direction the object are going using arccos/sin because that only spans from 0 to pi radians or pi/2 to pi/2 would i just add pi to get the other object? and then which object is the one's value i am actually getting?

i'm going to suggest not using trig because that is slow
an example on how i would figure out the force of b acting on a
keep everything in component form vectors
so if you have bodies A and B
Av is the velocity vector of a. something like <0,0>.
force = mass*constant/distance^2
don't actually compute the distance by square rooting because you'll square it anyways in the end
if the position of A is <ax,ay> and the position of B is <bx,by>, then find the offset <bxax,byay>
then suppose the mass * constant = 8 and distance = 4, so force is 2
multiply the offset <bxax,byay> by 2 to get the force vector called Bf
force = mass*distance/time^2
divide by mass
acceleration = distance/time^2
multiply by time
velocity = distance/time
use the mass of A, the time is the length of your timestep
so Bf/mass*time = velocity
add the velocity vector to Av which is the velocity vector of object A
for every object you add their velocity vector to the velocity vector of A
then if you end up with the velocity vector <3,2>, you move A right 3 units and down 2 units

I didn't get a chance to read the whole post yet, but I already have the force part down.

ok thats nice
although i wanted to note that you were finding the distance with math.hypot which uses a square root. since you're going to square the distance afterwards, you should probably not bother with the square root operation which takes a bit of time.

Ok all the post explained to me was what I already knew about simulating the stuff... and then you throw vectors in the last 3 lines. How do you suggest I do the vectors as I can't figure out the inverse trig functions and how that would work, and you say it'd be slow?

vector = [thing1,thing2]

I'm talking about you know, instead of using trig to get an angle and a magnitude (polar coordinates), how else you expect me to calculate where the thing is to move. Start from having the magnitude (distance calculated from acceleration and timestep).
Like... the part you skipped here:
for every object you add their velocity vector to the velocity vector of A
here
then if you end up with the velocity vector <3,2>, you move A right 3 units and down 2 units

ok i was mistaken you actually have to calculate the distance
there are objects x and y
object x is at position with mass 6 and a velocity of 0,5
object y is at position 5,3 with mass 7 and a velocity of 1,2
the gravitational constant is 2
calculating the effect
the force is (6+7)*2/((52)^2+(33)^2) = 0.5777....
the movement of x:
relative to x, object y is at 3, 6 (52,33)
the magnitude is sqrt(45) from sqrt(3^2+6^2), however we want to make it 0.5777 because that is the force
0.577.../sqrt(45) * (3,6) gives us (0.2583, 0.5168)
pretend the time step is 5 units of time
we multiply by 5 because the force is sustained for that long
(1.2915, 2.583)
then divide by the mass of object x since we are calculating the movement of object x
(0.2152,0.4305)
by dividing by mass we've converted force to acceleration since
f = ma
f/m = a
now multiply by the lenght of the time step again
(1.076, 2.153)
acceleration = velocity/time (as in meters per second per second)
so (1.076, 2.153) is the velocity of motion that object y causes to object x
since there are no other objects which gravitationally pull x
(0,5) + (1.076, 2.153) = (1.076, 7.153) is the current velocity of object x
add velocity to position (2,3)
(3.076, 10.153)
repeat for y
disclaimer: i haven't taken physics so i have no idea what i'm talking about this all comes from one week of vectors in math

yeah I think I'll just figure out the trig...

i have dictionaries with the values of the dictionary keys being a list, and the keys are strings
i want to count how many objects i have in the lists combined
strategy 1:
sum = 0
for key in dict:
sum += len(dict[key])
>gets result of around 120,000
strategy 2:
sum = 0
for key in dict:
for object in dict[key]:
sum += 1
>get a result of 76,000
wtf

wait actually that wasn't the problem, this is:
sum = 0
for key in dict:
for object in dict[key]:
sum += 1
>sum of 120,000
sum = 0
for key in dict:
for object in dict[key]:
sum += 1
if something:
delete from the list
>sum of 76000
ok i'm suspecting the deleting is screwing with the list

^it was i've fixed it

example of problem:
count = 0
derp = range(1000)
import random
for int in derp:
count +=1
if random.random() < 0.5:
derp.remove(int)
print count
>>>667
thats not a thousand ponies, thats 667, and that's a problem >.<

.

idk if i posted this here but i need this
import math
g = 6.67384
list = []
gravity = []
thetas = []
def calc_grav(m1, m2, r):
f = g*((m1*m2)/r**2)
return f
def calc_rt(x1, y1, x2, y2):
x = x2  x1
y = y2  y1
c = math.sqrt(x**2 + y**2)
theta = math.degrees(math.acos(x/c))
return c, theta
class object:
lx = 0
ly = 0
lr = 0
lt = 0
mass = 0
vx = 0
vy = 0
vr = 0
vt = 0
def __init__(self, x, y, r, t, m, vx, vy, vr, vt):
self.lx = x
self.ly = y
self.lr = r
self.lt = t
self.mass = m
self.vx = vx
self.vy = vy
self.vr = vr
self.vt = vt
#generate two test objects
sun = object(0.0, 0.0, 0.0, 0.0, 1000.0, 0.0, 0.0, 0.0, 0.0)
pl1 = object(1000.0, 0.0, 1000.0, 0.0, 10.0, 0.0, 40.0, 40.0, 90.0)
pl2 = object(2000.0, 0.0, 2000.0, 0.0, 15.0, 0.0, 15.0, 15.0, 90.0)
list.append(sun)
list.append(pl1)
list.append(pl2)
#calculate gravitational force
i = 0
for o in list:
j = 0
for p in list:
# print "%s, %s" % (i, j)
if i >= j:
pass
else:
d = calc_rt(o.lx, o.ly, p.lx, p.ly)
gravity.append(calc_grav(o.mass, p.mass, d[0])) #do i really need arrays yet?
# thetas.append(d[1])
j += 1
i += 1
print gravity
#print thetas
#TO DO
#calculate magnitude of force ^^^^^^^^^^^^^^^
#calculate direction of force ^
#calculate x, y of the force
#add to initial motion vector (x, y)
#store this final vector so that it can be used next iteration, and multiply the vector by the timestep to get the new location of all objects
#add config file for custom simulations
#add output file

what is this?

what is this?
http://forum.nationstates.net/viewtopic.php?f=12&t=238623 (http://forum.nationstates.net/viewtopic.php?f=12&t=238623)

1 dimensional fourier transform implementation
e = 2.7182818
pi = 3.1415926
i = 1j
def summation(bottom, bign, function, m, x):
sum = 0
for n in xrange(0, bign):
sum = sum + function(m, x, n, bign)
return sum
def sumfun(m, k, smalln, bign):
return e**(i*2*pi*k*smalln/bign)*m[smalln]
def fft(m): #list
bign = len(m)
r = [0]*bign
for x in xrange(0,bign):
r[x] = summation(0, bign, sumfun, m, x) #xn and k
return r
m = [3,2,0,1]
print fft(m)/code]

you need pygame (module) for this
a test game thing
oh wait you need my car file too (put it in the same folder as the script is)

gneiss
worst name ever though
ok i've figured out how to turn

you might want directions
up arrow  'gas'
down arrow  'brake' (i want to make these function more like them)
left arrow  pivot left
right arrow  pivot right
page up  drive (you start in neutral)
page down  reverse

solution: play f1 instead

you might want directions
up arrow  'gas'
down arrow  'brake' (i want to make these function more like them)
left arrow  pivot left
right arrow  pivot right
page up  drive (you start in neutral)
page down  reverse
wait whats the difference between the gas pedal and the drive pedal if i just press gas will a pile of gasoline start leaking out

you can't drive in the neutral gear, so you have to put the car in drive and then you can use the gas to accelerate!

now add gas and prevent the car from going off screen
and is it just me or is the acceleration constant unused

it's unused atm

hashcash generator with size argument and writing to file

a value of 100,663,296 in hashcash
N8qX4e1ZlDRpstt2AxSDYSR7onRKcDdJ3sh8H77ZJqRJbS1tWnp7Qq53GEXuFi6h
GHB4V0bub7cppl3SARH3wCGgzdjCHcg9jSWj116nvAAIJJXnUPkIbZzwXR7EMFjm
Ae0xRoh0q2ciKAh4kl05mwufEgJEFY4RiipD26AwyQq1Hy4MyMVMiGIYTL3KZMGt
cy74uw95TcF5i5mqWpcse0DCO0CEp6LMhzFcwCwMBzHl1Os2KPznysSBt7pMs9vC
6EXhgO4s9W8JWP0JDAljlSjEVviGxzuDcFxTLPPCMFozQAvaZNLmy6FTOxTLulhW
VbioCBvUqlqhzBS6iBa1y5gnL8wXamMRsFvgPCgnytOmG6iDzzvElRm53Kc26aHB

print "1D pressuregradient force simulation"
dx = 100000 #m
v = 0
j = 0
i = raw_input("Iterations: ")
i.strip('\n')
def calc(v, dx):
a = (1/1.275) * (500/dx)
preV = a*60 #ms^2 * s > ms^1
v += preV
dx += v*60 #ms^1 * s > m  distance moved is ????'d
return v, dx
while j < int(i):
data = calc(v, dx)
v = data[0]
dx = data[1]
print str(v) + " m/s, " + str(dx) + " m\n"
j += 1
#equalizing pressure?
idk if i'm doing this right...

import math
print "Coriolis parameter calculation"
deglat = raw_input('Latitude: ')
lat = int(deglat)*(math.pi/180)
calc = 2*((2*math.pi)/24)*math.sin(lat)
print str(calc) + " (coriolis parameter)"
v = [15, 0] #ve, vn  m/s  chosen default values
a = [v[1]*calc, v[0]*calc]
print a
I think i'm doing this right but still pressure gradient force looks suspicious

soo i'm sharing this because the psutil module is pretty neat
(http://i.snag.gy/yRMym.jpg)
here, g is the python27.exe process, and i'm running a cpu heavy script. if i'm trying to play ksp or something, i want the thread to pause so more cpu power can go towards what i'm currently doing. to detect this, i measure if the cpu utilization is high, yet the python utilization of the cpu is lower than 90% of the cpu utilization, then pause it. if the cpu usage decreases afterwards, the process resumes

this is a better version
(http://i.snag.gy/ghdTi.jpg)

does it do it automatically or did you code something that you didn't post here? :P

it's automatic :), the while loop just runs the detection forever
if you are pausing a python process though, you have to be careful because there will be two python processes, the script you're running, and the interpreter i have open here
i had to find the process id manually, but it only took a minute, and i'm sure you can automate it if you want

no i mean actually running it

huh
yeah that while loop is all the code i used

how do you run multiple lines in cmd

huh
this was interpreter
but you can do it on cmd too, just type in 'python' (without quotes) or in my case, python27 because i renamed it, and the cmd turns into an interpreter

the captionator adds captions to all your images quickly and efficiently
tell me if you have any bugs regarding how well the text fits

what do you have to import

i got an error message

all the imports should be installed by default.
this modified version will delete files if you leave the caption blank, exit if you enter 'break' as the caption, and start at any screenshot you want. so if you captioned 500/10,000 screenshots, you can start at 2013342004.png. if you leave start blank , you start from the beginning
edit; some errors with below version
ok fixed
the folder you are captioning must contain only image files

no pil

i think this is the tk inter stuff but idk if it works i tried it and it broke when i typed things so idk what i did to it but it used to work

i need a program that clicks every 3045 seconds, and it has to be random. by click i mean like a left click

i know this is about empireattack. mudkipz made a python script to continuously click in an outward circle from his capital and his account got banned for a week.

well fuck i'll test it on another account

how did they even know he had a bot, or did they?
and how could they tell if it clicked at random?

protip for copying:
suppose you have a piece of data, and you want to do two things to it. in my case, i had an array of data representing an image which i wanted to do two things with.
1. simulate particles moving on the image
2. render the image with particles
since the particles weren't on the image (i had them in a separate class), i would have to change the array in order to render the image.
the obvious solution is copying
renderdata = data
but this is a reference to the list, not an actual copy. this is wrong because
>>>data = range(1000)
>>>tempdata = data
>>>tempdata[0] = 100
>>>data[0]
100
to fix this, you should do
renderdata = list(data) #creates a new list
or
renderdata = data[:] #creates a slice of data, which is a new list
tl;dr use copy = list(data) for making a copy of a list instead of a reference

protip #2:
representing the number 1 as a '64bit bigendian integer' just means
00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000001
argghh terminology

item copying tip:
>>>e = range(100)
>>>g = e
>>>g[0] = 50
>>>e[0]
50
when you copy e, you are only getting a refernce to it. thus, changing g changes e
this can normally be fixed by doing this
e = list(g)
or
e = g[:]
however, in some cases, this does not work (i still do not know why, except that this has caused me hours of trouble)
in those cases,
import copy
e = copy.deepcopy(g)

I was messing around with PIL (Python Image Library) and created a simple image based on random colors.
from PIL import Image
import random
import operator
width = 100
height = 100
data = []
start = (random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
for x in xrange(0, width*height):
rand = (random.randint(5, 5), random.randint(5, 5), random.randint(5, 5))
data.append(tuple(map(operator.add, start, rand)))
start = tuple(map(operator.add, start, rand))
img = Image.new('RGB', (width, height))
img.putdata(data)
img.save('image.png')
(first two images use 1/1, last two use 5/5)

huh pretty

Nice, could be adapted to generate planetary ring textures maybe? Or maybe textures for gas giants.

i've been on this for a few days but got bored. basically it simulates the formation of cities out of randomly distributed populations.
first it initializes cities on the map. then, for each city, it calculates the 'value' of each piece of land around it taking into account population density and distance. then, the city moves from it's current position to the land with the highest value. repeat.
the code runs fine but no cities form for some reason.

does anyone know where to get some coastline data
I don't know but I'm going to hav to somehow decode it and stuffs and put it into PIL to get a map

what do you mean by coastline data? images of coastline?

like
numbers
latitude and longitude
locations

of what? every point on the coastline?

yes

tkinter documentation is surprisingly sparse. here's an alpha version of URANCO (uranium enrichment company simulator)

so it seems that even rendering a simple 3d object is difficult in python. i've read the panda3d documentation, opengl documentation, and none of it seems to make sense. blender works, but it's python 3. this sucks.
however, i think i could write some code to render shapes in a 3d environment for tkinter, allowing me to render 3d shapes. the optimization would take some time though.

what is this

pyGCM = python Global Climate Simulator.

my first python program done :)

i was expecting it to be tkinter and nothing else

global climate model

how do you know that it even makes sense how do you have data output
rn i'm too tired to fix my model's grid edge problems so i don't even know if it works yet because that kind of breaks the program if it tries to put something in grid[1][1] sooo
I have also decided that my ocean model is pretty bad and even when i add the land it'll probably fail horribly and end up only simulating a general current direction (which we basically already know anyway, defeating the purpose) and not even the temperature. I could do an atmospheric model much better, considering that involves actual pressuregradient force. My ocean model only takes into account coriolis and a sine wave approximation of winds.

grid[1][1] is valid
>>>g = [1,2,3]
>>>g[1]
3
so it automatically warps on one side already
on the other
>>>g[3%len(grid)]
1

if calc1 > 0 and calc1 <= 1:
newgrid[r1][c1].append(calc1*cell.t)
if calc8 > 0 and calc8 <= 1:
newgrid[r][c1].append(calc8*cell.t)
it likes the first one but errors the other?

that indenting is screwy, use code
and....it'd help if you also typed out the error message

if usforum had karma i would give you about 100 karma.

PYPY is fast
(http://i.snag.gy/pqWmD.jpg)

Uhhhhhhhhhhhhhh.......................................... what

wtf is pypy

it speeds up pygmc

wtf is pypy
pypy is like an implementation of python but faster. there's a complicated explanation but all you need to know is that it's faster for most things

i want complicated explanation

so i've got this idea and if atomic or someone thinks its promising i'll code it
basically you have two 'swarms' of instances which 'battle' with each other until one side wins
each instance, or bot, in the swarm has
memory
processing power
scanners
energy
communications
energy transfer
energy weapons
each player will give a set of instructions (code) to the bots to do stuff like accelerate in a direction, transfer energy, communicate information, compute, scan for enemies, store information, etc. of course, there are several limitations that the player must follow
each bot will have an attribute memory, which is a list. so for example, in your code, you can't say "v = 40", instead, you have to store it as bot.memory[0] = 40. if the memory exceeds the requirements, it'll be overwritten/wiped.
another restriction is processing power. i haven't figured out how to regulate this yet, but basically each bot has a limited amount of power so it can't run expensive algorithms and shit.
there are also communications, for sending from 110kb of information. very helpful if you can't process the data fast enough, you can have a bot scan and send the information to other bots for processing.
the rest of the things are pretty much self explanatory. you use energy to attack, accelerate, maybe some other things. there's also damage, which goes from 0 to 1 and at 1 the bot is destroyed. ability of the bot to function is determined by (1d)^0.2 where d is damage.
to add more interesting things, i thought bots might be able to specialize. for example, there could be group of computation bots and a group of scanning bots which work together better than bots which do both scanning and computations. so you can allocate the abilities of each bot towards a particular function.
distance affects communications, energy transfer, and weapon damage
so, basically, competitors of players will create a short bit of code (probably limited to 100 or 200 lines) in order to compete with the enemy swarm. they'll be given a list of functions to use like scan(), accelerate(direction), senddata(id), and etc to use.

this sounds like it'd be a good flash game thing
idk how you're planning to do it but if it was like programming 10 python things at once that sounds like it could be overwhelming

class BOT
like that.

short script, the hardest part was getting the memory to clear itself, which i solved by defining the thingy as a function
basically you download a few of these files from http://nsarchive.net/, (http://nsarchive.net/,) don't unzip them.
then put the processor in the same directory as the files and run. it should take a bit over a minute per file and happily eat 2gbs of ram. when it's done you'll have several 100 MB files sitting in your folder that contains the attributes of every single nation in ns for that time period
so i can load each file and say
mainstats = []
for nation in thingy:
mainstats.append(sum(nation.freedomscores))
count = 0
for 300 in mainstats:
count += 1
print count
to find out how many nations have 100 civil rights, 100 economy, and 100 political freedom. no screwing around with xml files, parsing, and stuff because i've already done that

Nice, do you know if that archive also stores all the detailed statistics like income equality and stuff?

well it stores the social equality budget for government. but no, it doesn't have the 69 census measures, you can only get those by the api and they're not archived. actually the daily dumps aren't archived by default either, this is just a playermade database

for dar

i thank

adsf

rough pseudocode that will attempt to weave together chatlogs
import os
import glob
filelist = ['kipulog.txt', 'atoulog.txt', 'darulog.txt']
combcount = 0
comblist = []
#gets number of each file
def getmax(f):
m = [[],[],[]]
for x in range(0,3):
for file in glob.glob('*'+f[x]):
print file
if str.isdigit(file[:2]):
m[x].append(int(file[:2]))
else:
m[x].append(int(file[0]))
m[x] = max(m[x]) #get all file lengths
return m
class SplitFile
filemax = getmax(filelist)
def __init__(self, name):
self.name = name
self.index = 0
def open(self):
#f = open(self.index + self.filename, 'r+')
#open self.index
def close(self, name):
#write f into open(self.index + name, 'w')
#f.close()
def readline(self):
#f.readline()
def getnext(self):
#m = readline
#if m == ''
#close(name)
#self.index += 1
#if self.index != max:
#open()
#m = readline()
#return m
#readline, else close, increment, open, read.
#else
#return 0 if end of file
def within(self, time, length):
#open current file, before, and after
#build a list with all cases
#find first, and find last that fit
#close the files
#return them all inbetween
#return all entries within length of time
def search(object, maxtime, loe): #loe is list of entries
#a more efficient search than the one presented can probably be accomplished
#for item in loe:
#if object.alias = item.alias and object.text = item.text and abs(object.timeitem.time) < maxtime:
#return index? or item? or just modify item?
def offsetscan(tlist):
#initiate instances of splitfile for all three threads in tlist
#for each thread:
#while 1:
#l = get next until length > LONG:
#l2 = search(l, MAXTIME, log)
#find l.time l2.time
#assign that value to offset
#assign offset to l.offset
#break at eof (0).
#modifies tlist
def poffset(thread, ref):
#for item in thread:
#item.time += item.offset[ref]
#clears offset parameter and makes it zero, shifting the time in the process
def poff(tlist)
cthread = 'kipulog.txt' #official time thread
#kipulog already synchronized
#poffset(atoulog, kipulog)
#poffset(darulog, kipulog)
#use poffset to synchronize all times with cthread
def getfirst(threadlist):
#initialize t as [0, 0, 0]
#for each thread:
#t[x] = thread[x].time
#i = t.find(max(t))
#return i
def combadd(item,comblist):
#if comblist is short:
#comblist.append(item)
#if comblist is long:
#write to file
#increment filename by one
#comblist = []
def weave(tlist): #tlist must be poffset
'''
combines all threads in tlist into a single thread
'''
f = getfirst(tlist) #returns index of first thread
#while 1:
#n = f.getnext()
#for two other logs:
#j = search(log.within(n), SHORT, log)
#m = log.getnext()
#if j:
#j.incorp = 1
#n.incorp = 1
#if j != m:
#f = log
#break
#else:
#j.incorp = 1
#combadd(j)
#if eof:
#break
#end

model for ubv where ubv.py and engine.py are run simultaneously off two command prompts
simultaneously:
ubv.py reads in text from next.txt and sends it to the channel
ubv.py reads in text from freenode and writes it in rec.txt
and
engine.py reads in text from rec.txt as a list, processes the first element, and deleted it
engine.py takes the result of the processing and writes it back into next.txt
this way, even if processing takes a minute or two, ubv.py will continue pinging and just check next.txt to see if engine.py and come up with an answer. it also neatly encapsulates the processing into a single function

import Image
import numpy as np
import cPickle
from operator import itemgetter
hdist = 60 #distance between each day
aliasdict = {}#connects aliases to numbers
colordict = {
1:np.array([255,0,255]),#
2:np.array([255,128,128]),#
3:np.array([128,255,128]),#
4:np.array([255,255,0]),#
5:np.array([128,128,255]),#
6:np.array([0,255,255]),#
7:np.array([255,128,128]),#
9:np.array([255,64,192]),#
10:np.array([255,192,64]),#
11:np.array([170,170,170])#
}
biglist = cPickle.load(#whatever)
biglist.sort(key=operator.itemgetter(0)) #sort by time
#get alias most used
aliaslist = {}
for line in biglist:
b = line[1]
if b not in aliaslist.keys():
aliaslist[b] = 1
else:
aliaslist[b] += 1
#sort by value
aliaslist = list(reversed(sorted(aliaslist.iteritems(), key = operator.itemgetter(1))))#now a list
for x in xrange(0,10):
aliasdict[aliaslist[x]] = x+1
print aliasdict
def additivepaste(canvas, article, c, r):
for x in xrange(0,len(article)):
for y in xrange(0,len(article[0])):
canvas[x+c][y+r] += article[x][y]
ls = 25
def j2u(j):
return (j2440587.5)*86400.0+ls
def u2j(u):
return ((uls)/86400.0)+2440587.5
class Day:
mlen = 460
mtime = 10
duration = 6
i = Day.mlen/2
aliascount = 13
def __init__(self, julian, start, lines=[])
self.julian = julian
self.start = start
self.lines = lines
self.total = 0
for line in lines:
self.total += len(line[2])
self.map = numpy.zeroes([Day.mlen+1,90000/Day.mtime,Day.aliascount])
self.article = numpy.zeroes([Day.mlen+1,90000/Day.mtime], dtype=(float,3))
def addline(self, line):
c = aliasdict[line[1]]
#assume odd num
l = len(line[2])
for x in xrange(il/2, i+l/2):
t = (line[0]start)/10
for y in xrange(t, t+Day.duration):
self.map[x][y][c] += 1.0/(yt+1.0) #fades as it ascends
def makearticle(self):
for x in xrange(0,len(self.article)):
for y in xrange(0,len(self.article[0])):
for z in xrange(0,Day.aliascount):
self.article[x][y] += colordict[self.map[x][y][z]]
def contrain(self):
for x in xrange(0,len(self.article)):
for y in xrange(0,len(self.article[0])):
self.article[x][y] = list(reversed(sorted(self.article[x][y])))
overflow = 0
for c in xrange(0,3):
d = self.article[c]255
if d > 255:
overflow += d
elif overflow > 0:
if overflow > d:
self.article[c] = 255
overflow = d
else:
self.article[c] += overflow
overflow = 0
else:
break
daylist = []
#add days
for line in biglist:
j = int(u2j(line[0]))
if daylist[1].julian == j:
daylist[1].lines.append(line)
else:
daylist.apppend(Day(j, j2u(j), [line])
days = int((llist[1][0]llist[0][0])/86400)+2
offset = 1000
voffset = 500
canvas = np.zeroes([days*hdist+1000, 90000/Day.mtime], dtype = (float,3))
for day in daylist:
additivepaste(canvas, day, day.julian*hdist+offset, voffset)
#contrain to 255
for x in xrange(0,len(canvas)):
for y in xrange(0,len(canvas[0])):
for c in xrange(0,3):
if canvas[x][y][c] > 255:
canvas[x][y][c] = 255
#convert to image
img = Image.fromarray(canvas, 'RGB')
img.save('irc.png')
code to convert irc logs into an visualization. the only parts thats uncompleted is the part where i load in the data. that'll have to wait until i complete the code from two post above about merging the logs

what's a visualization? like how do you see the text in a log other than opening a txt file?

code to download the zday data from ns api.
import urllib2
import time
def getevent(str):
str = str[19:str.find("\n</HAPP")]
limstart = str.rfind('EVENT id="')+10
limend = str[limstart:].find('"')+limstart
return str, int(str[limstart:limend])
zurl = 'http://www.nationstates.net/cgibin/api.cgi?q=happenings;view=world;filter=zombie;beforeid='
lim = 10000000
#header
zxml = []
zxml.append('<WORLD><HAPPENINGS>')
while 1:
print lim, len(zxml)
c,lim = getevent(urllib2.urlopen(zurl+str(lim)).read())
if c.find('EVENT') != 1:
zxml.append(c)
else:
break
time.sleep(0.65)
zxml.append('\n</HAPPENINGS></WORLD>\n')
#add tail
t = ''.join(zxml)
#save file
with open('nsxml', 'w') as output:
output.write(t)
i'm just posting this here as reference if anyone wants to do the same with similar things

this takes a graphml file and moves the distant points closer to the center.
it's quite impressive what can be done in 12 lines
import networkx as nx, random
N = nx.read_graphml('zdaybmig.graphml')
xoff, yoff = 1000.0, 500.0
rparam, maxdist2 = 3.0,16000.0**2
K = N.nodes()
for x in xrange(0,len(K)):
n = N.node[K[x]]
while float(n['x']+xoff)**2+float(n['y']+yoff)**2 > maxdist2:
j = random.random()*(rparam1)+1
n['x'] /= j
n['y'] /= j
nx.write_graphml(N,'zdaymig.graphml')

When running it, I get this error:
Traceback (most recent call last):
File "C:\Users\Mikkel\Desktop\guitest.py", line 6, in <module>
import matplotlib
ImportError: No module named matplotlib

right. you'll need matplotlib (http://matplotlib.org/downloads.html)

I installed it to the default subfolder
Lib\sitepackages
but it still gives the exact same error. :l

have you tried the binary installers?

I ran the
matplotlib1.3.1.winamd64py2.7.exe
I also tried downloading the .rar and running setup.py inside it, still not working. I don't really have patience to read and follow long texts on several different ways to install it and remove it where most of them probably won't work.
If the binary file is the .dmg file, no, Idk how to use that.

i don't know how familiar you are with setup.py, but you ran it with a command like
python setup.py install
?
also i too have problems installing with modules and sometimes it works when i install it in /Lib instead of /Lib/sitepackages. maybe you can copy/paste the thingies and try again
if you have pip or easy_install installed, you might try something like
easy_install matplotlib
(on command line)

i've got an interesting problem i thought we could have an impromptu coding contest on. java, python, or whatever language. (too bad there's no general coding topic.)
anyways it was inspired by darvince:
<Darvince>tell him the amount of correct numbers he got
<Darvince>don't tell him in what order though
basically, a number will be generated, and the algorithm must guess the number. the test() function will return True if the correct answer is guessed and an integer containing the number of digits correct will be returned if it was the wrong number.
some numbers will be of specified lengths and some others will have unspecified lengths (<1000).
fastest algorithm wins
if anyone's interested, post so that i know i'm not the only person working on this

i would but
1. idk how to time it and
2. i'd get second because me and kip would be the only dudes doing it

EDIT: wait darvince was refering to telephone numbers

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '113376'.

tell me in 2 days how you're doing

LEVLEN:
the function levplot takes a list of segment lengths, attaches them end to end in one long snake, and rotates each pivot randomly. the distance of the tip of the segment from the origin is plotted as a histogram.
usage example in interpreter
import os
os.chdir("c:\\kolkon\\pathname")
execfile('levlen.py')
levplot([1,2,3])
levplot([range(5)])
levplot([x**2 for x in list(reversed(range(10)))])
levplot([1,1],1000000,500) #1 million samples (normal is 100000) and 500 bins (normal is 200)
the following are example results. filename shows the list passed to levplot.

method of setting up a multiplayer game without needing to port forward by using freenode which can transmit around 1 kB/second

that doesn't seem very traditional lol
interesting

Kol, that should work fine for Map War 3 I guess.

i still have the dilemma of preventing one player from pretending to be another and screwing up the game that way. perhaps i will have each player generate a low value hashcoin and encrypt it with a short private key to ensure identities are correct

further elaboration of freenode setup shown previously. it's not cryptographically secure, but most people without a degree in cryptography would have a hard time cracking it

code for alternative voting system to be used in blavision (or other applications). example from wikipedia included.
def dez(ditc): #delete zeroes
dlist = []
for key in ditc:
if not(ditc[key]):
dlist.append(key)
for k in dlist:
del ditc[k]
def calc(choicelist, votelist):
cdict = {}
for c in choicelist:
cdict[c] = 0
for v in votelist:
cdict[v[0]] += 1 #replace this line with something more robust
dez(cdict) #delete zeroes
while 1:
vcount = sum((len(v) for v in votelist))
larg = max(cdict, key = cdict.get)
if cdict[larg]*2 > vcount: #terminate if over 50% vote
return larg
rem = min(cdict, key = cdict.get) #find min
del cdict[rem] #remove min
for v in votelist:
i = v.index(rem) #Get index
if i == 0: #remove previous vote
del v[0] #then delete the name
if len(v) == 0:
del v
break
elif v[0] in cdict:
cdict[v[0]] += 1 #deleted
if i != 1:
del v[i]
if len(v) == 0:
del v
#test samples
choicelist = ['bob', 'sue', 'bill']
v1 = ['bob', 'bill', 'sue']
v2 = ['sue', 'bob', 'bill']
v3 = ['bill', 'sue', 'bob']
v4 = ['bob', 'bill', 'sue']
v5 = ['sue', 'bob', 'bill']
votelist = [v1,v2,v3,v4,v5]
print calc(choicelist, votelist)

the ackerman function is a beautiful 4 lines in lisp
(define (ack m n)
(cond ((= m 0) (+ n 1))
((= n 0) (ack ( m 1) 1))
(else (ack ( m 1) (ack m ( n 1))))))
(define x (ack 3 9))
(print x)

What does the Ackermann function do?

make big numbers
"Its value grows rapidly, even for small inputs. For example A(4,2) is an integer of 19,729 decimal digits.[2]"

No what does it actually do, does it like grow 4,2 into 4^2 * 4^1 * 4^0 * 3^2 * 3^1 * 3^0 * 2^2 * 2^1 * 2^0 * 1^2 * 1^1 * 1^0?

A(4, 2) = A(3, A(4, 1))
= A(3, A(3, A(4, 0)))
= A(3, A(3, A(3, 1)))
= A(3, A(3, A(2, A(3, 0))))
= A(3, A(3, A(2, A(2, 1))))
= A(3, A(3, A(2, A(1, A(2, 0)))))
= A(3, A(3, A(2, A(1, A(1, 1)))))
= A(3, A(3, A(2, A(1, A(0, A(1, 0))))))
= A(3, A(3, A(2, A(1, A(0, A(0, 1))))))
= A(3, A(3, A(2, A(1, A(0, 2)))))
= A(3, A(3, A(2, A(1, 3))))
= A(3, A(3, A(2, A(0, A(1, 2)))))
= A(3, A(3, A(2, A(0, A(0, A(1, 1))))))
= A(3, A(3, A(2, A(0, A(0, A(0, A(1, 0)))))))
= A(3, A(3, A(2, A(0, A(0, A(0, A(0, 1)))))))
= A(3, A(3, A(2, A(0, A(0, A(0, 2))))))
= A(3, A(3, A(2, A(0, A(0, 3)))))
= A(3, A(3, A(2, A(0, 4))))
= A(3, A(3, A(2, 5)))
= A(3, A(3, A(1, A(2, 4))))
= A(3, A(3, A(1, A(1, A(2, 3)))))
= A(3, A(3, A(1, A(1, A(1, A(2, 2))))))
= A(3, A(3, A(1, A(1, A(1, A(1, A(2, 1)))))))
= A(3, A(3, A(1, A(1, A(1, A(1, A(1, A(2, 0))))))))
= A(3, A(3, A(1, A(1, A(1, A(1, A(1, A(1, 1))))))))
= A(3, A(3, A(1, A(1, A(1, A(1, A(1, A(0, A(1, 0)))))))))
= A(3, A(3, A(1, A(1, A(1, A(1, A(1, A(0, A(0, 1)))))))))
= A(3, A(3, A(1, A(1, A(1, A(1, A(1, A(0, 2))))))))
= A(3, A(3, A(1, A(1, A(1, A(1, A(1, 3)))))))
= A(3, A(3, A(1, A(1, A(1, A(1, A(0, A(1, 2))))))))
= A(3, A(3, A(1, A(1, A(1, A(1, A(0, A(0, A(1, 1)))))))))
= A(3, A(3, A(1, A(1, A(1, A(1, A(0, A(0, A(0, A(1, 0))))))))))
= A(3, A(3, A(1, A(1, A(1, A(1, A(0, A(0, A(0, A(0, 1))))))))))
= A(3, A(3, A(1, A(1, A(1, A(1, A(0, A(0, A(0, 2)))))))))
= A(3, A(3, A(1, A(1, A(1, A(1, A(0, A(0, 3))))))))
= A(3, A(3, A(1, A(1, A(1, A(1, A(0, 4)))))))
= A(3, A(3, A(1, A(1, A(1, A(1, 5))))))
= A(3, A(3, A(1, A(1, A(1, A(0, A(1, 4)))))))
= A(3, A(3, A(1, A(1, A(1, A(0, A(0, A(1, 3))))))))
= A(3, A(3, A(1, A(1, A(1, A(0, A(0, A(0, A(1, 2)))))))))
= A(3, A(3, A(1, A(1, A(1, A(0, A(0, A(0, A(0, A(1, 1))))))))))
= A(3, A(3, A(1, A(1, A(1, A(0, A(0, A(0, A(0, A(0, A(1, 0)))))))))))
= A(3, A(3, A(1, A(1, A(1, A(0, A(0, A(0, A(0, A(0, A(0, 1)))))))))))
= A(3, A(3, A(1, A(1, A(1, A(0, A(0, A(0, A(0, A(0, 2))))))))))
= A(3, A(3, A(1, A(1, A(1, A(0, A(0, A(0, A(0, 3)))))))))
= A(3, A(3, A(1, A(1, A(1, A(0, A(0, A(0, 4))))))))
= A(3, A(3, A(1, A(1, A(1, A(0, A(0, 5)))))))
= A(3, A(3, A(1, A(1, A(1, A(0, 6))))))
= A(3, A(3, A(1, A(1, A(1, 7)))))
= A(3, A(3, A(1, A(1, A(0, A(1, 6))))))
= A(3, A(3, A(1, A(1, A(0, A(0, A(1, 5)))))))
= A(3, A(3, A(1, A(1, A(0, A(0, A(0, A(1, 4))))))))
= A(3, A(3, A(1, A(1, A(0, A(0, A(0, A(0, A(1, 3)))))))))
= A(3, A(3, A(1, A(1, A(0, A(0, A(0, A(0, A(0, A(1, 2))))))))))
= A(3, A(3, A(1, A(1, A(0, A(0, A(0, A(0, A(0, A(0, A(1, 1)))))))))))
= A(3, A(3, A(1, A(1, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(1, 0))))))))))))
= A(3, A(3, A(1, A(1, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, 1))))))))))))
= A(3, A(3, A(1, A(1, A(0, A(0, A(0, A(0, A(0, A(0, A(0, 2)))))))))))
= A(3, A(3, A(1, A(1, A(0, A(0, A(0, A(0, A(0, A(0, 3))))))))))
= A(3, A(3, A(1, A(1, A(0, A(0, A(0, A(0, A(0, 4)))))))))
= A(3, A(3, A(1, A(1, A(0, A(0, A(0, A(0, 5))))))))
= A(3, A(3, A(1, A(1, A(0, A(0, A(0, 6)))))))
= A(3, A(3, A(1, A(1, A(0, A(0, 7))))))
= A(3, A(3, A(1, A(1, A(0, 8)))))
= A(3, A(3, A(1, A(1, 9))))
= A(3, A(3, A(1, A(0, A(1, 8)))))
= A(3, A(3, A(1, A(0, A(0, A(1, 7))))))
= A(3, A(3, A(1, A(0, A(0, A(0, A(1, 6)))))))
= A(3, A(3, A(1, A(0, A(0, A(0, A(0, A(1, 5))))))))
= A(3, A(3, A(1, A(0, A(0, A(0, A(0, A(0, A(1, 4)))))))))
= A(3, A(3, A(1, A(0, A(0, A(0, A(0, A(0, A(0, A(1, 3))))))))))
= A(3, A(3, A(1, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(1, 2)))))))))))
= A(3, A(3, A(1, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(1, 1))))))))))))
= A(3, A(3, A(1, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(1, 0)))))))))))))
= A(3, A(3, A(1, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, 1)))))))))))))
= A(3, A(3, A(1, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, 2))))))))))))
= A(3, A(3, A(1, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, 3)))))))))))
= A(3, A(3, A(1, A(0, A(0, A(0, A(0, A(0, A(0, A(0, 4))))))))))
= A(3, A(3, A(1, A(0, A(0, A(0, A(0, A(0, A(0, 5)))))))))
= A(3, A(3, A(1, A(0, A(0, A(0, A(0, A(0, 6))))))))
= A(3, A(3, A(1, A(0, A(0, A(0, A(0, 7)))))))
= A(3, A(3, A(1, A(0, A(0, A(0, 8))))))
= A(3, A(3, A(1, A(0, A(0, 9)))))
= A(3, A(3, A(1, A(0, 10))))
= A(3, A(3, A(1, 11)))
= A(3, A(3, A(0, A(1, 10))))
= A(3, A(3, A(0, A(0, A(1, 9)))))
= A(3, A(3, A(0, A(0, A(0, A(1, 8))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(1, 7)))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(0, A(1, 6))))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(0, A(0, A(1, 5)))))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(1, 4))))))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(1, 3)))))))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(1, 2))))))))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(1, 1)))))))))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(1, 0))))))))))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, 1))))))))))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, 2)))))))))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, 3))))))))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, 4)))))))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(0, A(0, A(0, A(0, 5))))))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(0, A(0, A(0, 6)))))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(0, A(0, 7))))))))
= A(3, A(3, A(0, A(0, A(0, A(0, A(0, 8)))))))
= A(3, A(3, A(0, A(0, A(0, A(0, 9))))))
= A(3, A(3, A(0, A(0, A(0, 10)))))
= A(3, A(3, A(0, A(0, 11))))
= A(3, A(3, A(0, 12)))
= A(3, A(3, 13))
= A(3, A(2, A(3, 12)))
= A(3, A(2, A(2, A(3, 11))))
= A(3, A(2, A(2, A(2, A(3, 10)))))
= A(3, A(2, A(2, A(2, A(2, A(3, 9))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(3, 8)))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(3, 7))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(3, 6)))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(3, 5))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(3, 4)))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(3, 3))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(3, 2)))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(3, 1))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(3, 0)))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, 1)))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(2, 0))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, 1))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(0, A(1, 0)))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(0, A(0, 1)))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(0, 2))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, 3)))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(0, A(1, 2))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(0, A(0, A(1, 1)))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(0, A(0, A(0, A(1, 0))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(0, A(0, A(0, A(0, 1))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(0, A(0, A(0, 2)))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(0, A(0, 3))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(0, 4)))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, 5))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(2, 4)))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(2, 3))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(2, 2)))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(1, A(2, 1))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(1, A(1, A(2, 0)))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(1, A(1, A(1, 1)))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(1, A(1, A(0, A(1, 0))))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(1, A(1, A(0, A(0, 1))))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(1, A(1, A(0, 2)))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(1, A(1, 3))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(1, A(0, A(1, 2)))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(1, A(0, A(0, A(1, 1))))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(1, A(0, A(0, A(0, A(1, 0)))))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(1, A(0, A(0, A(0, A(0, 1)))))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(1, A(0, A(0, A(0, 2))))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(1, A(0, A(0, 3)))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(1, A(0, 4))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(1, 5)))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(0, A(1, 4))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(0, A(0, A(1, 3)))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(0, A(0, A(0, A(1, 2))))))))))))))))))))
= A(3, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(2, A(1, A(1, A(1, A(0, A(0, A(0, A(0, A(1, 1)))))))))))))))))))))
.............
etc

what the fuck

yes.
in fact, the ackerman function is used as a computational benchmark

osmotischen the stratosphere affects weather (since pygcm seems to be turning into pygwm)

care to elaborate?

2d simplex noise
fairly selfexplanatory and simple. you'll need the libraries
noise: http://www.lfd.uci.edu/~gohlke/pythonlibs/#noise (http://www.lfd.uci.edu/~gohlke/pythonlibs/#noise)
numpy and matplotlib
import noise
import numpy as np
import matplotlib.pyplot as plt
def narray(xs, ys, s, p = 0.5, oct = 3):
r = [[noise.snoise2(x/s, y/s, octaves = oct, persistence = p) for y in xrange(0,ys)] for x in xrange(0,xs)]
return np.array(r)
g = narray(1000,1000,500.0, oct = 5)
plt.imshow(g)
plt.show()
result:

LOS maps based on the above heightmap
(line of sight).

requires 32 bit python and the library pyglet
right now it just shows a bunch of triangles. within a few days it should render a 3d figure. within a week, i might get something like fly mode working with a height map. then i'll try some shaders out

how do line of sights work
i'm trying to imagine silhouettes but im not getting anything

well right now i only need to determine line of sight between two objects given a heightmap in the form of an array. i draw a supercover line between the objects, and check each grid square it intersects to make sure it does not block the line of sight.
what you see above is the result of using this algorithm with a the center point and every pixel on the map. impractical for official use

i gave my first stackoverflow answer! check it out, or dont.
http://stackoverflow.com/a/20624839/1858363 (http://stackoverflow.com/a/20624839/1858363)

fastpy (http://www.youtube.com/watch?v=NMAy_uVWbk#)

a framework for musics.
the first 45 lines of this file is a framework with which to work with. the second part is a function that creates a song using the framework. a sample of the music produced is uploaded

<rodafk>darv have you ever figured out your sexuality
<Darvince>rodafk uhh mostly
<rodafk>what about you kal
<rodafk>i know vh is codesexual
<rodafk>you're always coding like a madman
<rodafk>new code appears everyday
<rodafk>born like rabbits

import os
import glob
from lxml import etree
import cPickle
import gzip
import time
import thread
import winsound
start = time.time()
def preprocessor(file):
invalid = [['','']]
with gzip.open(file,'r') as original:
with gzip.open('~'+file,'w') as temp:
m = original.readline()
while m != '':
for i in invalid:
m = m.replace(i[0],i[1])
temp.write(m)
m = original.readline()
os.remove(file)
os.rename('~'+file,file)
class NATION:
def __init__(self, name, type, fullname, motto, category, un, civil, economy, political, region, population, tax, animal, currency, flag, industry,
priority, environment, equality, education, law, administration, welfare, spirituality, defence, transportation, healthcare, commerce,
founded, firstlogin, lastlogin, activity, influence, public, leader, capital, religion):
self.name = name
self.type = type
self.fullname = fullname
self.motto = motto
self.category = category
self.unstatus = un
self.freedomscores = {'civilrights':civil, 'economy':economy, 'politicalfreedom':political}
self.region = region
self.population = population
self.tax = tax
self.animal = animal
self.currency = currency
self.flaglink = flag
self.majorindustry = industry
self.govtpriority = priority
self.govt = {'environment':environment, 'socialequality':equality, 'education':education, 'lawandorder':law, 'administration':administration,
'welfare':welfare, 'spirituality':spirituality, 'defence':defence, 'publictransport':transportation, 'healthcare':healthcare,
'commerce':commerce}
self.founded = founded
self.firstlogin = firstlogin
self.lastlogin = lastlogin
self.influence = influence
self.publicsector = public
self.leader = leader
self.capital = capital
self.religion = religion
self.lastactivity = activity
def create(file):
print 'processing '+ file
nationlist = []
_dump = gzip.open(file, 'r')
try:
parseddump = (etree.parse(_dump)).getroot()
except:
print 'error'
_dump.close()
preprocessor(file)
create(file)
return 0
_dump.close()
for nation in parseddump:
nationlist.append(NATION(
nation[0].text, nation[1].text, nation[2].text, nation[3].text, nation[4].text, bool(nation[5].text[0] == 'W'),
int(nation[21][0].text.strip('%')), int(nation[21][1].text.strip('%')), int(nation[21][2].text.strip('%')),
nation[7].text, int(nation[8].text), int(nation[9].text), nation[10].text, nation[11].text, nation[12].text, nation[13].text, nation[14].text,
int(nation[15][0].text.strip('%')), int(nation[15][1].text.strip('%')), int(nation[15][2].text.strip('%')), int(nation[15][3].text.strip('%')),
int(nation[15][4].text.strip('%')), int(nation[15][5].text.strip('%')), int(nation[15][6].text.strip('%')), int(nation[15][7].text.strip('%')),
int(nation[15][8].text.strip('%')), int(nation[15][9].text.strip('%')), int(nation[15][10].text.strip('%')),
nation[16].text, int(nation[17].text), int(nation[18].text), nation[19].text, nation[20].text,
int(nation[22].text.strip('%')), nation[23].text,nation[24].text, nation[25].text))
with gzip.open(file[:file.find('.')]+'output','wb') as outputfile:
cPickle.dump(nationlist, outputfile)
parseddump = None
with open("error.txt", 'w') as f:
f.write('this is the error log\n')
for file in glob.glob("*.gz"):
try:
create(file)
except:
winsound.Beep(2000,2000)
print 'error', file
with open("error.txt",'a') as ef:
ef.write(file+'\n')
print time.time()start
this is an update of dump_processor.py
some files don't extract if they're on an external hd for some reason, so i added an error log to catch those problems.
link to original below
.

kdf (https://en.wikipedia.org/wiki/Key_derivation_function) based on sha512
time complexity is O(n^{2})
memory complexity is O(n)
there are 3 functions in the code. hash is just sha512 as implemented by a library
algohash is the actual algorithm
algocollision is a generator object that yields keys with partial hash collisions  similar to cryptocurrency mining
code:
import hashlib
import random
def hash(k,hasher):
hasher.update(str(k))
return int(hasher.hexdigest(),16)
def algohash(length,start):
hasher = hashlib.sha512()
plist = [start]
for x in xrange(0,length):
plist.append(hash(sum(plist),hasher))
return hex(plist[1])
def algocollision(length,bits):
while 1:
key = random.random()
r = algohash(length,key)
b = bin(int(r[2:1],16))[2:].zfill(8)
if b[1:bits+1] == '0'*bits:
yield key
basically, there's a list. you put the input into the list.
then for n times, sum the list, hash the sum, append the result to the list
on a single thread, algohash takes about 3 seconds with a length parameter of 10000 and 12 seconds with a length parameter of 20000. with a length parameter of 100000, the expected time is 5 minutes
with a length parameter of 100000 the memory usage should be around 6.1 MB, making it extremely difficult to parallelize onto a gpu or asic. the average gpu runs from 5000 to 40000 concurrent threads. this would be 30 and 238 GB of ram respectively using the algohash algorithm

sloppy code but it works
import itertools
import pyglet
import random
from pyglet.gl import *
import noise
import numpy as np
import colorsys as cs
import math
win = pyglet.window.Window(resizable=True)
kb = pyglet.window.key.KeyStateHandler()
win.push_handlers(kb)
win.set_exclusive_mouse(True)
def randcol():
return [int(random.random()*256) for x in range(3)]
def narray(x, y, s=200, p = 0.5, oct = 3):
return noise.snoise2(x/s, y/s, octaves = oct, persistence = p)
def trimesh(vcmax, kmax, scale, offsetx, offsety, func, theight):
num = vcmax*kmax
const = (3**0.5)/2
eo = [[[k*const*scale+offsetx,
offsety+scale*(k/2.0+vc),
theight*func(k*const*scale+offsetx, offsety+scale*(k/2.0+vc))
] for vc in xrange(0,vcmax)] for k in xrange(0,kmax)] #k, vc, 3list
eo = list(itertools.chain(*eo))
counter = 0
order = []
flag = True
while 1:
order.append(eo[counter])
if counter == num1:
break
if flag:
counter += vcmax
flag = False
else:
counter = (vcmax1)
flag = True
sorder = [tuple(order[x:x+2*vcmax]) for x in xrange(0,len(order),2*vcmax)]
for s in xrange(0,kmax1):
sorder[s] = list(itertools.chain(*sorder[s]))
vlb = pyglet.graphics.Batch()
color = []
for s in xrange(0,len(sorder)):
color.append([])
for v in xrange(2,len(sorder[s]),3): #start on 3 vertice, the altitude
val = (sorder[s][v]/theight+1)/2.0 #map in range 0,1
for colr in cs.hsv_to_rgb(0.5,1,val): #get rgb
color[s].append(int(colr*256))
for s in xrange(0,len(sorder)):
sorder[s] = tuple(sorder[s][0:3] + sorder[s] + sorder[s][3:])
color[s] = tuple(color[s][0:3] + color[s] + color[s][3:])
vlb.add(2*vcmax+2, pyglet.gl.GL_TRIANGLE_STRIP, None, ('v3f', sorder[s]), ('c3B', color[s]))
return vlb
world = trimesh(90,90,10, 0,400, narray, 50)
def display():
glClear(GL_COLOR_BUFFER_BITGL_DEPTH_BUFFER_BIT)
glShadeModel(GL_SMOOTH)
glLoadIdentity()
def reshape():
glShadeModel( GL_FLAT )
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(120., win.width / float(win.height), .1, 1000.)
glMatrixMode(GL_MODELVIEW)
glTranslatef(0.,0.,100.)
glRotatef(0,1,0,0)
a, b, = win.width/2, win.height/2 #this stores mouse position
k = 0.01 #sensitivity
gx = 0 #this stores the angle
gy = 0 #this also stores the angle
dx = 0 #default xpos #positive is rightward
dy = 0 #default ypos #positive is forward
dz = 0 #default zpost #positive is up
@win.event
def on_mouse_motion(x, y, dx,dy): #No effect?
k = 7
global a, b
a += dx*k
b += dy*k
return pyglet.event.EVENT_HANDLED
fps_display = pyglet.clock.ClockDisplay()
@win.event
def on_draw():
global a, b, k, gx, gy, dx, dy, dz
display()
reshape()
win.clear()
#
glMatrixMode(GL_MODELVIEW)
gx += k*(awin.width/2) #if mouse on right side of screen, gx will be positive. If left, gx is negative
gy += k*(bwin.height/2) #if mouse on top of sceen, gy will ne positive. If bottom, gy is negative
a, b, = win.width/2, win.height/2 #reset positions so scene does not move
#
glRotatef(gy,1,0,0)
glRotatef(gx,0,0,1)
glTranslatef(dx, dy, dz)
#
world.draw()
def move(dt):
global gx, gy, dx, dy, dz
held = kb[pyglet.window.key.W]
kt = 3
if held:
heading = (gx+90) % 360
pitch = (270gy) % 360
dz += math.sin(pitch*math.pi/180)*kt
comp = math.cos(pitch*math.pi/180)*kt
dx += comp*math.cos(heading*math.pi/180)
dy += comp*math.sin(heading*math.pi/180)
pyglet.clock.schedule_interval(move,1.0/120.0)
pyglet.app.run()
demo
smoothpy (http://www.youtube.com/watch?v=HfKfzhrLHn4#ws)

My first actual legitimate program release!
imgget v1.0
I've created a simple file downloader that you eternally run to download files for you! It is meant for files that update frequently (more frequently than once a day) so that it will catch them when you're not around.
Operation:
1. Configure the config.txt file so that it links to a url you want to download and after the comma, include the filename that you want it to download as before the timestamp. So if you put "foobar" then it will download as "foobar20140101_1830", so you may want to put "foobar_".
2. You will unfortunately manually have to download your first file (save it with the correct filename in which you want all the other files), and enter the timestamp into the list in lastdownload.txt. Not too difficult though.
3. Run, and it should do all the work for you. It shows simple status messages to let you know everything is (or is not) working okay.

I am amaze at my PHP skills.
I got a webpage to read an advisory from an entirely different website, and find a storm name and number, which i can now modify to look more presentable.
<?php
copy('http://weather.noaa.gov/pub/data/raw/wt/wtio30.fmee..txt','wtio30.txt');
$handle = fopen("wtio30.txt", "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
echo $line;
echo '<br />';
}
} else {
echo 'Error reading file.';
}
echo '<br /><hr /><br />';
$handle = fopen("wtio30.txt", "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
if (preg_match('/1.A/', $line, $matches)){
echo $line;
echo '<br />';
echo substr($line, 4).'<br />';
preg_match('/ [09] /', $line, $sn);
echo 'Storm Number: '.$sn[0].'<br />';
preg_match('/\([AZ]+\)/', $line, $name);
$temp = substr($name[0], 1, strlen($name[0])2);
echo 'Storm Name: '.substr($temp, 0, 1).strtolower(substr($temp, 1));
}
}
} else {
echo 'Error reading file.';
}
?>
I'm going to use this to create a database which just records all updates to relevant cyclone files... basically pywx online. And no python.

woah that color coding...

apparently SMF has it built in to color PHP

atomic tell me where do you even put php

PHP works on a web server to create a webpage that isn't necessarily the same every time you call it. A normal HTML webpage will always be the same unless someone changes the way it's written so that it looks different, but 5 years down the road, someone can request the page and it will be the same as it was 5 years ago. PHP can do stuff like look up information in databases or other dynamic things that may have the page end up different based on user input or something that changed.
I don't know if you wanted an explanation on PHP as well, but there you have it.

ok so it's a thing to put on a webpage k thx

ok so it's a thing to put on a webpage k thx
You have learned a lot

erosion simulator. requires matplotlib and numpy
you can use it without matplotlib or numpy if take them out in the code and delete the display and update functions. then you'd need someone to plot it for you
before
(http://i.imgur.com/secnegG.png)
after
(http://i.imgur.com/ArWChOn.png)
usage guide to erosim
first we make the landscape with random walk
import random
walker = 0
path = []
for x in xrange(0,400):
walker += random.random()random.random()
path.append(walker)
now we have to match the end of the path up to the beginning. if we don't there is a large discontinuity and the erosion will exponentially grow bigger, causing an overflow error.
slope = (path[1]path[0])/400
we subtract the slope so that it becomes flat
for x in xrange(0,400):
t[x] = slope*x
and now set the minimum to zero.
t = [valmin(t) for val in t]
all of the above can be written into a function of course, so you don't have to type it in every time.
navigate to the correct directory with os and execute the file
import os
os.chdir('c:\\users\\kolkon\\desktop\\erosim')
execfile('erosim.py')
then we create a world. we must give the elevation map, flow rate, erosion rate, evaporation rate, rock hardness, and rain amount in that order.
here is a sample that works relatively well. notice we use list(t).
g = World(list(t), 0.2, 10.0, 0.01, 5.0, 1.0)
lets take a look
g.display()
now we run the simulation, eroding and making it rain periodically. make sure there isn't already too much water when you add more or everything will flood
for x in xrange(0,10000):
if not(x%100) and max(g.water) < 1:
g.rain()
g.erode()
lets see how it went
g.update()
and there we are.

Map War 3  now with erosion!

barbaria erosion >:D

instead of subtracting the water from and right and water from the left, a typo caused only water to be subtracted from the right which caused a strange flow error. that and other things fixed here.

draft of a new project. puts organisms in a environment and evolves their code
import numpy as np
import math
class Cell:
def __init__(self, position, world):
#self.center = position
#self.blocks = [position]
#world.cells.append(self)
#self.energy = world.initenergy
#self.inst = Code()
def step(self):
#try:
#self.Code.run()()
#except:
#pass
def grow(self):
#while 1
#pick random cell
#check if it has any edges
#pick random edge and fill
def move(self):
#call position on world class
def make(self):
#mutate code, place in front
def eat(self):
#of the objects touching, dissapear one
#add energy
def atk(self):
#of the objects touching, dissapear one cell
#make sure to call that cell and split
#convert to food
def see(self):
#touching search
#also farthest search
def turn(self):
#rotate direction so that movement is different
class Code:
oplist = [Cell.grow, Cell.move, Cell.make, Cell.eat, Cell.atk, Cell.see]
loops = ['for', 'if', 'while']
conditional = [Cell.size, Cell.energy, Cell.sight, Cell.danger]
other = ['break', 'pass']
def __init__(self):
self.topnode = {None:[]}
def codeiterate(self, function):
#queue root node
#while queue
#pick node in queue
#visit node and apply function to it
#add all children to queue
#delete node from queue
def shuffle(self):
#use codeiterate and call random.shuffle on a list
def prune(self):
#probablility of deleting random code with codeiterate
def mutate(self):
#swap out and switch 'for', 'if', and 'while' while codeiterating
def clone(self):
#duplicate lines while codeiterating
def mix(self, other):
#not sure yet
#def dfs(self, graph, string):
#string = graph.keys()[0]
#if not(graph[string]):
#return nullstring
#for k in graph[string]:
#indented add dfs(graph, string)
#return string
def run(self):
#inst = exec(dfs(self.topnode))
#return inst
class World:
def __init__(self, size, initenergy, decayrate, toroidal = True, solar):
#self.grid = np.zeros(size)
#self.cells = []
#self.initenergy = initenergy
#self.decayrate = decayrate
#self.toroidal = toroidal
#self.solar = solar
def move(self, obj):
#check collision
#move if possible
def step(self):
#for each cell
#run decay, solar, etc
#run code

Progress on my map plotter!
Unfortunately it took 10 minutes just to generate this pretty crude image:
note to self: latitude lines

no code?

27 line alternative solution. readme in the code. generates full world resolution map in about 10 minutes if you have enough ram (that'll be 180,000 pixels by 90,000 pixels)
sample image here at scaling = 300 of europe
https://www.dropbox.com/s/8q471ypp753sv17/wmap.png (https://www.dropbox.com/s/8q471ypp753sv17/wmap.png)

(http://paladinofstorms.net/ptpc/2013/w/wp35_graphic.png)
It looks pretty horrible but I'm not sure how to improve it...

Is that super doge Haiyan

suppose you had some unknown code, statement, or function that you wanted to run. the source of this might come from a variety of places. randomly generated code, user input code, mathematical expressions from an irc bot  and on and on.
now also suppose you wanted to run a lot of these codes or functions. perhaps 10 or a hundred or a thousand at a time. this is useful if you had an irc calculator that needed to keep reading the chat while processing.
well, i've written a function to do so. the three arguments are time, the function, and the arguments:
import os
from multiprocessing import Process
import threading
import time
def timeoutprocess(_time, function, arg):
if __name__ == "__main__":
import time
p = Process(target=function, args = arg)
p.start()
now = time.time()
while 1:
if time.time()now > _time and p.is_alive():
try:
p.terminate()
except:
pass
if not(p.is_alive()):
break
def timeoutthread(time, function, arg):
t = threading.Thread(target=timeoutprocess, args = (time, function, arg))
t.start()
here's a short explanation of how this works.
we run the function on a separate process. process and not thread because
1. there is no way to terminate threads in python, but there is a way to terminate processes
2. takes advantages of more cores/parallelization
we can't simply spawn off a new process, we have to spawn the new process in a new thread. this is because there is a while loop inside the thread that keeps track of the time. when time is up, the process is killed. If we didn't use threads, we'd have to compute everything serially and not simulatenously.
and here's an example usage.
execfile('tof.py')
def wait(null):
while 1:
pass
def test():
if __name__=="__main__":
print 'hi', time.time()
timeoutthread(1,wait,(1,))
print 'bye', time.time()
for x in xrange(0,10):
test()
we have a function test. inside that function, we do some things, then spawn off a separate process to take care of a task. note that you need if __name__=="__main__":
this is because python's structured so that the process can only access the code and know what to run by importing the file. however, if it imports the file, it'll also execute the line of code that spawns itself, and processes will keep spawning more processes until the system freezes up.

here's an update to my key derivation function. there was a problem before where i was simply adding everything up, so a person could save a lot of memory just by keeping the last sum, which is bad. (because if they save a lot of memory, that means they can run it concurrently on thousands of threads, which defeats the entire point).
however the algorithm is still compute bound. at ten thousand rounds, the algorithm takes about half a minute to run on a single thread and 10MB of memory. I'm shooting for a time of about a second and 1gb of memory
what i plan to do is to reduce the computation time by not hashing all of the previous values, but only some, depending on the value of the last hash
yes i'm aware algohash is the most lame, undescriptive, and incorrect name for a key derivation function ever

i've been working on this.
https://github.com/osmotischen/evolve5

short piece of code that counts how much code you've written.
import os
sum1,sum2=0,0
for f in [val for val in os.listdir(os.curdir) if '.py' in val]:
with open(f, 'r') as file:
d = file.readlines()
sum1 += len(d)
sum2 += len([val for val in d if ('#' not in val and val)])
print sum1, sum2
the two numbers are total amount and total amount excluding whitespaces and comments

this plots a histogram from a one dimensional dataset. except it's smoooooth
more like a density function

after a few hours of experimentation and a new folder dedicated to plotting i've completed my minimalist density curve plotter in python.
i'll be adding an option for standard deviation and mean. right now zero looks pretty ugly

wow that looks cute

MatLab (http://en.wikipedia.org/wiki/MATLAB) has many of those functions, actually a very cool program and programming language. It has an std() function for finding standard deviation.
I once made a time dilation visualizer in it and a program for finding a minimum in functions of 1 and 2 variables.
But I'm pretty sure it isn't free, I got a license from university.

ha. the module i (and most other people) use for plotting, matplotlib, is basically just matlab's plotting functions imported to python
you should upload that time dilation ponyer

I ALWAYS THOUGHT DILATION WAS SPELLED DIALATION LIKE "TURN THE DIAL TO THE TIME MACHINE QUICK!"

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '117061'.

Here it is:
Time Dilation Visualization (http://www.youtube.com/watch?v=FL1c_l7pEU8#ws)
The code:
% Timestep
dt = 0.025;
% Properties of clocks
x1 = 0; y1 = 1;
x2 = 0; y2 = 2; vx2 = 0.75; t2 = 0;
x3 = 0; y3 = 3; vx3 = 0.95; t3 = 0;
% Properties of light particles in clocks
x1l = 0; y1l = y10.25; vy1l = 1;
x2l = 0; y2l = y20.25; vx2l = vx2; vy2l = sqrt(1vx2.^2);
x3l = 0; y3l = y30.25; vx3l = vx3; vy3l = sqrt(1vx3.^2);
% Properties of light wave (black line)
xl = 0; vxl = 1;
% Gamma factor of clocks
g2 = 1/sqrt(1(vx2.^2));
g3 = 1/sqrt(1(vx3.^2));
% Figure properties
scrsz = get(0,'ScreenSize'); % Get screen resolution
figure('OuterPosition',[0 50 scrsz(3) scrsz(4)50]) % Figure window set to fill the screen except bottom 50 pixels
for t=0:dt:10
plot(x1, y1, 'sr', 'MarkerFaceColor', 'r', 'MarkerSize', 1); hold on; % This ensures that the plot works
% Feynmanclock rectangles
patch([x10.1 x10.1 x1+0.1 x1+0.1],[y10.25 y1+0.25 y1+0.25 y10.25],'r');
patch([x20.1 x20.1 x2+0.1 x2+0.1],[y20.25 y2+0.25 y2+0.25 y20.25],'g');
patch([x30.1 x30.1 x3+0.1 x3+0.1],[y30.25 y3+0.25 y3+0.25 y30.25],'b');
% Light particles in clocks
plot(x1l, y1l, 'sk', 'MarkerFaceColor', 'k', 'MarkerSize', 5);
plot(x2l, y2l, 'sk', 'MarkerFaceColor', 'k', 'MarkerSize', 5);
plot(x3l, y3l, 'sk', 'MarkerFaceColor', 'k', 'MarkerSize', 5);
% Lines at xaxis
line([x1 x1], [0 0.25], 'Color', 'r');
line([x2 x2], [0 0.25], 'Color', 'g');
line([x3 x3], [0 0.25], 'Color', 'b');
line([xl xl], [0 0.25], 'Color', 'k');
hold off;
% Axis properties
axis([0.5, 10.5, 0, 4]) % Format: [xmin, xmax, ymin, ymax].
xlabel('xdistance [ct]') % Xaxis label.
ylabel('ydistance [ct]') % Yaxis label.
set(gca,'ytick',[0 0.5 1 1.5 2 2.5 3 3.5 4])
set(gca,'xtick',[0.5 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7 7.5 8 8.5 9 9.5 10 10.5])
% Display text in plot
text(x1, 0.5, ['Black line (light), velocity = ', num2str(1),' c'])
text(x1, y1+0.5, ['Red Feynman clock, velocity = ', num2str(0),' c, gamma = ', num2str(1),' time = ', num2str(round(t*10)/10),' s'])
text(x1, y2+0.5, ['Green Feynman clock, velocity = ', num2str(vx2),' c, gamma = ', num2str(round(g2*10)/10),' time = ', num2str(round(t2*10)/10),' s'])
text(x1, y3+0.5, ['Blue Feynman clock, velocity = ', num2str(vx3),' c, gamma = ', num2str(round(g3*10)/10),' time = ', num2str(round(t3*10)/10),' s'])
% Display time next to objects
text(x1+0.25, y1, [num2str(round(t*10)/10),' s'])
text(x2+0.25, y2, [num2str(round(t2*10)/10),' s'])
text(x3+0.25, y3, [num2str(round(t3*10)/10),' s'])
drawnow();
% Update xcoordinates of moving frames and lightwave
x2 = x2 + vx2*dt;
x3 = x3 + vx3*dt;
xl = xl + vxl*dt;
% Update time for moving frames
t2 = t2 + dt/g2;
t3 = t3 + dt/g3;
% Update coordinates of light particles in clocks
y1l = y1l + vy1l*dt;
x2l = x2l + vx2l*dt;
y2l = y2l + vy2l*dt;
x3l = x3l + vx3l*dt;
y3l = y3l + vy3l*dt;
% Make light particles in clocks bounce (reverse velocities)
if (y1l >= y1+0.25)  (y1l <= y10.25)
vy1l = vy1l*(1);
end
if (y2l >= y2+0.25)  (y2l <= y20.25)
vy2l = vy2l*(1);
end
if (y3l >= y3+0.25)  (y3l <= y30.25)
vy3l = vy3l*(1);
end
% Pause at start
if t == 0
pause(2);
end
end

another framework for musics and sample

here's a text editor in python. it's pretty basic and i hacked it together in about half an hour but it does have some features
it'll print out how many characters of text you have every hundred seconds, which is useful for seeing how much you've done
the first ten characters (or less) of the first line becomes the title
backups are saved every hundred seconds with the title and the timestamp
the editor also records how much text you have every second and writes it to a log every hundred seconds.
of course put this in a folder before using  it spawns about 72 files per hour. which probably need to be frequently cleared. in anycase i just wanted to see how my writing speed is over the course of a research paper
requires tkinter which is probably installed already

and here are the results of the above experiment with time on the x axis and characters on the y axis. if you download the svg you can actually zoom it and see the individual seconds.
(https://dl.dropboxusercontent.com/u/42218552/writingdat.svg)

import numpy as np
def a_rk4(h, t, v, f): #t is a scalar, v is a vector, f is a function of a vector, h is a function of a scalar
s = h(np.linalg.norm(f(v)))
k1 = f(t, v)
k2 = f(t+s/2,v+s*k1/2)
k3 = f(t+s/2,v+s*k2/2)
k4 = f(t+s,v+s*k3)
return v + h*(k1+2*k2+2*k3+k4)/6
adaptive runge kutta integrator. i'll explain how it works
t is the variable you're integrating with respect to, in most cases, time.
v is the vector. it could just be x, or [x,y], or [x,y,z] for a 3d gravity simulator
f is a function of vector v, in the case of gravitational attraction to the origin it might be 1/(x**2+y**2)
of course if you have multiple points you'll have to loop over them and get the sum.
h is the adaptive time step. for example, you might set it to be 1/x, so time step is inversely proportional to force, so that accuracy is maintained
if you see i multiply and add the vectors using numpy arrays. it would be possible to do so without numpy but then i'll also have to add an argument for an adding and multiplying function and this is just simpler i think

https://dl.dropboxusercontent.com/u/42218552/field%20(1).png (https://dl.dropboxusercontent.com/u/42218552/field%20(1).png)
http://zoom.it/2wm6 (http://zoom.it/2wm6)

Amazing

that makes a lot more sense than the wierd swirlies you had

movie coder/decoder in python
i suspect there's an error i haven't found but i'm done with this project
the code is unreadable btw
i created a custom movie codec and it is really buggy. (http://www.youtube.com/watch?v=HqRZo34ZSpk#ws)

niceplot2 with some updates
you can pick font size now
unicode support
option to automatically plot ticks at mean and standard deviations
bounds of plot is not determined by numbers but my standard deviations
bounds of plot do not have to be symmetric anymore
ticks can have custom labels
sample included

movie coder/decoder in python
i suspect there's an error i haven't found but i'm done with this project
the code is unreadable btw
i created a custom movie codec and it is really buggy. (http://www.youtube.com/watch?v=HqRZo34ZSpk#ws)
It's perfect don't change anything

polygon collision detection that comes with examples. you can just run the script

import numpy as np
import math
n_body = lambda bodies, accel_function = lambda a, b: (a[4]+b[4])/math.sqrt((a[0]b[0])**2 + (a[1]b[1])**2), dintegrator = lambda a, b, t, f, d: lambda a, b, t, f, d, integrator = lambda a, b, t, f, d: np.concantenate(a[:2],a[2:4]+[np.cos(d), np.sin(d)]*t*f(a,b),a[4:]): np.concantenate(a[:2]+t*a[2:4], a[2:]), timestep = 1.0: map(lambda a: np.concantenate(a[:4]+sum((dintegrator(a, b, timestep, accel_function, d = math.atan2(a[1]b[1], a[0], b[0])) for b in bodies)), a[4:]), bodies)
#body is in the format [posx, posy, velx, vely, mass, ...]
#all vectors are numpy arrays
a one line nbody simulator (aka gravity sim).

uranium enrichment simulation. completed but there are bugs.
should i continue it?

right. update of uranco which actually works now. if you haven't figured it out yet, this is a simulator where you can put together a uranium enrichment cluster and test how well it works. when you run it, four numbers will be shown
4761.9047619 0.0077
5238.0952381 0.00636363636364
this means that there are 4761.9 units of ore enriched to 0.0077 and 5238.09 units of ore disposed with 0.00636 enrichment. obviously this isn't a good uranium enricher
does anyone want a gui for this

this simulates a crystal growing. i haven't made the graph animated yet, so you'll just have to close the window and another one will pop up. 10 steps are simulated between each stage.
unfortunately the way i structured the code makes it relatively inflexible. the only thing that'll happen is a strangely shaped circle

this code illustrates the depletion force which causes particles to be 'attracted' to each other and the edges of the container.
shown are histograms (binned and smoothed) of the location of particle positions. note the exponentially decaying wave
https://en.wikipedia.org/wiki/Depletion_force
i've also updated niceplot two with two more arguments, bw and cov, both of which seem to do the same thing, which is to determine how smooth the gaussian kde is

blalert.pyw is a blacraft alert. upon finding that there is a player on the server (after a period where no one is on), it will emit a 3 second long beep. for each additional player that joins, a one second beep will follow.
this should run without a window appearing. if it doesn't work or you want a window remove the w in the fiel name.

kol a such excellent

Kol, nice program.
I tried doubleclicking it, it said a beepsound when it started, but besides from that I didn't see or notice anything from the program. I tried logging on Blacraft after opening it, it didn't react. I haven't been on Blacraft since the weekend.

the problem was that the code thought empty string counted as one player, so even when the server was empty it thought there was someone on. don't know how i missed that bug. here's the fix.

cloud coding thingy which comes with a vm to let you run online collaboratively.
referral link (gives me and you an extra 1gb):
https://koding.com/R/osmotischen
you can register with github

scrapes historical eod stock market data which you usually can't get for free from yahoo. the symbols.txt file you need is here:
ftp://ftp.nasdaqtrader.com/symboldirectory/nasdaqlisted.txt

c++ application that computes the number of primes from one to n. run it, then enter the number n, then enter the number of times you want to run it. it is quite optimized. i can't release the source code yet but i will. the first number printed for each trial is the count, the second is the number of miliseconds taken.

wrapper for the pycrypto, exchange keys and shit. will be used to send encrypted messages over irc. not tested yet.
https://pypi.python.org/pypi/pycrypto
installation of pycrypto (32 bit python. if you don't use 32 bit python install seperately in a folder such as python27_x86)
download file and extract to c:\python27\lib\sitepackages
cd c:\python27\lib\sitepackages\pycryptowhatever
python setup.py install

from collections import namedtuple
screen = namedtuple('screen', ('item','to'))
class Interface:
def __init__(self, mtext, mid):
self.main = mid
self.v = {mid:screen(mtext, [])}
def addscreen(self, id, item):
self.v[id] = screen(item,[])
def connec(self, s1, s2):
self.v[s1].to.append(s2)
def disp(self, id):
itm = self.v[id].item
if type(item) == str:
print self.v[id].item
else:
self.v[id].item()
l = len(self.v[id].to)
for i in xrange(0,l):
print self.v[id].to[i] +':' + str(i)
while 1:
try:
k = int(raw_input())
break
except:
pass
if 0 <= k < l:
self.disp(self.v[id].to[k])
def startloop(self):
self.disp(main)
so what is this? an interface of sorts.
normally, if you have a few user inputs for a program, you'd just write them into the function. but supposed your program revolved around text inputs, as in an interactive story or menu selection thing. certainly, all the if statements, loops, and raw_inputs would be confusing.
this class consists of a bunch of screen objects which you can add and connect. Each screen is represented by an id, an item, and a list of connections. the id is a string used to identify the screen, the item is either a function or a piece of text, and the list of connections contains the ids of other screens that can be accessed.
if the item is a piece of text, it will be printed, then the user will choose which screen to go to next.
if the item is a function, it will be executed. however, in order to keep the code concise, i have not allowed any arguments to be passed to the function.
so what if i have a writefile function you say, and you want to pass the filename of log.dat to the function? well, before you add the screen, do this:
logwritefile = lambda: writefile('log.dat', raw_input('hi'))
and then pass the logwritefile function to the screen creator.
i have to say this is not tested at all but i will be using it soon so if there are bugs they will be fixed

if you have a bunch of python programs you run simultaneously, like an irc bot, a web scraper, imgget, a key logger, or whatever, this script runs them all on threads which means they will only ever take up one cpu core.
many pieces of code where you have
while time.time()start < 1:
or something similar, this while loop can eat up a lot of cpu power by running very quickly. by threading all the scripts onto one core, the loop is slowed down, which means less cpu use with the same performance
import threading
names = ['agent.py', 'crypto.py', 'interface.py', 'top.py', 'connect.py'] #fill this with a list of whatever shit
tlist = []
for name in names:
tlist.append(threading.Thread(target = lambda : execfile(name)))
for thread in tlist:
thread.start()

a few months later i've started coding the majority of it. here's another view of how it works again

i present to you the 150 line "HelloWorld" program in opencl. well actually it's a bit more complicated. the program takes the string "GdkknVnqkc", then adds 1 to all the ascii values, and prints the result.
here's the heavily commented main code
#include "stdafx.h" //standard something
#include <stdlib.h> //standard library
#include <string.h> //for string
#include <stdio.h> //standard input and output
#include <iostream> //input output stream
#include <string> //also for string
#include <fstream> //file stream
#include <CL/cl.h> //for opencl
using namespace std; //we don't have to type std every time
int convertToString(const char *filename, string& s){
//filename is the name of the file
//s the address of the string
size_t size; //an unsigned long long int that contains size of object
char * str; //initialize pointer str
fstream f(filename, (fstream::in  fstream::binary));
//make f a file object with the filename and mode is input and binary
if(f.is_open()){ // if file opened
size_t fileSize; //unsigned long long int that contains size of file object
f.seekg(0, fstream::end); //go to the end of the file, then offset by zero
size = (size_t)f.tellg(); //get the current position, convert it to type size_t, store in size
fileSize = size; //set filesize equal to size
f.seekg(0, fstream::beg); //go back to beginning of file and offset by zero
str = new char[size+1]; //initialize array of characters just big enough to store the file
if(!str){ //if the array is empty
f.close(); //close the file
return 0; //signifies success
}else{ //if the array is not empty
f.read(str, fileSize); //read the file until the end, store it in the char array
f.close(); //close the file
str[size] = '\0'; //set the last character to 0, termiating the string
s = str; //put the character array into s
delete[] str; //delete str, saves memory
return 0;//success
}
}else{ //the file did not open
return 1; //1 signifies failure
}
}
int main(){ //the main program or whatever
cl_uint numPlatforms; //number of platforms stored as a unsigned cl integer
cl_platform_id platform = NULL; //set the platform to none or something
cl_int status = clGetPlatformIDs(0,NULL,&numPlatforms);//get the platform id of null, assign it to numplatforms
if(status != CL_SUCCESS){ //if the platform failed
return 1; //failure
} //if it did not fail
if(numPlatforms > 0){ //if more than one platform available
cl_platform_id* platforms = (cl_platform_id* )malloc(numPlatforms* sizeof(cl_platform_id));
//allocate an array to store all the platform IDs
status = clGetPlatformIDs(numPlatforms, platforms, NULL); //put all the platforms ids into the array
platform = platforms[0]; //set the platform to the first platform found
free(platforms); //unallocate the array from before
}
cl_uint numDevices = 0; //zero devices
cl_device_id *devices; //stores device ids
status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0 , NULL, &numDevices);
//get devices of type gpu, available on platform, of type gpu, and store the number in numDevices
if(numDevices == 0){//there are no gpus
status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_CPU, 0, NULL, &numDevices);
//get the devices of type cpu, available on platform, and store number in numdevices
devices = (cl_device_id*)malloc(numDevices * sizeof(cl_device_id));
//allocate an array to store all the devices
status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_CPU, numDevices, devices, NULL);
//store the devices into the devices array
}else{//there are at least 1 gpu
devices = (cl_device_id*)malloc(numDevices * sizeof(cl_device_id));
//allocate an array to store all the devices
status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numDevices, devices, NULL);
//store all the devices into the devices array
}
cl_context context = clCreateContext(NULL,1, devices,NULL,NULL,NULL);
//create a context with one device, and pass the devices to it
cl_command_queue commandQueue = clCreateCommandQueue(context, devices[0], 0, NULL);
//create a command queue, give it the context, and the first devices
const char *filename = "HelloWorld_Kernel.cl"; //the name of the file where the kernel is stored
string sourceStr; //initialize the string that will store the code
status = convertToString(filename, sourceStr); //get the code, place it in sourceSTR
const char *source = sourceStr.c_str(); //get a pointer to the string containing the kernel
size_t sourceSize[] = {strlen(source)}; //array of length 1 containing the size of the kernel
cl_program program = clCreateProgramWithSource(context, 1, &source, sourceSize, NULL);
//now we create the program with given context, the kernel string, and the size of the kernel
status=clBuildProgram(program, 1,devices,NULL,NULL,NULL); //build the program for the device
const char* input = "GdkknVnqkc"; //initialize an object that is the same size of helloworld
size_t strlength = strlen(input); //store the size of this object
char *output = (char*) malloc(strlength + 1); //allocate an output one char bigger than input
cl_mem inputBuffer = clCreateBuffer(context, //allocate memory (a buffer)
CL_MEM_READ_ONLYCL_MEM_COPY_HOST_PTR, //it is read only  copies the input
(strlength + 1) * sizeof(char), //the size enough to contain hello world
(void *) input, //and give it a pointer to the input
NULL);
cl_mem outputBuffer = clCreateBuffer(context, //allocate memory ( a buffer)
CL_MEM_WRITE_ONLY , //it is write only
(strlength + 1) * sizeof(char), //size enough to contain hello world
NULL, NULL);
cl_kernel kernel = clCreateKernel(program,"helloworld", NULL); //create the kernel object with hello world string
status = clSetKernelArg(kernel, 0, sizeof(cl_mem), (void *)&inputBuffer); //set the kernel's in buffer
status = clSetKernelArg(kernel, 1, sizeof(cl_mem), (void *)&outputBuffer); //set the kerels' out buffer
size_t global_work_size[1] = {strlength}; //use as many workers as there are characters
status = clEnqueueNDRangeKernel(commandQueue, kernel, 1, NULL, global_work_size, NULL, 0, NULL, NULL);
//send the instructions to the workers using the specified command queue, kernel, and worksize
status = clEnqueueReadBuffer(commandQueue, outputBuffer, CL_TRUE, 0, strlength * sizeof(char), output, 0, NULL, NULL);
//read back in the data with command queue, the output buffer, put the memory into the output string
output[strlength] = '\0'; //add terminating character to the output
printf(output); //print the string
printf("\n");
status = clReleaseKernel(kernel); //release kernel
status = clReleaseProgram(program); //release the program object
status = clReleaseMemObject(inputBuffer); //release input buffer
status = clReleaseMemObject(outputBuffer); //release output buffer
status = clReleaseCommandQueue(commandQueue); //release command queue
status = clReleaseContext(context); //release the context
if (output != NULL){ //if the output contains a string
free(output); //remove it
output = NULL; //dereference the pointer
}
if (devices != NULL){ //if devices exist
free(devices); //free the devices
devices = NULL; //dereference the pointer
}
system("pause"); //makes sure the window doesn't close out immediately
return 0; //signifies success
}
and here's the kernel, which is used on 10 of your gpu/cpu/whatever cores
__kernel void helloworld(__global char* in, __global char* out) //make a kernel function
{
int num = get_global_id(0); //read in the id
out[num] = in[num] + 1; //get the character, add one
}

please read this article on brainfuck, i promise it's painless: https://en.wikipedia.org/wiki/Brainfuck
so this is a brainfuck interpreter i coded. just double click on it, and you can start typing brainfuck in. it stores all the code you've typed in until you enter a blank line, then executes. if there are any problems, they'll be printed. if you want to clear the cells, type NIL to restart everything.
here's some sample code you can try:
+++++[>+++++++++++++<]>.
this first sets the first cell to five. then, it decreases the first cell and increase the second cell by 13 in a loop which executes five times. 5*13 = 65. we shift back to the second cell and print 65, which is ascii character 'A'
this is hello world:
++++++++[>++++[>++>+++>+++>+<<<<]>+>+>>>+[<]<]>>.>.+++++++..+++.>>.<.<.+++...>>+.>++.

this is an idiotproof mob farm calculator which simulates five minutes of spawning and despawning in a few seconds. just click to run.
curiously, the simulation suggests that large mob farms near the ground should not kill the mobs as quickly as possible, a slightly longer time gives up to a 50% increase in kill rate
bla's farm should get 3 mobs per second with one player on, and 3.7 seconds with 3 players on
the destroyed farm in desertopia would have gotten .6 per second with one player on, and .8 with 3 players on
a 2000piston mob farm in the sky would get 2.8 mobs per second with one player on, but only .33 with 3 players on.

brainfuck program to print the fibonacci sequence wrote with explanation
+>+[[>+<]<[>>+<<]>>.]
+>+ initialize the first two cells a1, a2
[ add a_n1 and a_n2 in a loop
[>+<] subtract a_n1 and add to a_n, stopping when a_n1 is zero
< shift from a_n1 to a_n2
[>>+<<] subtract a_n2 and add to a_n, stopping when a_n2 is zero
>> shifts over to a_n which becomes a_n1 in the next loop
. output which doesn't actually print the number
] since a_n is never zero, loop does not terminate
by the way, this code doesn't work but i'm too lazy to fix it

pycollective. just extract the folder to whereever.
open the file with notepad and edit the player variable with your own blacraft nickname (for bla it would be "Comrade Blanoxium" or something).
drag a shortcut into the startup folder to make it run on startup.
in blacraft, whenever you remove something from your collective storage chests, type something like
! cobblestone 1000
or
! lapis +1000
at the end of the month, open the file, and all the changes will be added up. you'll need to reset the log manually
if you don't mind the black terminal, you can rename .pyw to .py so you'll know if it stops working for some reason.

Holykol that sounds super kolvenient, thanks for developing that! Definitely going to try that.
Where's the startup folder? For startup in Minecraft or Wind dose?

for windows
i'm just following this page:
http://windows.microsoft.com/enus/windows/runprogramautomaticallywindowsstarts#1TC=windows7
haven't done it myself so i don't know where it is :P
edit:
also keep in mind this only works if dynmap is turned on.

Here's a tutorial for how to do it in Windows 8:
http://www.techrecipes.com/rx/28206/windows8howtoaddapplicationsstartupfolder/

i forgot to mention, you have to clear the logs before you use it because i forgot to do that after i finished testing.

i coded a taylor polynomial grapher. to use it, just type in something formatted like the following
function, degree, center, x1, x2
for example:
lambda x: airy(x)[1], 100, 0, 7,7
which plots the imaginary part of the airy function along with a 100th degree taylor approximation centered at 0 from 7 to 7 as shown below
right now the derivative is numerically approximated so any degree over 20 is pretty much useless. i might try symbolic derivatives later
if you try logs and other function with domain holes it acts strangely and might print errors
edit: added the code. scipy, numpy, and matplotlib needed.

fixed code above so a center other than zero works.
also adjusted the derivative calculator so it can handle functions like log(x+1) better and cbrt(x)

protip: scipy's scipy.stat.norm.pdf is a very slow approximation for the bell curve, i sped up my code like 10 times by using this:
def nfunc(mu, sigma):
def normpdf(x):
u = (xmu)/abs(sigma)
y = (1/(sqrt(2*pi)*abs(sigma)))*exp(u*u/2)
return y
return normpdf

d42758482096b3e
pyimg takes a screenshot, uploads it to imgur, and puts the link in your clipboard whenever you press f9. entire process takes about 1 to 2 seconds on average.
you need a client id to use the application, and each id can upload 1250 images per day. i've posted one above, or you can register for one here: https://api.imgur.com/oauth2/addclient
you'll need a shitload of libraries for this to run though:
pyimgur
win32gui
win32ui
win32con
win32api
pythoncom
(all under the name pywin32)
PIL
pyHook
downloads:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyhook
http://effbot.org/downloads#pil
and this one is not a binary
https://pypi.python.org/pypi/pyimgur/0.5.2

no one asked but this is a multithreaded version so there is no input lag

new version of pyimg.
with this version, the link is instantly (<1ms) copied onto your clipboard. however, the link points nowhere for the first few seconds. this probably will not be an issue as no one clicks on irc links that fast (i hope).

is it just me or does ink scape use .py files so it uses python???

haskell is really cool.
random number gen i coded
lehmer :: [Int] > Int > Int > Int > Int > [Int] list of random integers
lehmer [] seed maxp mult len = lehmer [seed] seed maxp mult (len  1)
lehmer k seed maxp mult len = if len > 0
then lehmer ((lehmerl (head k) maxp mult) : k) seed maxp mult (len  1)
else k
lehmerl :: Int > Int > Int > Int  generate next element on list
lehmerl prev maxp mult = mod (mult * prev) maxp
randmax :: Int > Int > [Int]
randmax max len = [mod i max  i < (lehmer [] 65537 2147483647 16807 len)]
from 0 to 100 w/ 1000 samples

simulation of a column of leaves collapsing into saplings. until the very end, the pattern is surprisingly linear.
i also wrote a few functions to simulate the collapse when collapse is proportional to the drop stacked on each block and also inversely proportional.

.

spoiler maker, which turns easily formatted paragraphs into html spoilers
usage example:
execfile('htmlrender.py')
awrite('demo.txt', 'demo.html')
demo.txt and demo.html are attached
note that all titles must be globally unique. i might fix this in the future but it will require major restructuring of the code

haskell primality tester
i've attached the code and a compiled exe, which tests the number
9444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444448484498999
and closes upon finding it is a prime

this script runs structural tests on a minecraft world and collapses structures that don't stand up to gravity and wind.
the first part opens the file and puts it into an array. this works.
the second part runs the structural tests. this doesn't work.

but wait i'm not done
i started coding map war 3 again today, except i started brand new with a new structure. i just have to code in the turn processing and the game rules/settings, then slap on some shiny graphics and we're done!
import networkx as nx
import cPickle
import deepcopy
class Zone:
def __init__(self, id, own = None):
self.id = id
self.econ = 0
self.indus = 0
self.fort = 0
self.own = own
self.dist = None #needs to compute
def upg(typ, amount): #bad form?
if typ == 'econ':
self.econ += amount
elif typ == 'indus':
self.indus += amount
elif typ == 'fort':
self.fort += amount
class Nation:
def __init__(self, id, capital, techs):
self.capital = capital
self.id = id
self.mon = 0
self.econ = 0
self.indus = 0
self.mil = 0
self.zones = [self.capital]
self.techs = techs
self.trades = []
def addzone(self, zone):
self.zone.append(zone)
def compstats(self):
self.econ = sum((zon.econ for zon in self.zones))
self.indus = sum((zon.indus for zon in self.zones))
self.mon += self.econ
def convmil(self, amount):
self.mon = amount
self.mil += amount
def research(self, tree, amount):
self.techs[tree].rsearch(amount)
def addtrade(self, onat):
self.trades.append(onat)
class Tech:
def __init__(self, dflags, cval = 0):
self.cval = cval
self.dflags = dflags
def rsearch(self, amount):
self.cval += amount
def checkflag(self, typ):
return self.dflags[typ](self.cval)
class World:
def __init__(self, zones, edges, tech):
self.zones = zones
self.edges = edges
self.techs = techs
self.nations = []
self.mgraph()
def mgraph(self):
self.graph = nx.Graph()
for node in self.zones:
self.graph.add_node(node)
for edge in self.edges:
self.graph.add_edge(*edge)
class Turn:
def __init__(self, acts): #zacts, wacts, tacts, racts, nacts, oacts
self.acts = acts
def addacts(self, typ, act):
self.acts[typ].append(act)
def removeacts(self, typ, act):
del self.acts[typ][self.acts[typ].index(act)]
def rotlist(lst):
return [lst.pop()]+lst
class Game:
def __init__(self, world, gamerules, tord):
self.history = [world]
self.world = world
self.gr = gamerules
self.tord = reversed(tord)
self.estate = False
def confirm(self):
self.history.append(copy.deepcopy(self.world))
def lastconfirmed(self):
self.world = copy.deepcopy(self.history[1])
#
def pzacts(self, zacts):
pass
def pwacts(self, wacts):
pass
def practs(self, racts):
pass
def pnacts(self, nacts):
pass
def poacts(self, oacts):
pass
def pturn(self, turnobj):
self.lastconfirmed()
self.turn = self.tord[0]
zacts, wacts, racts, nacts, oacts = turnobj.acts
self.pzacts(zacts) #zone acts
self.pwacts(wacts) #war acts
self.practs(racts) #tech acts
self.pnacts(nacts) #nation acts
self.poacts(oacts) #other acts
if not(self.estate):
self.tord = rotlist(self.tord)
self.confirm()
class Gamerules: #is a class overkill
def __init__(self):
self.settings = {
}
self.rules = {
}
pass
def tofile(instance, file):
with open(file, 'w') as f:
cPickle.dump(instance, f)

inb4 bla

keylogger that doesn't log keys, only the time at which keys are pressed. even which key was pressed is not stored
import pythoncom, pyHook
import time
times = []
last = time.time()
def tofile(lst):
with open('ktime.log', 'a') as file:
file.write('\n'.join([str(val) for val in times])+'\n')
def OnKeyboardEvent(event):
global times, last
times.append(time.time())
if len(times) >= 1000 or time.time()last > 1000:
last = time.time()
tofile(times)
times = []
while True:
hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()
it's sloppy, but it works.

d
[0, 'test1.py', True]
[1, 'test2.py', True]
s all
[0, 'test1.py', False]
[1, 'test2.py', False]
r 0
[0, 'test1.py', True]
[1, 'test2.py', False]
r 1
[0, 'test1.py', True]
[1, 'test2.py', True]
k 0
[0, 'test2.py', True]
k 0
d
a test1.py
[0, 'test1.py', True]
a test2.py
[0, 'test1.py', True]
[1, 'test2.py', True]
ponypony
error
i wrote a thing to manage the multiple scripts i like to keep running
think of it like task manager... but better!
here's the manual
d
displays running processes
a <file>
adds a new process
s <index>
suspends a process by index. use display to find the index
r <index>
resumes a process
k <index>
kills a process
u <index>
updates the status of a process. unless something went bad this shouldn't be needed
also, instead of using an index, one might use the keyword 'all', which applies the action to all processes.
to run scripts on startup, place them in the scripts list in smanage.py
here's the code along with several test scripts.

puzzle. not mindnumbing, but not easy either.
(http://tinyurl.com/274543766554)

for bonus points do it functionally.
600 iron prize on blacraft if you finish it within 18 hours of this post

snip
i updated smanage.py so that one might put shortcuts to the scripts instead of the actual script. you can now add 'shortcut.lnk' to the list of scripts


did it
compose :: [a > a] > (a > a)
compose fs = foldl (flip (.)) id fs
data Block = Block [[Bool]] Int deriving (Show)
replacen :: Int > a > [a] > [a]
replacen n val (x:xs)
 n == 0 = val:xs
 otherwise = x:(replacen (n1) val xs)
replace2n :: Int > Int > a > [[a]] > [[a]]
replace2n n1 n2 val arr = replacen n1 (replacen n2 val (arr !! n1)) arr
setval :: Block > Int > Int > Bool > Block
setval (Block arr size) n1 n2 val = Block (replace2n n1 n2 val arr) size
getringdict :: Int > Block > [(Int,(Int, Int))]
getringdict n (Block arr s) = zip [0..] (c1 ++ c2 ++ c3 ++ c4)
where
c1 = zip [n..sn2] (repeat n)
c2 = zip (repeat (sn1)) [n..sn2]
c3 = zip [sn1,sn2..n+1] (repeat (sn1))
c4 = zip (repeat n) [sn1,sn2..n+1]
rraccum :: [(Int,(Int, Int))] > Int > (Block, Block) > (Int,(Int, Int)) > (Block, Block)
rraccum rposs amount (oblock, nblock) entry = (oblock, setval nblock n1 n2 obool)
where
np = mod ((fst entry) + amount) (length rposs)
(n1, n2) = fromJust $ lookup np rposs
(o1, o2) = snd entry
(Block arr s) = oblock
obool = (arr !! o1) !! o2
rotring :: Int > Int > Block > Block
rotring amount ring oblock = snd $ foldl (rraccum rposs dr) (oblock,oblock) rposs
where
(Block arr size) = oblock
rposs = getringdict ring oblock
dr
 mod amount 2 == 0 = amount
 mod amount 2 == 1 = (amount)
rotate :: Block > Int > Block something with this is wrong
rotate oblock amount = compose (map (rotring amount) [0..div size 2]) $ oblock
where (Block bitarr size) = oblock
haskell is nice.

46 lines of church arithmetic in common lisp.
lisp is very messy for my taste
(defun church (n)
(labels
((repeat (f x n)
(if (<= n 0)
x
(repeat f (funcall f x) ( n 1)))))
(lambda (f) (lambda (x) (repeat f x n)))))
(defun unchurch (n)
(funcall (funcall n (lambda (x) (+ 1 x))) 0))
(defparameter zero (church 0))
(defparameter one (church 1))
(defparameter two (church 2))
(defparameter three (church 3))
(defun csuc (n)
(lambda (f) (lambda (x)
(funcall f (funcall (funcall n f) x)))))
(defun cadd (n m)
(lambda (f) (lambda (x)
(funcall (funcall m f) (funcall (funcall n f) x)))))
(defun cmul (n m)
(lambda (f) (lambda (x)
(funcall (funcall m (funcall n f)) x))))
(defun cexp (n m)
(lambda (f) (lambda (x)
(funcall (funcall (funcall m n) f) x))))
(defun cpre (n)
(labels (
(extract (k)
(funcall k (lambda (u) u)))
(inc (f)
(lambda (g) (lambda (h)
(funcall h (funcall g f)))))
(const (x)
(lambda (u) x)))
(lambda (f) (lambda (x)
(extract (funcall (funcall n (inc f)) (const x)))))))
(defun csub (m n)
(funcall (funcall n #'cpre) m))

remember that keylogger i posted which only records the times you press the key? well when you're playing minecraft and hold down w, a bunch of keys get recorded. but i messed around with the module and found this hidden feature  if you replace KeyDown with KeyUp, the hook module gets key releases. so yeah.

but wait now it tracks mouse presses also

fixed version of tlog

so once upon a time i wanted to make a minecraft banner in the shape of a sickle. of course, i automated this process
goal.png is the goal state
done.png is the current state
all the other images are the patterns.
there are two functions in permutator.py
one of the tries to brute force patterns and find a matching banner
the other one also brute forces but adaptively changes the weights so certain patterns are used more.
in practice, they both run about the same.

11.25kB and its a rar 0.0

brownian tree fractal
(https://i.imgur.com/p5PsQbn.png)
and lyapunov fractals
(https://i.imgur.com/vmEtVgV.png)

Here's the code for the Jister bot on IRC, if anyone cares.
import socket
import random
import time
server = "irc.freenode.net" # Server
channel = "##universesandbox" # Channel
botnick = "Jister" # Your bots nick
with open("kol.txt", "rt") as in_file:
koltimes = in_file.readline()
koltimes = int(koltimes)
with open("mfw.txt", "rt") as in_file:
mfwtimes = in_file.readline()
mfwtimes = int(mfwtimes)
shitlist = [" :kol\n", " :jkok\n", " :peacock\n", " :trollface.png\n", " :jackie_chan.png\n", " :misc_jackie_chan.png\n", " :home phone\n", " :mpw\n", " :mfw\n", " :what the christ\n", " :what the pony\n", " :allahu ackbar\n", " :ackbar\n", " :con\n", " :kolok\n", " :hpw\n", " :hfw\n", " :u wot m8\n", " :hue\n", " :peasant\n", " :what_the_christ.png\n", " :dar_on_his_sides.png\n", " :music.avi\n", " :sugg\n", " :inb4\n", " :peacock\n", " :plot twist\n", " :gorchul\n", " :my homeschooling when\n", " :pants.bigger\n", " :what the inafter christ\n", " :kolmunism\n", " :kolkommunism\n", " :sell your cars\n", " :donate your cars\n", " :kol\n", " :kolkon\n", " :inb4\n", " :hue\n", " :what the jkok\n", " :blotz is literally of jkok\n", " :bangkok\n"]
def ping(): # Respond to server pings
ircsock.send("PONG :pingis\n")
def joinchan(chan): # Join a channel
ircsock.send("JOIN "+ chan +"\n")
def randShitSpeak(): # Randomly selects a shitspeak phrase
ircsock.send("PRIVMSG " + channel + random.choice(shitlist))
ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ircsock.connect((server, 6667)) # Here we connect to the server using the port 6667
ircsock.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :Jister  A bot made by Jorster on USF\n") # user authentication
ircsock.send("NICK "+ botnick +"\n") # here we actually assign the nick to the bot
joinchan(channel) # Join the channel using the functions we previously defined
while 1: # Be careful with these! it might send you to an infinite loop
ircmsg = ircsock.recv(2048) # receive data from the server
ircmsg = ircmsg.strip('\n\r') # removing any unnecessary linebreaks.
ircmsg = ircmsg.lower() # Converting to lowercase for easier finding of kol
ircmsg = ircmsg.replace('osmotikol', 'dsfjak')
ircmsg = ircmsg.replace('!kol', 'dsfjal')
ircmsg = ircmsg.replace('!mfw', 'whatthejkok.avi')
print(ircmsg) # Here we print what's coming from the server
if ircmsg.find("ping :") != 1: # If the server pings us then we've got to respond!
ping()
if ircmsg.find("##universesandbox") != 1: # Make sure we're getting a message from the irc channel
if ircmsg.find("kol") != 1: # If someone says kol
koltimes += 1 # Add one to the koltimes variable
if koltimes == 3000:
ircsock.send("PRIVMSG " + channel + " :Congratulations!\n")
ircsock.send("PRIVMSG " + channel + " :UniverseSandbox has reached 3000 kols!\n")
with open("kol.txt", "wt") as out_file: # Open the kol.txt file
out_file.write(str(koltimes)) # Populate the file with the kol number
if ircmsg.find("mfw") != 1:
mfwtimes += 1
with open("mfw.txt", "wt") as out_file:
out_file.write(str(mfwtimes))
if ircmsg.find("whatthejkok.avi") != 1:
ircsock.send("PRIVMSG " + channel + " :mfw has been said " + str(mfwtimes) + " times!\n")
if ircmsg.find("soul") != 1: # If someone says soul
randShitSpeak() # Respond with shitspeak
if ircmsg.find("!jister") != 1: # If someone says !Jister
ircsock.send("PRIVMSG "+ channel + " :Jister v1.8  A bot by Jorster. Counts the number of Kol's and Mfw's said in IRC, retrieve them via !kol and !mfw, respectively.\n") # Gives bot info
if ircmsg.find("dsfjal") != 1: # If someone says !kol
ircsock.send("PRIVMSG "+ channel + " :kol has been said " + str(koltimes) + " times!\n") # Respond with the number of times kol has been said
if ircmsg.find("thomas") != 1: # if someone says thomas
ircsock.send("PRIVMSG "+ channel + " :thamis*\n") #correct them to thamis
if ircmsg.find("BlaBla44") != 1:
if (random.randint(1,100)) == 1:
ircsock.send("PRIVMSG "+ channel + randShitSpeak())

if ircmsg.find("BlaBla44") != 1:
if (random.randint(1,100)) == 1:
ircsock.send("PRIVMSG "+ channel + randShitSpeak())
omg im' dying

Shhh soopir sekrit feature

Post python code, python stuff, maybe even a python.
esidgbsdgclesgdkzugy. Python.

a pure montecarlo algorithm that solves the puzzle from this app
https://itunes.apple.com/us/app/magicalwater/id409979686?mt=8
although this link to a very similar game explains the puzzle better
http://android.m.brothersoft.com/dropspuzzle157758.html
given a few seconds of thinking time, it performs better than the average human

you'll have to open the file and make minor adjustments to use this.
basically, it count the number of files/subdirs on your desktop (or any directory) once per minute, and writes it to file.

req tkinter and matplotlib

this plots the brightness of a 24hour digital LED clock assuming it displays leading zeroes

a flashcard tool which takes into account the weighing of each card and a forgetting curve.
run fcardtest

this attempts to put n points in a plane so that they are 1 unit away from every other point. obviously this is impossible, but that doesn't stop me

This is my first bit of code done in c#. What do yous think? Its very basic I know but for my first time I think its alright.
Is the structure alright?
/*
*Author: Stephen Doran
* Date: 16/10/2014
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Q4
{
class Program
{
static void Main(string[] args)
{
// declare variables
int apples;
int oranges;
int total;
// assign value to variables
Console.Write("How many apples do you have? ");
apples = Convert.ToInt32 (Console.ReadLine());
Console.Write("How many oranges do you have? ");
oranges = Convert.ToInt32 (Console.ReadLine());
// process
total = apples + oranges;
// output value
Console.WriteLine("You have {0} apples and {1} oranges", apples, oranges );
Console.WriteLine("You have a total of {0} pieces of fruit", total);
}
}
}

vewy nice.
now its my turn
import net.minecraft.block.Block;
import net.minecraftforge.common.ForgeHooks;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
//import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
@Mod(modid="BagaliumMod", name="Bagalium", version="0.1.0")
public class BagaliumMain {
@Instance(value = "BagliumMod")
public static BagaliumMain instance;
public final static Block bagaliumOre = new BagaliumOre(Material.rock);
@SidedProxy(clientSide="bagalium.eclipse.cp.ClientProxy", serverSide="forge.eclipse.bagalium.CommonProxy")
public static CommonProxy proxy;
public static Item bagaliumIngot;
public void preInit(FMLPreInitializationEvent event) {
bagaliumIngot = new BagaliumIngot()
.setMaxStackSize(64)
.setUnlocalizedName("bagaliumIngot");
}
public void load(FMLInitializationEvent event) {
proxy.registerRenderers();
ItemStack diamondStack = new ItemStack(Items.diamond);
ItemStack dirtStack = new ItemStack(Blocks.dirt);
GameRegistry.addShapelessRecipe(diamondStack, dirtStack);
MinecraftForge.setBlockHarvestLevel(bagaliumOre, "pickaxe", 3);
GameRegistry.registerBlock(bagaliumOre, "bagaliumOre");
}
public void postInit(FMLPostInitializationEvent event) {
}

As a heads up, I highly recommend commenting your code so if you ever go back you know what you were trying to accomplish

As a heads up, I highly recommend commenting your code so if you ever go back you know what you were trying to accomplish

As a heads up, I highly recommend commenting your code so if you ever go back you know what you were trying to accomplish

Alrighty Then!

vewy nice.
now its my turn
import net.minecraft.block.Block;
import net.minecraftforge.common.ForgeHooks;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
//import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;
@Mod(modid="BagaliumMod", name="Bagalium", version="0.1.0")
public class BagaliumMain {
@Instance(value = "BagliumMod")
public static BagaliumMain instance;
public final static Block bagaliumOre = new BagaliumOre(Material.rock);
@SidedProxy(clientSide="bagalium.eclipse.cp.ClientProxy", serverSide="forge.eclipse.bagalium.CommonProxy")
public static CommonProxy proxy;
public static Item bagaliumIngot;
public void preInit(FMLPreInitializationEvent event) {
bagaliumIngot = new BagaliumIngot()
.setMaxStackSize(64)
.setUnlocalizedName("bagaliumIngot");
}
public void load(FMLInitializationEvent event) {
proxy.registerRenderers();
ItemStack diamondStack = new ItemStack(Items.diamond);
ItemStack dirtStack = new ItemStack(Blocks.dirt);
GameRegistry.addShapelessRecipe(diamondStack, dirtStack);
MinecraftForge.setBlockHarvestLevel(bagaliumOre, "pickaxe", 3);
GameRegistry.registerBlock(bagaliumOre, "bagaliumOre");
}
public void postInit(FMLPostInitializationEvent event) {
}
Minecraft Forge Mod eh?

yep ;D

As a heads up, I highly recommend commenting your code so if you ever go back you know what you were trying to accomplish

i recommend never commenting your code so if you ever go back you can practice how to decipher uncommented code

smalltalk is the most confusing thing in the world
(https://i.imgur.com/bQ8fS5m.png)

Weather model chronicles:
i don't have time to write a whole chronicle so just have the output graphic results from tonight:
first try, i forgot the else statements, so anything with a value too low ends up compounding on the bottom as black
all of these graphics are of humidity percentage, darker green is more humidity
timestep for each run was 1 hour, each frame shown is 6 hours
model is a 256x128 equirectangular grid
(http://i.imgur.com/0RTF6lm.gif)
then i figured that out and ran the model 72 hours at what i thought was "atmospheres" of pressure and uh well it does this odd thing at about 45N and 45S that spreads out... i have no idea why
(http://i.imgur.com/U2g0lSa.gif)
then i tried hPa (cause I know pascals are just death)
(http://i.imgur.com/OKbGyAr.gif)
no that's obviously broken
so here's something in the middle
(http://i.imgur.com/RpKHU6f.gif)
you can see some things move and advect properly, but no time to see things speed up enough because the "corruption" takes everything over
something is obviously wrong, with the smaller pressures, not enough happens, with the higher pressures, it breaks the advection formula and stuff tries to move too fast (thereby moving too much and leaving cells empty)
fortunately, it appears that the cells that border each other actually do so according to the model, you can sometimes see things move between them and the corruption spreads out logically
unfortunately, i have no idea why the corruption occurs on every OTHER row, and only in that area originally?
in other news, we get to add to the collection of modern art :)
here's a plan: i'm going to run a daylong simulation at a minute timestep using pascals overnight, output every hour, and see how it comes out

Help me understand this mess

i don't think that will help. the very dark and very light areas in 'the corruption', suggest some sort of feedback event that creates large values. i suggest trying to figure out why that happens
switch on and off coriolis to see if that's causing anything

so this is from a multivariable calculus course...
use the enemy's strength against him
(https://i.imgur.com/RRcqgH4.png)

All other music is ingame music. It makes me want to understand this.

What I ran overnight...
(http://i.imgur.com/UKNqOH5.gif)
Now I'm trying it without coriolis as kip suggested to see if that has any affect on the corruption
(http://i.imgur.com/TkOnfuk.gif)
compare with (from yesterday)
(http://i.imgur.com/U2g0lSa.gif)
and a higher resolution:
(http://i.imgur.com/KcASLld.gif)
???

:O

time = calendar.timegm(datetime.datetime(*[int(val) for val in re.split(' :',line[line.index("[") + 1:line.index("]")])]).utctimetuple())
this a beautiful one liner than turns a line like this:
[20111005 17:27:05] <matty406> screenies\n
into a timestamp like this:
1317835625

parses a eu4 save game into a csv file which i've imported into a sql database
(wars, sorted by largest number of boats destroyed)
(https://i.imgur.com/Do413RO.png)
(battles in which both sides had more than 50000 participants. note the 17th century battle)
(https://i.imgur.com/7BKhdCK.png)

I wrote a program to calculate the current time on Universalis...
Fiah and dar came up with year 984, but I'm not sure how. I got 988.
Here's the code: http://pastebin.com/KUeGYDZ1
Output for the value on line 2
Universalis days: 245240.501362
Universalis years: 988.470426812
Base Universalis Time  988116, 15.70824
Calendaric Universalis Time  988107, 11.0399999997
Soleani Calendar  988225, 11.0399999997
Base Universalis Time is basically just the time i got by dividing 22.02 and 248.101, the exact hour and day values. This differs from the Calendaric Universalis Time (should it really differ by 9 days though?) because that is calculated as a calendar would calculate it out, in blocks of days per year, and not just a raw time value. The Soleani Calendar is a modified version of CUT which uses the method of dividing into months. At the moment, it does not have an offset, but it will be offset to whenever the nearest Universalis winter solstice is to January 1, 1399, 00:00 UTC, Earth time. For ease, I assumed it synced up exactly with midnight January 1.
I posted this so that, if I made a mistake, someone will be able to understand what went wrong.

what did you define as 0000101 00:00:00? how about 13991021 17:00:00 UTC+0 is 0000101 00:00:00?

0 hours is January 1, 1399, 00:00 UTC

drag the ball.
(requires tkinter)

the ball is a slow pony

well at least it works

I figured it out, who would have known .001 was one per thousand and not one per hundred...
that might account for the 9 day discrepancy.
I'll update the code when I get home to see if that's accurate and then maybe I can host a thing on my site showing Base Universalis Time for conversion and maybe people's calendars

fixx pygwm

i can confirm that i messed up the calendar thing, but it is fixed now
so if people want to work on their calendars, and decide on a time for winter solstice of universalis, that would be helpful and then i can start working on a calendar/time conversion which i can put on my site

so i'm coding an evolution simulator for trees and it's neat how every single possible bug gets exploited by the evolutioning.
for example, i made the cost of growing a branch proportional to its height off the ground  this lead to the forest become a carpet of branches at y = 0
i implemented a variable in the genes that determined how much energy the offspring would start off with, but used a constant value for that instead. the trees exploited this by using 1 energy to create offspring with 10 energy

for the first issue you could keep that feature but make the cost decrease from 0 to 5 then increase and never let it reach 0, also if a tree occupies the same space as another one the cost increases

eh. i just made cost be proportional to 1 + height
then i removed the height term because i was trying to get taller trees to grow

i don't need to to do the tree occupying the same space thing because i actually measure the amount of sunlight absorbed by each branch on a tree and if a branch is covered by another branch higher up it gets less energy (50% less for every additional overlap)

i'm having problems with speciation  all my trees have evolved to be tall, but theyre all exactly the same tallness

Maybe coding a giraffe could help?
(http://thefunniestpictures.com/wpcontent/uploads/2014/04/270254.jpg)

speciation only happens when a population is isolated from another or put under pressure by itself

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '146683'.

tfw doing data processing and there's an io bottleneck

A simple little program which can be used as a memory game for learning your own conlang (or any language really)
not full definitions, but simple vocab glossing
(http://i.imgur.com/ShmWqVD.png)
if people want to help add to files or use it, just ask
the way it works is the english will always show up and you have to type it in the conlang, so if you need to specify things, then you can do that
I still have to test to see if special characters work and such.
And actually, I'd like to try to put it on my website so that it's always there to use when you want. Although the personal version would allow you to dump vocab things you want to work on, on demand.

a brute force solver for https://en.wikipedia.org/wiki/24_Game

i find this data structure useful because if your code crashes unexpectedly in the middle of processing a large amount of data, you don't have to redo everything
import cPickle
class IOlist(list):
def __init__(self, filename, sentinel):
list.__init__(self)
self.count = 0
self.sentinel = sentinel
self.filename = filename
def add(self, elem):
self.append(elem)
self.count += 1
if self.count >= self.sentinel:
self.save()
def save(self):
self.count = 0
with open(self.filename, 'wb') as ouf:
cPickle.dump(list(self), ouf)
def load(self):
with open(self.filename, 'rb') as inf:
self[:] = cPickle.load(inf)
it saves itself to a file every so often

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '148891'.

it's time to up the byebla game
there's a 0.1% chance it'll break when starting up
oops quickly squashing a bugs

python space program https://djungelorm.github.io/krpc/docs/tutorials/launchintoorbit.html

ok its call blabotc cuz its so crude
my complex design is in the process of breaking

kol

you can't stop me!
(https://i.imgur.com/abgIseT.png)

tfw math homework is too much work. this only took me about twice the time it would take to do the homework by hand

an automated nonhomogenous linear ODE solver which uses the method of undetermined coefficients. the best part is that it outputs a latex file showing each step. includes batch processing
attached is the script, an example latex output, and the latex rendered as a pdf
from sympy import *
from copy import deepcopy
def all_terms(polyn, rcoeff = False):
polyn = deepcopy(polyn)
coeffs = []
terms = []
while polyn:
fam, coeff = polyn.LT()
famexpr = fam.as_expr()
if famexpr == 1:
fam = poly(x+1)poly(x) #1
else:
fam = poly(fam.as_expr())
terms.append(fam)
coeffs.append(coeff)
polyn = polyn  fam*coeff
if rcoeff:
return zip(terms, coeffs)
else:
return terms
def csub(pexp):
pexp = deepcopy(pexp)
for i in range(mc*2):
pexp = pexp.subs('C'+str(i), 1)
return pexp
def MOUC(problem, rlatex = True):
latextext = []
#print the problem
latextext.append(latex(problem))
latextext.append(latex("\\line(1,0){450}"))
yc = Eq(problem.lhs, 0)
latextext.append('y_c : ' + latex(yc))
#print yc
cp = yc
for i, ndy in reversed(list(enumerate(dys))):
cp = cp.subs(ndy, r**i)
cp = cp.lhs
latextext.append(latex(cp))
cproots = []
cpr = roots(Poly(cp))
for k, v in cpr.items():
cproots.append([k]*v)
#print roots (imaginary!?)
latextext.append('r : ' + ', '.join([latex(cproot) for cproot in cproots]))
latextext.append(latex("\\line(1,0){450}"))
ycsol = dsolve(yc.subs(y, y(x)))
latextext.append(latex(ycsol))
#print ycsol
yfams = []
ypf = poly(problem.rhs)
yfams = all_terms(ypf)
dyfams = [yfam.as_expr() for yfam in yfams]
for yfam in dyfams:
done = True
while done:
if type(yfam) in [type(S(val)) for val in xrange(1,3)]:
break
dyfam = poly(diff(yfam, x))
dyfammons = all_terms(dyfam)
for dyfammon in dyfammons:
dyfammon = dyfammon.as_expr()
if dyfammon in dyfams:
done = False
else:
dyfams.append(dyfammon)
dyfam = dyfammon
dyfams1 = dyfams[:]
yre = ycsol.rhs.expand()
yre = csub(yre)
rhsfams = [term.as_expr() for term in all_terms(poly(yre))]
for i, dyfam in enumerate(dyfams):
while dyfams[i] in rhsfams:
dyfams[i] *= x
while dyfams.count(dyfams[i]) > 1:
dyfams[i] *= x
#print promoted dyfams... if different
for i, dyfam in enumerate(dyfams):
if dyfam == dyfams1[i]:
latextext.append(latex(dyfam))
else:
latextext.append(latex(dyfams1[i]) + ' \\rightarrow ' + latex(dyfam))
Cs = [symbols('C'+str(i)) for i in range(3, 3+mc2)]
yp = 0
for i, term in enumerate(dyfams):
yp += Cs[i]*term
dyps = [yp]
for i in xrange(1, md+1):
dyps.append(diff(dyps[1], x))
#print each of the dyps
latextext.append(latex("\\line(1,0){450}"))
name = "y_p"
for i in xrange(poly(cp).degree()+1):
latextext.append(name + '=' + latex(dyps[i]))
name += "'"
adds = []
TCs = all_terms(poly(cp), True)
for T, C in TCs:
adds.append(C*dyps[T.degree()])
problemlhs = Add(*adds, evaluate=False)
latextext.append(latex("\\line(1,0){450}"))
ypbs = Eq(problemlhs, problem.rhs)
ypas = Eq(problemlhs.collect(x), problem.rhs)
#print unsimplified and simplified particular
latextext.append(latex(ypbs))
latextext.append(latex(ypas))
eqs = {key: Eq(0,0, evaluate = False) for key in rhsfams+dyfams}
for term, coeff in ypas.lhs.as_coefficients_dict().items():
key = csub(term)
cl, cr = eqs[key].lhs, eqs[key].rhs
eqs[key] = Eq(cl+coeff*term, cr)
for term, coeff in ypas.rhs.as_coefficients_dict().items():
key = csub(term)
cl, cr = eqs[key].lhs, eqs[key].rhs
eqs[key] = Eq(cl, coeff*term+cr)
for k, v in eqs.items():
cl, cr = v.lhs, v.rhs
eqs[k] = Eq((cl/k).simplify(), (cr/k).simplify())
tosolve = []
for k, v in eqs.items():
if v is not S(True):
tosolve.append(v)
#print tosolve
latextext.append(latex("\\line(1,0){450}"))
for eq in tosolve:
latextext.append(latex(eq))
ucs = Cs[:len(tosolve)]
Cps = {key:val for (key, val) in zip(ucs, solve_poly_system(tosolve, ucs)[0])}
#print Cps
for k, v in Cps.items():
latextext.append(latex(k) + ' = ' + latex(v))
ypsol = yp.xreplace(Cps)
#print ypsol
latextext.append(latex("\\line(1,0){450}"))
latextext.append('y_p = ' +latex(ypsol))
gsol = Eq(y, ycsol.rhs + ypsol)
#print gsol
latextext.append(latex(gsol))
if rlatex:
return gsol, latextext
else:
return gsol
def format(latexlines):
start = "\\begin{dmath*}"
end = "\\end{dmath*}"
nl = "\n"
return nl.join([start + nl + line + nl + end for line in latexlines])
def batchMOUC(problemdict, output):
fulltext = ["\\documentclass[fleqn, 12pt]{article}\n\\usepackage{breqn}\n\\usepackage[cm]{fullpage}\n\\setlength{\\mathindent}{0pt}\n\\begin{document}"]
#head, tail, and section
for i, v in problemdict.items():
_, latext = MOUC(v)
fulltext.append('\\section*{'+str(i)+'}')
fulltext.append(format(latext))
fulltext.append("\\end{document}")
with open(output, 'w') as ouf:
ouf.write('\n'.join(fulltext))
init_printing()
md = mc = mc2 = 5
x, y, r = symbols('x y r')
dys = [y]
for i in xrange(1, md+1):
dys.append(Derivative(dys[1], x))
problems = {
9: Eq(dys[2] + 2*dys[1]  3*y, 1+x*exp(x)),
10: Eq(dys[2] + 9*y, 2*cos(3*x) + 3*sin(3*x)),
13: Eq(dys[2] + 2*dys[1] + 5*y, exp(x)*sin(x))
}
batchMOUC(problems, 'output.latex')

number of "favorites" a piece gets on fanfiction.net vs which day it was published. i only considered stories that were published all at once (no incremental publishing). sample size for each day is about 90000. error bars are one standard deviation. monday is 0 and sunday is 6.
tldr publish on monday or thursday or friday. although it's less than a 2% difference from the average so it's probably not that important.

python handles double negatives well
(https://i.imgur.com/Clv0mTR.png)

python 3.4 master race

>3.4
boooo

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '149628'.

3.4 handles unicode encoding automatically with no frustrations
which is what a programming language/compiler should do in 2015
it's the future

but the 2.7 libraries!

my IOint class is like my IOlist class. except this one doesn't use inheritance because i've been too lazy to get it working
class IOint():
def __init__(self, filename):
self.value = None
self.filename = filename
def set(self, val):
self.value = val
self.save()
def save(self):
with open(self.filename, 'wb') as ouf:
ouf.write(str(self.value))
def load(self):
with open(self.filename, 'rb') as inf:
self.value = int(inf.readline().strip())

my western pacific statistical model...
it creates pretty believable tracks but the options are very limited (there's one track per square degree per month) and (probably) very innaccurate. the other issue is that many of the square degrees have no data and the storm will stop moving, so i need to create some interpolation method of some sort
it also only does tracks and doesn't forecast strength at all, but that is for a later addition
in the coming months i will hopefully be able to do some case studies
i could try to 'forecast' past storms too and see how well that goes

i was gonna say you should be a meteorologist as a money making profession and then i realized

http://imgur.com/a/uO6uV#0
this is the data that the program has so as you can see there are a lot of holes (except during peak season), but i'm not sure how i'd interpolate between them and determine where is interpolatable and where isn't
each character is how many storms have data for that square degree, and if it's greater than 9, A = 10, B = 11, R = 28, Y = 35 (yes there is one of those) etc

i'm studying for the computer science ap exam and google loves to troll me
(https://i.imgur.com/IJdPLmQ.png)

(http://i.imgur.com/dDJd8w5.png)
(http://i.imgur.com/sXlw3Ox.png)

http://stackoverflow.com/questions/24978052/interpolationoverregulargridinpython
this appears to be very useful for filling in my grid but i have no idea how to use numpy/scipy grids and how to convert the data i already have (which is basically just a 3d list of list of lists) into a grid that can be interpolated by these modules
it doesn't help that the example has everything named with seemingly random letters!
Edit: potentially useful for actually you know getting numpy and scipy on python 3.4 http://continuum.io/downloads#py34

it's actually not that hard. i never bothered with tutorials
converting:
np.array(yourlist) works
everything else is pretty much the same, except you can't append and can only store one type (like arrays are supposed to work).
slicing is all the same. iteration is all the same, BUT DON'T ITERATE
if you want to take the square of everything it's as simple as arr**2
or if you want to apply function f to everything it's as simple as arr = np.vectorize(f)(arr)

kolok will try it later tonight

ok so um this is not interpolation
This is what the original data looks like. It's visibly upsidedown but that's fine, the program handles it properly.
(http://i.imgur.com/kYPPXiF.png)
And this is the "interpolated" result:
(http://i.imgur.com/JlhmCgP.png)
i somehow managed to flip the grid dimensions which i think reorganized the data and then didn't even interpolate anything
i fixed that and changed all the zero's to nan's because they were not being interpolated at all
and now i'm getting an error at f = interpolate.Rbf(rr, cc, ar, function='linear')
ValueError: array must not contain infs or NaNs
yeeeeeeeeeeeeee
(http://i.imgur.com/V8lHbzM.png)
no time in class rn but this is the PTPC model's Tropical Storm Noul prediction
TS NOUL
[+0hr] +9.5 +139.6
[+6hr] +10.2 +140.5
[+12hr] +11.4 +140.7
[+18hr] +11.6 +140.9
[+24hr] +11.8 +141.1
[+30hr] +12.3 +141.4
[+36hr] +12.5 +141.7
[+42hr] +12.8 +141.9
[+48hr] +13.1 +142.5
[+54hr] +13.7 +143.1
[+60hr] +14.4 +143.9
[+66hr] +15.2 +144.7
[+72hr] +16.0 +145.6
[+78hr] +17.0 +146.6
[+84hr] +17.9 +147.8
[+90hr] +19.1 +149.2
[+96hr] +20.6 +150.7
[+102hr] +22.1 +152.5
[+108hr] +23.7 +154.4
[+114hr] +25.3 +156.0
[+120hr] +26.9 +156.7
[+126hr] +28.0 +157.0
[+132hr] +28.6 +158.2
[+138hr] +29.9 +159.5
[+144hr] +31.0 +160.0
[+150hr] +31.5 +161.2
[+156hr] +32.0 +161.7
[+162hr] +32.5 +163.2
[+168hr] +33.5 +164.5
[+174hr] +34.6 +165.7
[+180hr] +35.7 +166.7
forecast end

heeeeyyyyyy
the first functional prediction of an active storm (http://www.darrinward.com/latlong/?id=563166)
to do:
 inertial assumption for the first ~24 hrs, so as to preserve initial motion of the storm and hopefully put it on a more realistic track before it becomes pure statistics
 further division of the grid data into three types for El Niño, La Niña, and neutral years, which can affect storm track and intensity  though i'm not sure if there'd be too sparse of data, it might be a feature that only works during peak season (~JulNov)
 intensity prediction (statistical)
 sst data which affects intensity, possible, maybe use anomalies, since sst averages are likely to be reflected in the overall storm data anyway
 shear data which affects intensity, unlikely to be implemented

why is it on darrinward.com not kal's website

because that's just an easy online latlon plotter that generates a link every time you use it
i could maybe later code a track plotter in matplotlib? maybe

coding this makes me hot
hhnnnnggggg cyclone data
lol omg i added intensity prediction to my model and uh
it thinks Noul is going to be a Haiyan (http://en.wikipedia.org/wiki/Typhoon_Haiyan)
TROPICAL STORM NOUL  05 05 12Z
[+0hr] +9.5 +138.9 45.0 kt 992.0 hPa
[+6hr] +9.5 +138.9 53.0 kt 991.0 hPa
[+12hr] +9.7 +138.6 60.0 kt 989.0 hPa
[+18hr] +9.9 +138.0 68.0 kt 988.0 hPa
[+24hr] +10.3 +137.3 76.0 kt 987.0 hPa
[+30hr] +10.9 +136.3 79.0 kt 985.0 hPa
[+36hr] +11.4 +134.3 80.0 kt 983.0 hPa
[+42hr] +11.6 +133.2 84.0 kt 980.0 hPa
[+48hr] +11.9 +132.6 87.0 kt 980.0 hPa
[+54hr] +12.4 +132.2 89.0 kt 974.0 hPa
[+60hr] +12.8 +132.2 98.0 kt 971.0 hPa
[+66hr] +13.2 +132.1 106.0 kt 968.0 hPa
[+72hr] +13.9 +132.0 111.0 kt 962.0 hPa
[+78hr] +14.6 +132.0 116.0 kt 956.0 hPa
[+84hr] +15.0 +131.7 118.0 kt 952.0 hPa
[+90hr] +15.4 +131.5 119.0 kt 949.0 hPa
[+96hr] +16.4 +131.4 125.0 kt 941.0 hPa
[+102hr]+16.8 +131.2 130.0 kt 933.0 hPa
[+108hr]+17.1 +130.9 134.0 kt 926.0 hPa
[+114hr]+17.9 +130.3 139.0 kt 921.0 hPa
[+120hr]+18.7 +129.7 144.0 kt 916.0 hPa
[+126hr]+19.2 +129.3 154.0 kt 906.0 hPa
[+132hr]+19.9 +128.7 157.0 kt 902.0 hPa
[+138hr]+20.7 +128.5 162.0 kt 895.0 hPa
[+144hr]+21.6 +129.3 162.0 kt 897.0 hPa
[+150hr]+22.4 +130.8 159.0 kt 905.0 hPa
[+156hr]+23.4 +131.6 153.0 kt 910.0 hPa
[+162hr]+24.6 +132.7 150.0 kt 915.0 hPa
[+168hr]+25.7 +134.1 148.0 kt 918.0 hPa
[+174hr]+27.3 +135.6 143.0 kt 924.0 hPa
[+180hr]+28.5 +137.5 138.0 kt 927.0 hPa
forecast end
I feel like it's going to need to be modified, maybe to intensify only like 50  75% of what it is told to do but I'm not sure how to empirically decide this.
if i get the shear data working i could maybe have that "nerf" the intensity

yee beautiful
# http://www.darrinward.com/latlong/?id=552821
# for plotting
# http://stackoverflow.com/questions/24978052/interpolationoverregulargridinpython
# for scipy interpolation help
# https://knowledge.safe.com/articles/How_To/Calculatingaccuratelengthinmetersforlatlongcoordinatesystems
# for lat/lon conversions to nautical miles
# http://matplotlib.org/basemap/users/examples.html
# create a 1 deg x 1 deg resolution grid for each month
# put SST data for each month
# put shear data?
#split SSTs by el nino and la nina and neutral
import math, sys
import numpy as np
import scipy.interpolate as interpolate
import matplotlib.pyplot as plt
class cycdat:
def __init__(self, vx, vy, wind, pres, data):
self.x = vx
self.y = vy
self.w = wind
self.p = pres
self.d = data #how many points of data are in this grid, so that velocities can be summed and averaged
#self.t = temp
f = open('bst8089.txt', 'r+')
k = f.read()
lines = k.split('\n')
#ln1 = lines[1]
#make a grid or something
grid = []
for m in range(0, 12):
temp2 = []
for y in range(0, 50):
temp = []
for x in range(100, 180):
temp.append(cycdat(0, 0, 0, 0, 0))
temp2.append(temp)
grid.append(temp2)
#m1, y, x100
lastyear = None
for l in lines:
sp = l.split(' ')
sp = [y for y in sp if y != '']
try:
if sp[1] == '002':
#date
t1 = sp[0]
year1 = t1[:2]
month1 = int(t1[2:4])
day1 = t1[4:6]
#tropical or extratrop
if sp[2] == '6':
ex1 = False
else:
ex1 = True
#position
lat1 = int(sp[3])/10
lon1 = int(sp[4])/10
#intensity
wind1 = int(sp[6])
pres1 = int(sp[5])
if lastyear is not None and lastlon < 180.0 and lastlat < 50.0:
dlat = lat1  lastlat
dlon = lon1  lastlon
dwind = wind1  lastwind
dpres = pres1  lastpres
grid[lastmonth  1][math.floor(lastlat)][math.floor(lastlon)  100].x += dlat
grid[lastmonth  1][math.floor(lastlat)][math.floor(lastlon)  100].y += dlon
grid[lastmonth  1][math.floor(lastlat)][math.floor(lastlon)  100].w += dwind
grid[lastmonth  1][math.floor(lastlat)][math.floor(lastlon)  100].p += dpres
grid[lastmonth  1][math.floor(lastlat)][math.floor(lastlon)  100].d += 1
lastyear = year1
lastmonth = month1
lastday = day1
lastlat = lat1
lastlon = lon1
lastwind = wind1
lastpres = pres1
if sp[0] == '66666': #reset all of the last things and bypass adding a point between storm end & start positions
lastyear = None
except:
print("end of file... probably")
for list in grid:
for list2 in reversed(list):
for x in list2:
if x.d != 0:
n = x.d
if x.d > 9:
n = chr(x.d + 55)
sys.stdout.write(str(n))
x.x = x.x/x.d
x.y = x.y/x.d
x.w = x.w/x.d
x.p = x.p/x.d
else:
sys.stdout.write(' ')
sys.stdout.write('\n')
sys.stdout.write('\n\n')
stormmonth = int(input('Initialization month: '))
stormlat = float(input('Initial latitude: '))
stormlon = float(input('Initial longitude: '))
stormwin = float(input('Initial wind speed (kt): '))
stormpre = float(input('Initial pressure (hPa): '))
stormsp = float(input('Initial speed (kt): ')) * 6 #6 hours of movement
stormdir = input('Initial direction (or STATIONARY): ')
#calculate nm/deg lon
rlat = stormlat * (math.pi/180)
hfactor = (111412.84 * math.cos(rlat)  93.5 * math.cos(3*rlat))/1852
#calculate nm/deg lat
#calculate vector of speed/dir
if stormdir == "N":
initv = stormsp / 60
inith = 0
elif stormdir == "S":
initv = stormsp / 60
inith = 0
elif stormdir == "W":
inith = stormsp / hfactor
initv = 0
elif stormdir == "E":
inith = stormsp / hfactor
initv = 0
elif stormdir == "NE":
inith = math.cos(math.pi/4) * stormsp / hfactor
initv = math.sin(math.pi/4) * stormsp / 60
elif stormdir == "NW":
inith = math.cos(3*math.pi/4) * stormsp / hfactor
initv = math.sin(3*math.pi/4) * stormsp / 60
elif stormdir == "SW":
inith = math.cos(5*math.pi/4) * stormsp / hfactor
initv = math.sin(5*math.pi/4) * stormsp / 60
elif stormdir == "SE":
inith = math.cos(7*math.pi/4) * stormsp / hfactor
initv = math.sin(7*math.pi/4) * stormsp / 60
elif stormdir == "ENE":
inith = math.cos(math.pi/8) * stormsp / hfactor
initv = math.sin(math.pi/8) * stormsp / 60
elif stormdir == "NNE":
inith = math.cos(3*math.pi/8) * stormsp / hfactor
initv = math.sin(3*math.pi/8) * stormsp / 60
elif stormdir == "NNW":
inith = math.cos(5*math.pi/8) * stormsp / hfactor
initv = math.sin(5*math.pi/8) * stormsp / 60
elif stormdir == "WNW":
inith = math.cos(7*math.pi/8) * stormsp / hfactor
initv = math.sin(7*math.pi/8) * stormsp / 60
elif stormdir == "WSW":
inith = math.cos(9*math.pi/8) * stormsp / hfactor
initv = math.sin(9*math.pi/8) * stormsp / 60
elif stormdir == "SSW":
inith = math.cos(11*math.pi/8) * stormsp / hfactor
initv = math.sin(11*math.pi/8) * stormsp / 60
elif stormdir == "SSE":
inith = math.cos(13*math.pi/8) * stormsp / hfactor
initv = math.sin(13*math.pi/8) * stormsp / 60
elif stormdir == "ESE":
inith = math.cos(15*math.pi/8) * stormsp / hfactor
initv = math.sin(15*math.pi/8) * stormsp / 60
elif stormdir == "STATIONARY":
inith = 0
initv = 0
print('\n')
fi = open('output.txt', 'a')
hours = 0
print("[+" + str(hours).zfill(3) + "hr]\t+" + str(stormlat).zfill(4) + "\t+" + str(stormlon).zfill(5) + "\t" + str(round(stormwin, 1)).zfill(5) + " kt\t" + str(round(stormpre, 1)).zfill(5) + " hPa")
fi.write(str(round(stormlat, 1)) + ", " + str(round(stormlon, 1)) + "\n")
hgrid = [] #horizontal (WE) motion
vgrid = [] #vertical (NS) motion
wgrid = [] #wind
pgrid = [] #pressure
for list in grid:
htemp = []
vtemp = []
wtemp = []
ptemp = []
for list2 in list:
htemp2 = []
vtemp2 = []
wtemp2 = []
ptemp2 = []
for x in list2:
htemp2.append(x.x)
vtemp2.append(x.y)
wtemp2.append(x.w)
ptemp2.append(x.p)
htemp.append(htemp2)
vtemp.append(vtemp2)
wtemp.append(wtemp2)
ptemp.append(ptemp2)
hgrid.append(htemp)
vgrid.append(vtemp)
wgrid.append(wtemp)
pgrid.append(ptemp)
def interp(g):
ar = np.array(g[stormmonth  1])
ar[ ar==0 ] = np.nan
r = np.linspace(0, 1, ar.shape[1])
c = np.linspace(0, 1, ar.shape[0])
rr, cc = np.meshgrid(r, c)
vals = ~np.isnan(ar)
f = interpolate.Rbf(rr[vals], cc[vals], ar[vals], function='linear')
return(f(rr, cc))
hi = interp(hgrid) #INTERPOLATE HORIZONTAL GRID
vi = interp(vgrid) #INTERPOLATE VERTICAL GRID
wi = interp(wgrid) #INTERPOLATE WIND SPEED GRID
pi = interp(pgrid) #INTERPOLATE PRESSURE GRID
#plt.imshow(wi)
#plt.show()
def simulate(slat, slon, g, g2, g3, g4):
tlat = g[math.floor(slat)][math.floor(slon)100]
tlon = g2[math.floor(slat)][math.floor(slon)100]
twin = g3[math.floor(slat)][math.floor(slon)100]
tpre = g4[math.floor(slat)][math.floor(slon)100]
return (tlat, tlon, twin, tpre)
for x in range(0, 180, 6):
templat, templon, tempwind, temppres = simulate(stormlat, stormlon, hi, vi, wi, pi)
if hours < 36:
frac = (1/1296) * (hours  36)**2
stormlat += frac * initv + (1frac) * templat
stormlon += frac * inith + (1frac) * templon
else:
stormlat += templat
stormlon += templon
stormwin += .5 * tempwind
stormpre += .5 * temppres
if stormlat == lastlat and stormlon == lastlon:
print("storm stalled")
break
if stormlat > 50.0 or stormlon > 180.0 or stormlat < 0.0 or stormlon < 100.0:
print("storm left grid")
break
lastlat = stormlat
lastlon = stormlon
hours += 6
print("[+" + str(hours).zfill(3) + "hr]\t+" + str(round(stormlat, 1)).zfill(4) + "\t+" + str(round(stormlon, 1)).zfill(5) + "\t" + str(round(stormwin, 1)).zfill(5) + " kt\t" + str(round(stormpre, 1)).zfill(5) + " hPa")
fi.write(str(round(stormlat, 1)) + ", " + str(round(stormlon, 1)) + "\n")
if hours == 180:
print("forecast end")
fi.close()

i feel like there should be a better way to handle that block of elif statements for every direction you had

i agree but can't think of anything

well i don't know how it works so i'm not going to try deciphering it but i think this piece of code should help.
def gettheta(tlc): #threelettercode
dd = {'E':0, 'N':1, 'W':2, 'S':3}
if 'S' in tlc and 'E' in tlc:
dd['E'] = 4
theta = dd[tlc[1]]
for l in reversed(tlc):
theta = (dd[l] + theta)/2.
return theta/2.*math.pi #convert to radians
then you can do
inith = math.cos(gettheta(tlc)) * stormsp / hfactor
initv = math.sin(gettheta(tlc)) * stormsp / 60
or something
you still need an separate case for the STATIONARY

or for some shorter (but less elegant) code
dirmap = dict(zip(['E', 'ENE', 'NE', 'NNE', 'N', 'NNW', 'NW', 'WNW', 'W', 'WSW', 'SW', 'SSW', 'S', 'SSE', 'SE', 'ESE'], [i/8.*math.pi for i in range(16)]))
and
inith = math.cos(dirmap[tlc]) * stormsp / hfactor
initv = math.sin(dirmap[tlc]) * stormsp / 60

also considering that objects are passed by reference i'm pretty sure instead of
grid[lastmonth  1][math.floor(lastlat)][math.floor(lastlon)  100].x += dlat
grid[lastmonth  1][math.floor(lastlat)][math.floor(lastlon)  100].y += dlon
grid[lastmonth  1][math.floor(lastlat)][math.floor(lastlon)  100].w += dwind
grid[lastmonth  1][math.floor(lastlat)][math.floor(lastlon)  100].p += dpres
grid[lastmonth  1][math.floor(lastlat)][math.floor(lastlon)  100].d += 1
you can do
cell = grid[lastmonth  1][math.floor(lastlat)][math.floor(lastlon)  100]
cell.x += dlat
cell.y += dlon
cell.w += dwind
cell.p += dpres
cell.d += 1

A tool I made for designing geometric minecraft builds. Plots ellipses, splines, parabolas, hyperbolas, and anything you can write as a parametric function.
def demo():
B = UnitGrid(100, 100, 100, 100, False, False)
print 'plotting hyperbola'
B.hyperbola(17, 23, 54, 71, 1)
print 'plotting ellipse'
B.ellipse(20, 80, 15, 17)
print 'plotting parabola'
B.parabola(0.01, 2, 20)
print 'plotting line'
B.line(54, 90, 90, 11)
print 'plotting spline'
B.spline([0,10,72,4,90,100],[0,10,11,17,90,100])
B.write('demo')
demo()
you can clearly see the ellipse, hyperbola, parabola, spline, and line in this image.

this is more stats than coding but whatever.
x axis: days since epoch
y axis: seconds since 0000
color: keypresses per five minutes

whenpulse

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '151120'.

is epoch the new thing for epic
jkjk i aint dat stupid

i'm working on something.
https://dl.dropboxusercontent.com/u/42218552/kol.gif

Cute

its ubox 0.00001

it looks like it tries to swirl but then it doesnt'

LET ME EDUMACATE YOU GUYS ON THE WONDER OF PYTHON'S COMPLEX NUMBERS
IMAGINE YOU WANT TO CALCULATE THE DISTANCE OF TWO POINTS LIKE A CIVILIZED PERSON
a = (x1, y1)
b = (x2, y2)
def distance(a, b):
return ((a[0]b[0])**2+(a[1]b[1])**2)**0.5
that's 36 goddamn characters after the return. two layers of parentheses. ewwww
NOW LETS USE SOME COMPLEX NUMBERS
a = x1+y1*1j
b = x2+y2*1j
def distance(a,b):
return abs(ab)
BAM JUST EIGHT CHARACTERS LOOK AT THAT EFFICIENCY this is the power of complexes

kol

fixed a few bugs, added plummer softening
new simulation showing a slightly perturbed grid of particles on a toroidal plane (yes it wraps). gravity calculations are a bit more complex now.
you can see an initial collapse phase followed by a stable dynamic phase
due to an artifact of my approximation scheme, most of the mass clusters at the center of the screen (which, as far as glitches go, is pretty sweet)
https://dl.dropboxusercontent.com/u/42218552/kol2.gif

Kolkute

update on my simulation. fixed a shitton of physics bugs. each second is 1.5 billion years, the size of the simulation is about 32 Mpc. each point represents the mass of 40 Large Magellanic Clouds
https://dl.dropboxusercontent.com/u/42218552/kol4.gif

A nifty script to compute area
Input: Image named map.png in equirectangular projection. Must be only black and white.
Output: prints a number between 0 and 1 which represents the proportion of the map which is black on a globe.
from PIL import Image
import numpy as np
from math import cos, pi
im = Image.open('map.png')
im = im.convert('L')
imarr = np.array(im)/255
dy, dx = imarr.shape
area = 0
for y, cir in enumerate(imarr):
factor = cos(((y+.5)/dy.5)*pi)
area += factor*np.sum(cir)
area /= dx**2/pi
area = 1area
print area

Kolkute
I was working on calcing some areas today but using another method where I used G.Projector to turn the map into an equal area projection and then counting pixels of various areas.
https://docs.google.com/spreadsheets/d/1uzJnsESvGT6UziUjPeLsWRpqULjNYzLxlUuaSia4ayM/edit#gid=0

a script which computes the best way to release *vision votes in order to generate the most suspense.
currently it just brute forces random permutations and takes the best result. there's probably a much better way to do this

Idk how you did it in the code but in Videovision 2 I just started from the end with all the points, and then picked someone to release results last who would leave as many potential winners as possible. Then I did the same for the second last release, and so on.

i basically just maximized a metric i made up to represent suspense
consider the time when a subset of all the votes has been released. at this point, the suspense is computed to be the sqrt(total points given out)*sum of x_max/(k+x_maxx_i) where x_max is the highest scoring entry and x_i are the scores of every other entry except that one.
k is a constant to avoid singularities on a tie.
as you can see, if many entries are close to the highest scoring entry, there's much more suspense.
the sqrt(total points) factor makes the suspense more heavily weighed when nearly all the votes are given out
i sum this suspense metric for every new vote that's released to get the total suspense, and that's what's maximized

my gravity sim code

i've pressed 10 million keys in the last year

Nice chart kol

can i have whenpulse

yes.

omf https://github.com/munificent/vigil

Kol joke code languages are the best.

i wrote some code to format c code for me
it turns this:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static heap_t *_heap_create(int s, long *f)
{
heap_t *h;
h = malloc(sizeof(heap_t));
h>h = malloc(sizeof(int)*s);
h>s = h>cs = s;
h>n = 0;
h>f = f;
return h;
}
static void _heap_destroy(heap_t *heap)
{
free(heap>h);
free(heap);
}
int main()
{
huffcode_t **r;
int i;
char strbit[MAXBITSPERCODE];
const char *p;
long freqs[BYTES];
memset(freqs, 0, sizeof freqs);
p = test;
while(*p != '\0') freqs[*p++]++;
r = create_huffman_codes(freqs);
for(i=0; i < BYTES; i++) {
if ( r[i] != NULL ) {
inttobits(r[i]>code, r[i]>nbits, strbit);
printf("%c (%d) %s\n", i, r[i]>code, strbit);
}
}
free_huffman_codes(r);
return 0;
}
into this:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static heap_t *_heap_create(int s, long *f) {
heap_t *h ;
h = malloc(sizeof(heap_t)) ;
h>h = malloc(sizeof(int)*s) ;
h>s = h>cs = s ;
h>n = 0 ;
h>f = f ;
return h ;}
static void _heap_destroy(heap_t *heap) {
free(heap>h) ;
free(heap) ;}
int main() {
huffcode_t **r ;
int i ;
char strbit[MAXBITSPERCODE] ;
const char *p ;
long freqs[BYTES] ;
memset(freqs, 0, sizeof freqs) ;
p = test ;
while(*p != '\0') freqs[*p++]++ ;
r = create_huffman_codes(freqs) ;
for(i=0; i < BYTES; i++) {
if ( r[i] != NULL ) {
inttobits(r[i]>code, r[i]>nbits, strbit) ;
printf("%c (%d) %s\n", i, r[i]>code, strbit) ;}}
free_huffman_codes(r) ;
return 0 ;}

all the code i needed to make this post, all ~300 lines and 9 hours of it.
http://universesandbox.com/forum/index.php/topic,2724.msg155589.html#msg155589

From a Game of Life assignment for a computer science course
(written in MatLab though)
(http://i.imgur.com/zoyPvAT.png)
(http://i.imgur.com/HPMrvV4.png)

cute
that figure looks like a replicator (high life?) or whatever ship thingy you can make from it in conway's life

wowowowoowowowowowowowowowow

Finished a numeric integrationthing that calculates the path of n bodies affected by gravity (or an equivalent kind of force), in 3 dimensions (plots 2 only) for computer science class.
Timestep is calculated depending on how much the acceleration changes and end time, gravitational constant, how often it plots points and initial conditions are entered.
Examples:
(http://i.imgur.com/5q6GoMU.png)
(http://i.imgur.com/5XLtbrZ.png)
(The units are pretty arbitrary)
Oh and on the lower plot the upper line is kinetic energy, lower line is potential energy and the (fortunately) constant line is total energy.

wow cute

the new universe sandbox everyone :P

universe sandbox 0.001

Kol :P
Here I let it run for 100 time units with the same conditions
(http://i.imgur.com/nNk07SG.png)
(http://i.imgur.com/Z54DhD7.png)
kol this is too addicting
(http://i.imgur.com/T0XagZs.png)
(http://i.imgur.com/4JiVYRo.png)
(http://i.imgur.com/S4gyapr.png)
(http://i.imgur.com/lKpDzCa.png)

>Saving a file
>Accidentally save entire matrix instead of specific matrix elements in loop
>End up with 10 GB file instead of 270 kB
(http://i.imgur.com/vd8KPBn.png)
wait nooo wait what it's still growing oshi stop stop stope
(http://i.imgur.com/RujlH5L.png)
catalog.bin was keeled to death after reaching 23.8 GB. Rip in peach catalog.bin after reaching 29% of progress in trying to take over my remaining hard disk space.
(http://i.imgur.com/cDloTVA.png)

is that nbt explorer i see there

Kolyes nbtexploder is my default program for .dat files
Also the gravity sim got an upgrade so it now can make videos
https://www.youtube.com/watch?v=aEh9Y5kqUH8

cute

Thank

Hurricane Marty overlaid on top of every named Pacific storm from 20042013
green = tropical
yellow = subtropical
blue = extratropical
gray = disturbance
black = other
(http://i.imgur.com/VFwchU6.png)
and Hurricane Jimena
(http://i.imgur.com/F78nLUZ.png)

jimena BIG

This week we had to make GUIs
It's depressing to think about the fact that Matlab costs $$$s though, and that even if I wrote e.g. Map War 2 in it, nobody would be able to play it I guess, since they'd have to buy Matlab. Or Idk about the Python Matlab thing. But some day, I hope I can use my experiences to revive the Map War project and program the Strategy Game I Always Dreamt of.
(http://i.imgur.com/u9Vlqsh.png)

wow this is orange oppression

It has no simple orange command :(

Actually I think I've found a way to make Matlab compile scripts into .exe, that would be supercute. The first exe should run a figure demonstrating some Feynman clocks moving. The second one should run the oscillator GUI and plot stuff. If anyone wants to try, let me know if it works for you.
mcc m <scriptname>

i tried running it but it complained about some acronym
(https://i.gyazo.com/10249914e92f420b99bd5be7f20e258d.png)

Oh great apparently the .exes require this 400 MB thing...
http://se.mathworks.com/products/compiler/mcr/index.html
Thanks for testing though.
I was working on a GUI for Orbit for fun but I guess it won't be of much interest to others if they need to download and install over 400 MB to try it. Anyway this is how it looks
(http://i.imgur.com/nZsp5YF.png)
(http://i.imgur.com/jX86gkf.png)
(http://i.imgur.com/fgLfmiF.png)

400 MB is ezpz

If you feel like it, the program in its current state is here
Also this
(http://i.imgur.com/AWuL7dy.png)

what happened to 15% of the energy

Fuck energy conservation, just go with the colorful lines!

Fuck energy conservation, just go with the colorful lines!

i'm play code windowed program
currently it handles not much more than a pannable and zoomable map (but it scales the pan when zoomed in! and stays centered!)
you can also adjust the text boxes at the top, and it tells you your cursor position
(https://i.gyazo.com/87e91377dccc38c22f6c2e31ce577b56.png)

Nice start, I expect to see Map War 2 gameplay implemented by November 1st

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '159542'.

I wrote a cute little script today which generates this (http://paladinofstorms.net/meteo/npac/latest.jpg) every 30 minutes.

Cute colors thar

going to talk about my code without actually posting it cause it's on my rl github account
i've been working on a gravity simulation to model the cosmological structure of the universe
here are how many gravitational interactions a brute force approach would have to compute:
2^10 (periodic boundary conditions)
2^12 (number of timesteps)
2^32 (number of bodies squared)
2^1 (number of acceleration calculations per step of verlet)
2^55 (total)
2^55 is about 36000 trillion, which is a bit even for modern computers.
anyway i managed to optimize it down. i added a counter to see how many computations i ran, and it ends up equivalent to 2^35 gravitational interactions, or about 34 billion, which my laptop does inside of an hour.
that's a speed of factor of 2^20  around a million, which is not so bad if i say so. also i managed to get multiprocessing working so that's another speedup of 2^3 on top of everything

[16:00] <+syule> what the hell
[16:01] <+syule> i changed my code in a way that shouldn't speed it up
[16:01] <+syule> and my code sped up by a factor of like 100
[16:01] <+syule> what the fucking fuck
[16:01] <+syule> wait i know why
[16:01] <+syule> branch prediction
[16:01] <+syule> gdi
immediately before this i had a problem where multiprocessing slowed down my code by a factor of 6

i just realized i was using the debugger in release mode
disabling it just sped up my code by another factor of 100+
this is glorious

so is that a factor of 101 (after the second) and 10000 after the first?
how do factors work

factor is a fancy way of saying multiplied, atleast the way ive heard it used.
Ex: Training with Omnipotencian trainers ups your power by a factor of 1,000

yes but multiply 100 by 100 or 1 by 100
they are different results

so apparently the reason my code suddenly got so fast is because i accidentally created a bug which caused the code to actually not do any computations at all but still appear to work and yeah i fixed that and now it's back to not being super fast but still being 2 to 3 times faster than it was before
1 million bodies for ten thousand timesteps should take about a day to compute now

(https://i.gyazo.com/cea4311f2d7d9cf3abc758e2c424b835.png)
it's not done yet

so anyway, i calculated musical taste groupings for the 15 eligible past participants of univision
basically what I did was, I compared the votes of every nation with every other nation, and got values for every single pairing (vote similarity + whether both nations vote for each other)
then created an algorithm which would split the nations into 4 groups which internally matched the closest, ignoring the rest of the nations
the result is 4 different musical tastes, or "pots"
(https://i.gyazo.com/424d91a8a865058d75946e732dfdd441.png)
if you think you're in the wrong pot, you very well may be, but you likely were sacrificed for someone else who fit better. for example, darvincia fits very well into pot C (Solea, Dotruga, and Blaland are his 1st, 2nd, and 4th most similar nations), and not very well into B (with his 6th, 8th, and 13th)
but the nation that he switched with, Bielosia, fits worse in pot B (10th, 11th, 12th), but about equally as well as Darvincia did in pot C (1st, 2nd, 5th)
this switch increased total affinity by 17 units
this doesn't exactly serve any functional purpose in univision, since we have no semifinals, but it does give a quantified sense of musical tastes and voting similarities
a more detailed chart and calculations that were used to determine this can be found here (https://docs.google.com/spreadsheets/d/1_E0EyVikuYqi_X2t3wiAfqbVBu4s39wKmr7X1nQj8Y/edit#gid=32936945)

can someone check all ips on wikipedia like contributions for 174.19.xxx.xxx

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '165705'.

i think it might make individual pages for each IP so it should be relatively easy.

there are contribs pages for every IP that has edited so yes

fiah there's a reason i asked in the coding thread (hint hint)

dar's number criteria thing i coded for him
even numbers not divisible by 10 whose digit sums are primes whose digit sums are prime
http://pastebin.com/dWrnN7VY
example: 14972 (even)
1+4+9+7+2 = 23 (prime)
sum again:
2+3 = 5 (prime)

do you even loop kalassak?
#rekt
http://pastebin.com/xNVqWXcj

holyshit, i just discovered this new python builtin today
testing if all values in a list are positive:
old style:
false not in [val > 0 for val in lst]
with this builtin:
all(val > 0 for val in lst)

I was working on a script that needs to fit a function, which has decided that it wants to contain an integral. I spent more than an hour trying to figure out why many variables, starting with Rg, began to change to ridiculous values after the first turn in the loop. Well, it turns out I used c for the speed of light and forgot that I also trashed a useless matrix element into a variable called 'c' in the loop. gg. Do never use c for anything else than the speed of light.
(http://i.imgur.com/YgTT4gV.png)

kol bad variable names have cost me many hours of debugging
also when i write physics simulations and i do something like
x_velocity += x_acceleration*t
the copy and paste it, changing x to y to update y_velocity  but i only change some of the x's to y's and forget the rest

Yes also formulas with x1 v1 a1 t1... then you write a giant formula with lots of stuff and change half the x1's to x2's but forget this one a1 that screws up everything and takes 3*10^8 hours to find

i am a goddess
uniformly distributed points on a sphere

dat looks like a circle

it's a 2d projection of points on a sphere

oh so it is like see through

it don't work

ok so there's obviously a problem but i made the attractive force stronger and removed the initial random velocities
and it looks more like it works... i'm going to have to fix whatever problem showed up above (they start to collect around the poles by default?)

[00:00] <+kalassak> two particles just decide that
[00:00] <+kalassak> they shouldn't repel directly away from each other
[00:00] <+kalassak> wth
[00:01] <+kalassak> something's wrong with the fundamental math
[00:01] <+kalassak> and i have no idea where to start
[00:10] <+kalassak> i wouldn't be surprised if i just typed sin where it was supposed to be cos or vice versa

pole collection has kicked into overdrive
i fixed the math and the particles move in the right direction now (although toward each other in this example, because that's easier to test than repulsion)
i also updated the graphics... green = near hemisphere, purple = far hemisphere

and repulsion

good news
sometimes two particles on opposite sides of the planet interact with each other, take similar paths, and then shoot off at high speed
i have no idea why
also i have a theory as to why things get stuck at the poles... they basically cross over or near the pole but retain their velocity numerically... so like, they might have a positive y velocity near the north pole, cross it, then still have a positive y velocity... which causes them to cross near the pole again over and over.
not really sure how to fix it, maybe i could try to calculate the final bearing for every particle and if the bearing is southerly/northerly and it wasn't before then the y velocity will be inverted

ｃａｎ ｕ ｍａｋｅ ａ ｃｉｒｃｌｅ ｓｏ ｉ ｃａｎ ｃ ｔｈｅ ｐｌａｎｅｔ ｔｈｘ

this was a five minute hack i put together.
ever wonder how much time you waste browsing reddit or playing minecraft? too lazy to track your habits? well this is the script for you.
it takes a screenshot of your entire screen (should work for multiple monitors too) with a 1/600 chance every second (so an image every 10 minutes on average), and saves it to a file in the same directory with the unix timestamp as filename.
at the end of the day, you should have 144 screenshots or so which you can look through quickly and get an idea of exactly how much time you wasted.
this works on windows only
requires:
PIL / Image
pywin32

random dump of the code i used to compute optimal elytra flight. the first 45 lines are pretty beautiful code, the rest is sloppy

simulation of this chaotic system, in which every point has two randomly selected target points that it wants to be equidistant to, and points cannot get too close or too far from each other
https://dl.dropboxusercontent.com/u/42218552/0test.mp4
"so what are the points trying to do?"
they're trying to go to perpendicular bisectors (which are drawn out) of their target points. this obviously makes them equidistant
"but senpai, why are the points so jittery"
well you see, having them actually move toward the bisector requires a good amount of math
"you're good at math ... right?"
i coded this on a friday night, when my brain was mush, so instead of doing the math, i just had each point make 10 random moves, compute how good each move was, and select the best move. which is why it's jittery, because it's searching for local optima and does no planning

this was a five minute hack i put together.
ever wonder how much time you waste browsing reddit or playing minecraft? too lazy to track your habits? well this is the script for you.
it takes a screenshot of your entire screen (should work for multiple monitors too) with a 1/600 chance every second (so an image every 10 minutes on average), and saves it to a file in the same directory with the unix timestamp as filename.
at the end of the day, you should have 144 screenshots or so which you can look through quickly and get an idea of exactly how much time you wasted.
this works on windows only
requires:
PIL / Image
pywin32
perfect

snip
now fixed so that if you lock your screen it won't crash

(https://i.gyazo.com/cd2dbb118f1a04d1cc04390f8bcec6b4.png)
(https://i.gyazo.com/c8d7ec3049037a83d68c36af62432b2f.png)
i wrote a very rudimentary gravity simulator that's limited to 3 bodies but you can watch it as the simulation progresses
requires matplotlib

this line is the death of my code:
input=open("coords.txt",'r')
which is funny, because it works just fine
but i'm running a script through cmd that runs in jython in some other program... and that causes it not to work
which is funny, because it should work just fine per this http://www.ssec.wisc.edu/~tomw/visadtutor/load.html
but, i did have some issues coding since some functions were changed from some earlier version of this program and had to updated to a new version of the function name... but that was for some other module presumably and not... normal... file... input/output... operations?????????????????????
anyway, i've been trying to get some help on the support forum for said program for a month now but my account hasn't been approved
so i made a new one
i figure this issue probably has a really simple fix and i'm just missing something really stupid... but i don't know, maybe i'll know in july

a more detailed chart and calculations that were used to determine this can be found here (https://docs.google.com/spreadsheets/d/1_E0EyVikuYqi_X2t3wiAfqbVBu4s39wKmr7X1nQj8Y/edit#gid=32936945)
new univision pots
(https://i.gyazo.com/8981b2195d908b59a31a5bd1bf8bdc72.png)

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '170686'.

wouldn't that be
darvincia aeridani kallisto bongatar

>implying i would stoop to the level of shitposting

you shitpost in univision by sending yoko ono

>no you shitpost by not sending enough yee

we define the product function over the ddimensional space as the product of the components of any point.
for example, product(.2) = .2, product([0.5,0.5,0.5]) = 0.125
if we integrate product over the unit interval [0,1], we get 1/2
if we integrate product over the unit square, with corners (0,0) and (1,1), we get 1/4
if we integrate product over the unit cube, we get 1/8
if we integrate product over the unit ddimensional hypercube, we get 2^d
notice that in high dimensions, this function has a very narrow peak which can trip up numerical integration methods.
therefore it is a good way to test how good a numerical integrator is.
we measure error of a numerical integrator as follows:
if the integrator returns some value y, and the actual solution is w, we say error is y/w1
in the below graph, the xaxis is the number of dimensions
the yaxis is the error as computed previously
the blue line represents a perfect symbolic integrator
the red line is a nonadaptive monte carlo integrator
the green line is an adaptive monte carlo integrator (VEGAS) which i used from this python library which is really nice
parameters were set so that both numerical integrators sampled 150000 points
we can see that up to 12 dimensions or so, the adaptive integrator is off by no more than one part in a thousand

(http://i.imgur.com/dBHWQl8.png)
I got WRF (an opensource regional weather model) running today and I've run a few test simulations... Here's my first "real" simulation:
It's a simulation using the North Atlantic basin as the domain for the model. I'll be using this as my region to see how the model forecasts Atlantic TCs throughout the season. I might also set up a region for the EPAC or WPAC but as of yet they haven't been doing anything.
I ran the simulation for 72hrs out from 20160610 00:00:00 UTC with 30 km resolution, using the GFS model as data input and for the bounds of the sim (since it's a regional model). The run took about 55 minutes to complete. Here are a few of the types of data it can output that I've been messing around with:
http://imgur.com/a/6drUC
The first album here is just 6 hour precipitation between each frame for the whole length of the run.
(http://i.imgur.com/zIMWAQI.png)
Here is an outgoing longwave radiation plot which works well to visualize where clouds and convection are. There is definitely a better way to simulate infrared satellite (probably a combination of factors and some math) but I don't know how to do that yet.
(http://i.imgur.com/xHb5rFA.png)
And here is a plot of mean sea level pressure and 10m winds. I'm still working on the contourfill color scheme.
I'm still messing around with it though and trying to figure out all the cool things you can do with it.
But finally... I'm in control. ^^

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '171175'.

kol

(http://i.imgur.com/11obLHk.png)
ehhhh... what
y axis is time (date of year)
x axis is longitude (in degrees)
points are locations of the formation of tropical cyclones
i'm trying to see if there's a pattern in the longitude of their formation... something like this:
(http://i.imgur.com/e8uWFYp.png)
but i have no idea because the kernel function is predicting(?) places of high frequency of cyclone formation where there were none, specifically west of 60E
and not showing any frequency where cyclones did actually form
cause it likely follows a pattern similar to this:
(https://upload.wikimedia.org/wikipedia/commons/8/8d/MJO_5day_running_mean_through_1_Oct_2006.png)

(https://s31.postimg.org/ucjoeaxpn/dvorak.png)
[04:53] <+kalassak> i'm working on a game but since i can't code it on vacation i figured i'd mess around with mechanics
[04:53] <+kalassak> so i'm figuring out how to generate dvorak numbers based on a known correct intensity
[04:53] <+kalassak> so that the player can take the dvorak and use it for their tracking
[04:56] <+kalassak> less often a microwave estimate will be given (a bit more accurate) and even less often will you get a scatterometer pass (very accurate)

for R E A L I S M scatterometer should only be accurate below hurricane strength

A video of my repulsive gravity simulator.
The repulsion seems to slow down over time. that's just the universe expanding according to hubble's law

doesnt play 0/10

yes it does

https://www.youtube.com/watch?v=LrjYWNN5sQ8&feature=youtu.be
a small scale simulation before i actually run the full scale version of the simulation. if you view this in full screen, each white pixel weighs about 2 milk way galaxies. the reason there are bars on the side of this video is because the video itself is 1024 x 1024, yet youtube kept resizing it to 720p, losing information in the process, so i was forced to pad it until it was 1920 x 1080. there are 65536 objects in this simulation. the full scale sim will have just over a million (2^20). each second of this video is about 160 million years of time.
i will admit there are some "glitches" with this simulation. if you watch one of the blobs in the lower left corner, you'll see that at some point, it spontaneously explodes itself.

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '174484'.

Very cool

yall need to be more active
Start with the numbers from 3 through 10 billion (skip 1 and 2 because they have weird properties). Now compute a list of primes in that range  there should be a bit less than 500 million of them.
Now consider these primes in groups of 3072 primes each, with groups separated by 2048 primes, so that there are 1024 primes of overlap. We will do some math with each group.
Take the second prime, subtract it from the first prime. This gives you the first number in a new sequence. Then take the third prime, subtract it from the second prime, giving you the second number. Continue doing this through all 3072 primes. This procedure is called the adjacent difference.
Now take the absolute values of this sequence. You don't have to do this really, because all the numbers are positive right now  but that will change.
Go back to the start and take the adjacent difference of your sequence again. Then take he absolute value. Then the adjacent difference. Keep going. After a while, you will realize that all your numbers have become zeroes and twos.
You are done with the first group. Now take your second group of 3072 primes, and repeat. There are over 200 thousand groups in this first chunk of 500 million primes.
You finish your first chunk. Out of all the groups, what is the most repeats of adjacent difference and absolute value you had to take before everything became 0s and 2s? Let's call this value the "chunk maximum"
Now move on to your second chunk. And the third. And so on. The final goal is to process 10 million chunks (up to the number 10^17), containing an aggregate total of over 2600 trillion primes.
Now ask yourself, at any point in time, what is the most difficult group of primes you have seen before? In all the groups in all chunks which you have processed, which group took the most iterations of adjacent difference and absolute value? Let's call this value the "global maximum"
In the plot below, the blue line is a smoothed plot of the chunk maximum. The green line is the global maximum. On the x axis is the chunk number. As you can see, I'm not too close to the ultimate goal of 10 million yet. Then again, I've only been running my code for about a day.

what is the significance of this?

Ok some recent stuff from my master project
A small script I wrote to determine the size of Sr atomic cloud from photos of its flourescence
(http://i.imgur.com/jbzPt7w.png)
A bit from another script I wrote that simulates the physics in the cloud inside a cavity and magnetooptical trap, and applying a Rabi pulse. This predicts the fraction that would be excited by different pulse durations (starting at 100 µs)
(http://i.imgur.com/woNgJKD.png)
The script can make sims with different experimental parameters to maximize the flash intensity or number of excited atoms. Here's an example of max excited fraction with different combinations of the waist sizes of the Rabi laser pulse
(http://i.imgur.com/i2CdnIm.png)
It takes into account temperature, magnetic field, cloud shape (gaussian but can be elongated along axes), seed and Rabi laser power, number of atoms, and uhh, lots of other things.
Bachelor students did some experiments in the lab and I hacked their results to compare with my simulation. However all this was from when we weren't very sure on the cloud size, temperature and stuff. The bachelor students worked on measuring temperature but I don't have their results yet.
(http://i.imgur.com/RmnC4EG.png)

cute.
what is the significance of this?
well basically there's this conjecture which says that if you keep taking the absolute adjacent differences of the prime numbers (this will give you a bunch of sequences), the first number of each sequence is always 1.
an more efficient way of testing this is, at the nth iteration of this absolute adjacent difference, all the numbers (besides the first one of course) are 0 and 2. if this is the case up to the kth number in this sequence, you can be sure that the 1st number in the next k absolute adjacent differences is a 1 (convince yourself this is true by working it out on a piece of paper)
now instead of computing the adjacent difference all at once, i compute it in groups. think about this for a minute and it should be clear why the groups of primes i described above need to overlap. now it should also be clear what the significance of that plot is  it's the number of iterations each group needs to go through
the amount of memory on the streaming multiprocessors i'm running this on is very small (32KB). therefore, i can only fit around 3072 primes on the each multiprocessor at once. i have an overlap of 1024 primes, which means i can do up to 1024 iterations without any problems. this may become problematic if there is some group which requires more than 1024 iterations, but we can fix this by making the overlap larger, say 1536, at the cost of computational efficiency

ok well i redid that plot again... big surprise

just found out google uses 2 space indents instead of 4
i could never work for them now.

2 space indents are fine

Kol 2 space sounds nice if you have a lot of loops. Coding Map War and some other stuff I got tired of all the code ending up in a small spot on the right

2 space indents are fine
no
Kol 2 space sounds nice if you have a lot of loops. Coding Map War and some other stuff I got tired of all the code ending up in a small spot on the right
right but if you have proper coding style, you should never have more than a nesting depth of 45 (and that's pushing it), which is only like 1/4th of your column if you follow the 80 character/row rule

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '179459'.

well spaces are bad yes
but you can set tab width

I'm using PyQt to make a gui to control the magnetooptical trap (and a new one we're gonna build) for my master project, keep thinking this is a Yqt conspiracy because 1) PyQt and 2) coding

i'd like to magnetooptical trap bla in a small green box as well

so i wrote some code to plot my time
numbers are in hours per week
code is pretty messy, only reason i'm posting it is cause this is the coding thread
let me tell you getting the plot to look as good as it does now was not very easy at all
i basically had to do everything from scratch

dIslam

i'd dlslam you if you know what i mean

ai learning to play from pixels
(that is, it does not have any access to the game state, and is not told the objective or mechanics of the game)

Kolkute

does it have to guess the controls too

it knows there are 9 controls but not what they do ( it has to learn that)

Breaking news: A user on USF called 'vh' is reported missing after developing an AI that's supposed to learn how to play a game. Rumors say the AI took control of a robot factory to recreate the game irl and abducted vh, forcing him to complete the track over and over while detecting his movements.

100 pareto optimal elytra flight trajectories over the course of 13 seconds, optimized for distance and altitude
you have the choice between traveling 300 meters and increasing your altitude by 30, or traveling 600 meters and decreasing your altitude by 210, or anything in between!
i'm hoping the chart is pretty selfexplanatory. on the x is distance, on the y is altitude relative to initial point. i put a point on each line every 10 ticks (0.5 seconds) for convenience

oh right since this is the coding thread i better post the code too

Verycute

attempt at using a deep net to generate music.
i'll let you guys judge for yourself

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '180271'.

wtf that's freaky

That's actually really cool tbh
Anyways I've really taken a liking to being a JS dev. Here's code snippets for the same functions, one in the Java API the other in the Node API.
Java:
Customer cu = Customer.retrieve({CUSTOMER_ID});
Map<String, Object> updateParams = new HashMap<String, Object>();
updateParams.put("description", {NEW_DESCRIPTION});
...
cu.update(updateParams);
Node:
stripe.customers.update({CUSTOMER_ID}, {
description: {NEW_DESCRIPTION},
...
});
Here's Python:
cu = stripe.Customer.retrieve({CUSTOMER_ID})
cu.description = {NEW_DESCRIPTION}
...
cu.save()
the language is freaking ridiculous idk how I survived for years using it
(also don't think about it too much, this example just has shitty java implementation, it could in theory be almost the same as the python implementation)

hmm i promise it sounds much better this time around

wrote some code to do more fine grained plotting of my time usage. each pie chart is a single week.
weeks arranged left to right first, and then top to bottom next (just like reading text guys)
this semester has pretty much exactly 16 weeks, which makes everything come out really nicely
https://drive.google.com/uc?export=view&id=0B6XNpALRcpv9TUYwV2ZQQkVxUFU
(https://drive.google.com/uc?export=view&id=0B6XNpALRcpv9TUYwV2ZQQkVxUFU)
warning: massive image

Access denied

fixed link hopefully
direct linking to images from gdrive is made, for some reason, really difficult

i gave my neural network the bottom img and it made the one on top
(https://i.imgur.com/GyHgqUk.png)

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '180595'.

oh you silly filly!

silly filly
we 2011 now

Kol wow

syule, give your neural network this image:
http://i.imgur.com/7NjCVGg.png

not gonna do that because nothing cool is going to come out. the picture i posted was a combination of careful hand tuning and a lot of luck.

today in "really weird python functions":
>>> 'hello world'.title()
'Hello World'
come on guys was that really a necessary language feature?

I still don't get how I didn't mess up several times when typing in the second order dt terms and it didn't mess up my simulation to give e^308 photons. Now time to write the second order terms that include the extra laser pulse
Nop I haven't efficientized the math yet. I'm not even sure it's gonna be more efficient with the 2nd order terms than just making the time step lower and run the same amount of time. Obviously slows down the simulation a lot
(http://i.imgur.com/qL1RG81.png)

o man dat subexpression elimination waiting to happen

script to generate false color GOES16 imagery
(http://i.imgur.com/3vsilmP.jpg)
(DATETIME will need to be modified cause the server i use only keeps like the past 24 hours of data)

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '181002'.

have some messy code that does this
(https://i.gyazo.com/c5ab080d0b63b211ff2b535dda8c441a.png)
(https://i.gyazo.com/07ffa09e2f711c8cd9be25d86e93cc5c.png)

waves and cyclones now have intensities
and waves have to form into cyclones
(https://i.gyazo.com/2429d809bd1d36f90c797eeed6f022cd.png)
oh yeah, and there's land now
requires numpy, matplotlib, netCDF4, and this dataset (http://ftp://ftp.cdc.noaa.gov/Datasets/noaa.oisst.v2/sst.mnmean.nc) from here (https://www.esrl.noaa.gov/psd/data/gridded/data.noaa.oisst.v2.html)

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '181091'.

uh i'm not sure if i'll make a pavala version in full, but soleani cyclone center will feature the amalthean region at least
edit: some updates
(https://i.gyazo.com/1e23d7f8b9dbadae1e276257e05fbbb5.png)
(https://i.gyazo.com/e90c797092b91cf1d08784cc5dc76175.png)
the second one has a feature where if a cyclone is moving south quickly it weakens... cause it should
and fun fact, 15 epac storms with 5 atl storms in the months of july and august seems weird right but last year it was 13 and 4 (and the sim used last year's sst's so...)

goond

new update moves the ridges and troughs based on month so now you can run full seasons (and even years, although i haven't tested full years yet)
i did this 6 month run from june to november of 2012 and got
(https://i.gyazo.com/0b63f4aa18e5c1bfb8f26be6afccc4db.png)
 sim  irl 
EPAC  1782  17105 
ATL  1941  19102 
where in XYZ
X is the number of tropical storms
Y is the number of hurricanes
Z is the number of major hurricanes (category 3 or higher)
so i am legit impressed at my own creation
also the color scheme i'm using:
white  tropical depression
yellow  tropical storm
yelloworange  severe tropical storm
orange  hurricane (cat 1 or 2)
red  major hurricane (cat 3 or 4)
purple  cat 5 hurricane

[07:54] Kalassak WEW
[07:54] Kalassak it runs so much quicker now
[07:54] Kalassak BLESS SYULE GOD FROM THE HEAVENS
(https://i.gyazo.com/0d312983ceca590692edeb6139872cba.png)
a two month sim like that used to take 9 minutes now it takes like 2.5 or less
and the pressure field calculations went from like 1 second to .001 seconds so that's great, now i just have to optimize the graphics time

recorded in 1080p60 cause i can
https://www.youtube.com/watch?v=1ZbHdFGfQZk
watch a computer figure out how to swing this heavy pendulum into a vertical position.
the radial arrow indicates the direction and magnitude of torque applied.
this is super interesting: the algorithm decides it can't apply enough force to swing the pendulum into vertical position in one go, so instead, it pushes the pendulum up most of the way in one direction, then lets it fall and reach the top from the other direction!
none of this strategy is hardcoded of course  the algorithm "discovers" it. the only thing the algorithm is given is a sandbox/simulator pendulum, where it can do arbitrary things to the pendulum and see what happens.

(https://imgur.com/DTGAlVyl.png)
no code this time but here's the architecture of the code which runs blacraft. it probably totals to between 500 and 2000 loc.
edit: actually 642 nonblank lines, as computed by this great bash command i just wrote:
find L .  grep py$  xargs cat  sed '/^\s*$/d'  wc l
blue boxes are external (such as irc, amazon web services, and blacraft's cloud server)
yellow boxes are pieces of code which sit on my computer
the right side is pretty simple  we have the irc interface which parses and validates all irc lines and sends commands / forwards messages from the UBV box. the irc interface should also reconnect in case of time out or related issues, but that part of the code is untested. ubv handles the logic of handling irc commands, which right now is pretty simple  it just passes them on to the coordinator on the top
on the left side, we have the aws interface, which talks to both the server and also aws. it does so through a bunch of different ways  ssh connections, directly pinging the spigot server, and making requests to AWS to start up and shut down the machine. the aws interface provides all of the primitives such as acquiring a machine, shutting down a machine, or running the spigot jar on the server.
on top of that, we have the server controller, which assembles these primitives into a small number of commands, such as server startup, server shutdown, query population, etc. it has to take care of stuff such as : the ssh server on the blacraft machine doesn't boot up instantly, so even after the machine is up, you need to wait the right about of time. it also has to robustly handle errors and timing issues, so spamming server on and server off won't cause the interface to go haywire (yes the aws interface is rather fragile). huge potential for race conditions in this box that i had to be careful about
then, on top of that, we have the coordinator, which talks to both UBV and the server controller. the coordinator has the job of passing commands from ubv to the server controller, as well as passing messages (such as the success of the startup command), back over to UBV so we on irc will be able to know when the server is up. it uh also doubles as the main object which initializes everything, both the server controller and also ubv, which may or may not be bad design practice.
so yeah there you have it

Impressive

figured out how to put text on images today
(https://i.imgur.com/INxuksC.png)

second image: a picture of how the chair looks
first image: how the chair looks when melted (an attempted 3d reconstruction of the chair)
third image: how the chair is supposed to look from all those angles
basically i'm computing a 3d model of a chair based off of one picture
using brainz i mean ai i mean neural nitwerks

Note bade

have you tried increasing the layers of neurons

sYnThEsIzEd ChAiR
yeah this needs improving

1. input image
2. sYnThEsIzEd ChAiR (yeah it's missing the legs)

1. input image
2. generated 3d model

i wrote a nifty utility function which basically takes a container object (list, dictionary, or tuple), and strips all the actual content out of it, replacing all the values with None
def iscontainer(obj):
return isinstance(obj, list) or isinstance(obj, dict) or isinstance(obj, tuple)
def strip_container(container):
assert iscontainer(container), 'not a container'
if isinstance(container, list) or isinstance(container, tuple):
return [(strip_container(obj) if iscontainer(obj) else None)
for obj in container]
else:
return {k: (strip_container(v) if iscontainer(v) else None)
for (k,v) in container.items()}
so if you have dictionaries and lists and nested dictionaries and lists containing a bunch of big strings and numbers and class instances, this replaces all those bottom level entries with None values, which makes it really easy to read the "outline" of a complicated "data structure"
for example, here's what it looks like when i apply it to some code i'm debugging:
{'gt': {'depths': None,
'masks': None,
'pose': None,
'view': None,
'views': None},
'pred': {'flow': {'pred_flow': None, 'pred_view': None},
'par': {'preds': {'depth': None,
'dx': None,
'dy': None,
'mask': None,
'view': None},
'reproj': {'body': {'depth': None,
'mask': None,
'view': None},
'view': {'depth': None,
'mask': None,
'view': None}}}}}
if i hadn't used this function, all of those None values would've printed with huge numpy arrays which would've made it impossible to read

a mysterious memory leak  a very slow one too, about 1gb per hour
vertical: memory used in GB
horizontal: iteration number

Mysterious. Imo it helps to close the window, when it's windy the memory tends to blow out

this plot of a stripped down version of the code suggests that maybe the memory leak levels out after a few GB and stops

the following images are plots of how many milliseconds are used to process each chunk. in order to run at 20 tps, the server cannot spend more than 50ms on all currently loaded chunks.
the following are maps of 100x100 chunk areas, or 800m by 800m
leftmost: synthetically generated lag map by me. brighter means more ms used to process chunk
rightmost: naive estimates of the chunk lag by simply diving 1000.0 by the tps
middle: my algorithm for estimating the chunk lag
things the algo can deal with
 the fact that tps is averaged over the last minute, during which you could've moved a lot
 multiple players simultaneously loading many chunks
 in the first image, there is a single chunk which takes 100ms to process. in the second image, there are 20 chunks, each which has 40ms of processing time. note that by itself, the server could still operate at 20tps  so it's only when two of these chunks are loaded that the tps lag happens. yet, my algorithm can still locate which chunks caused the lag
actually the multiple player support is in theory  haven't implemented it yet. but don't fear. i'm about to implement it.

so here's a demonstration of multiplayer lag computations
so first look at the right most plot. there are two horizontal lines  one top on bottom, which shows the paths taken by the two players.
for about 1h of irl time, the top player moves right across the map, while the bottom player stays in the bottom left corner.
then in the next 1h of irl time, the top player moves left across the map, while the bottom player moves right. they do this at the same speed so that they cross in the middle
as shown by the leftmost ground truth lagmap, there is only one laggy chunk, which is in the middle of the top player's path. however, the naive "observation based" strategy would get confused and think that the bottom player is also responsible for the lag, due low tps observed when the bottom player is in the middle.
on the other hand, my algo pretty much pinpoints the lag just in the top player's path. note that there's a lot of vertical spread to the prediction, since both players are moving horizontally, and it's impossible to tell which chunk out of the 21 chunks in the vertical column was the lag causer without some vertical movement.

wrote a long rambly thing about my OO approach to DL

in each of these images, one row was generated by a neural network and the other one is human generated

I made a Darvince IRC Markov chain bot
import json
import markovify
import socket
import random
import time
server = "irc.freenode.net" # Server
channel = "##universesandbox" # Channel
botnick = "BotVince" # Your bots nick
print("Opening Brainfile")
corpus = open("darvincelines.txt").read()
print("Converting Brainfile to json")
text_model = markovify.Text(corpus, state_size=3)
model_json = text_model.to_json()
print("Success")
reconstituted_model = markovify.Text.from_json(model_json)
def ping(): # Respond to server pings
ircsock.send("PONG :pingis\n")
def joinchan(chan): # Join a channel
ircsock.send("JOIN "+ chan +"\n")
ircsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ircsock.connect((server, 6667)) # Here we connect to the server using the port 6667
ircsock.send("USER "+ botnick +" "+ botnick +" "+ botnick +" :Jister  A bot made by Jorster on USF\n") # user authentication
ircsock.send("NICK "+ botnick +"\n") # here we actually assign the nick to the bot
joinchan(channel) # Join the channel using the functions we previously defined
while 1: # Be careful with these! it might send you to an infinite loop
ircmsg = ircsock.recv(2048) # receive data from the server
ircmsg = ircmsg.strip('\n\r') # removing any unnecessary linebreaks.
ircmsg = ircmsg.lower() # Converting to lowercase for easier finding of kol
print(ircmsg) # Here we print what's coming from the server
if ircmsg.find("ping :") != 1: # If the server pings us then we've got to respond!
ping()
if ircmsg.find("##universesandbox") != 1: # Make sure we're getting a message from the irc channel
if ircmsg.find("darvince") != 1:
if random.randint(1,10) == 1:
try:
markov = str(reconstituted_model.make_short_sentence(340))
except:
try:
markov = str(reconstituted_model.make_short_sentence(340))
except:
try:
markov = str(reconstituted_model.make_short_sentence(340))
except:
markov = "markov failed yell at jorster"
ircsock.send("PRIVMSG " + channel + " :" + markov + "\n")
if ircmsg.find("!dar") != 1:
print("!dar found")
try:
markov = str(reconstituted_model.make_short_sentence(340))
except:
try:
markov = str(reconstituted_model.make_short_sentence(340))
except:
try:
markov = str(reconstituted_model.make_short_sentence(340))
except:
markov = "markov failed yell at jorster"
print(markov)
ircsock.send("PRIVMSG " + channel + " :" + markov + "\n")
It was a fun experiment in markov chains and irc bots

some thoughts on a next gen irc bot
gen 0: old old ubv, using some weirdass bespoke key word search i made up. could repeat previously said text. actually was quite coherent
gen 1: trigram model (old ubv and current jister). attention span of 2 words max.
gen 2: standard lstm model with single line attention span. would also expect much lower perplexity than trigrams
gen 3: both a line and paragraph lstm model, where the paragraph level lstm model produces some context vector which is fed in to the line lstm. this would allow bot to have a long attention span
gen 4: gen 3 + pointer networks attention mechanism, which would be very useful for irc, due to the limited amount of training data.
gen 5: gen 4 + gan loss, cause why not.
references
thought vectors: https://arxiv.org/abs/1506.06726
pointer networks: https://arxiv.org/abs/1506.03134
seqgan: https://arxiv.org/abs/1609.05473

(https://i.imgur.com/SElRhQz.png)
xaxis: log2(hours i think some task will take)
yaxis: log2(hours it actually took)
performed gaussian process regression. inner blue region is 1 std, outer blue region is 2 stds
red points are actual tasks from my collected dataset slightly jittered so you can see overlapping points. note that the majority of tasks i predict as taking 0.5, 1, or 2 hours. note the incredible spread of times taken for "1 hour" tasks  predicting time is hard.
although it's not visible from this plot  gaussian processes can model heteroskedastic trends  so if i became really accurate at predicting tasks which took less than 1 hour but really bad at tasks which took more, then the predictive intervals would vary in thickness along the horizontal axis

welp
i might've mostly used someone elses code as a template and this picture may have been really easy and i might've only had 3 letters to pick from and i might've used the simplest machine learning algo in existance but:

in each of these images, one row was generated by a neural network and the other one is human generated
i wonder how it would look if you asked the human brain to generate the numbers instead of the human hand

(a quick note: paladinofstorms.net/cyclone == tropicalcyclonedata.net, the folder is literally the same)
dae have any idea what's going on
[07:17] Kalassak http://paladinofstorms.net/cyclone/adv/view.php
[07:17] Jister title: Tropical Cyclone Tracking Data: page 1
[07:17] Kalassak http://tropicalcyclonedata.net/adv/view.php
[07:17] Jister title: Tropical Cyclone Tracking Data: page 1
[07:20] Darvince the second one has no CSS
[07:20] Darvince for some reason
[07:20] Kalassak yeah
[07:21] Kalassak i can't figure that one out
[07:21] Kalassak interesting
[07:21] Kalassak if i link to http://paladinofstorms.net/cyclone/adv/tables.css
[07:21] Jister type: text/css, size: 624 bytes
[07:21] Kalassak it works
[07:21] Kalassak but
[07:22] Kalassak why can't i just link to tables.css
[07:22] Kalassak it's in the same
[07:22] Kalassak fucking
[07:22] Kalassak folder
[07:23] Kalassak yeah
[07:23] Kalassak the link
[07:23] Kalassak <a href="search.php">
[07:23] Kalassak takes you to search.php
[07:23] Kalassak which is in the same folder
[07:23] Kalassak that works
[07:23] Kalassak why doesn't <link rel="stylesheet" type="text/css" href="tables.css" />
[07:23] Kalassak take you to tables.css
[07:23] Kalassak which is in the same folder
[07:24] Kalassak https://i.gyazo.com/0dd62a22a8f61600400bc2297ed38aa3.png
[07:24] Kalassak wow look at that
[07:24] Kalassak they're in the same folder
[07:25] Kalassak <link rel="stylesheet" type="text/css" href="http://tropicalcyclonedata.net/adv/tables.css" />
[07:25] Kalassak doesn't work
[07:25] Kalassak http://tropicalcyclonedata.net/adv/tables.css look what's here
[07:25] Jister type: text/css, size: 624 bytes
[07:25] Kalassak the fucking file
[07:26] Kalassak i guess we'll use the way that works
[07:26] Kalassak since it works
[07:26] Kalassak by linking to paladinofstorms
[07:26] Kalassak which makes no fucking sense

this time, with proper h e t e r o s k e d a s t i c i t y
and no, it's not a linear trend, it just looks like it (cause it's pretty close)
(https://i.imgur.com/KVFwiNf.png)

it's good to have a simple "dump this object to disk" and "read this file as an object" function in every programming language, so here's mine for java
public class Database <T extends Serializable> {
private final String filename;
public Database(String filename) {
this.filename = filename;
}
public void save(T obj) {
try {
FileOutputStream fos = new FileOutputStream(filename);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(obj);
oos.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public T read() {
File f = new File(filename);
if(!f.exists()  f.isDirectory()) {
return null;
}
T obj = null;
try {
FileInputStream fis = new FileInputStream(filename);
ObjectInputStream ois = new ObjectInputStream(fis);
@SuppressWarnings("unchecked")
T tmp = (T) ois.readObject();
obj = tmp;
ois.close();
fis.close();
} catch (IOException e) {
e.printStackTrace();
} catch(ClassNotFoundException e) {
e.printStackTrace();
}
return obj;
}
}
in python pickling is builtin. why can't you be more like python, java

here's my famously complex backup script which i run once whenever i remember and upload to dropbox
cat /dev/sda3  gpg symmetric output backup.gpg
i should probably back up the entire /dev/sda while i'm at it, since my boot sector is in /dev/sda4. it's not technically important but it would be a pain to have to set that up again
i did consider compression before encryption but note that
1. there are attacks that exploit compressing data before you encrypt it  so you have to be very careful
2. most of my drive either contains many small files which take up little space and are not worth compressing, and a small number of large files  usually binary data, images, or videos  all of which have either already been compressed using image/video compression algs which would do better than any general purpose compression  or in the case of binary data files, probably cannot be compressed much, if at all. so i suspect compressing wouldn't actually shrink the size of the backup

public class Database <T extends Serializable> {
private final String filename;
public Database(String filename) {
this.filename = filename;
}
public void save(T obj) {
try {
FileOutputStream fos = new FileOutputStream(filename);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(obj);
oos.close();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public T read() {
File f = new File(filename);
if(!f.exists()  f.isDirectory()) {
return null;
}
T obj = null;
try {
FileInputStream fis = new FileInputStream(filename);
ObjectInputStream ois = new ObjectInputStream(fis);
@SuppressWarnings("unchecked")
T tmp = (T) ois.readObject();
obj = tmp;
ois.close();
fis.close();
} catch (IOException e) {
e.printStackTrace();
} catch(ClassNotFoundException e) {
e.printStackTrace();
}
return obj;
}
}
cat /dev/sda3  gpg symmetric output backup.gpg
wut

thinking about how resources should be allocated on a cluster. specifically gpu resources
proposal: users use an artificial currency to buy or sell gpu time on an open market.
1. every user gets a baseline number of gpuhours (GPUH) per hour/day. the reason we hand out GPUH directly instead of handing out credits is because it avoids the need for the sysadmins to act as a market maker.
2. by default, users have a recurring sell order which sells their GPUH for dirt cheap on an open exchange. users can remove this order and configure their own buy/sell orders at will.
3. obviously you need credits to buy GPUH on the market. the nth user starts off by being given 1/n of the credits on the market, which is collected by the admins using some form of taxation (maybe tax stored credits at 1%/day, or tax transactions with a 1% fee). but the overall monetary supply is constant.
4. whenever the computing resources increase (a new node with gpus added to the cluster), all users get a bonus paycheck to spend
5. in times of little activity, everyone will be selling their GPUH on the market, and the price will drop. before a paper deadline, when everyone wants GPUH, the prices will skyrocket. this is reasonable and efficient behaviour, rewarding users who make the effort to help everyone out by using GPUs when they are least needed.
6. of course, users are not obligated to participate in the market at all, since they may simply use their own GPU hours as they would otherwise.
7. want to do some long term planning? need to run an experiment for 1 week and don't want to be surprised by GPUH price spikes? no problem. introducing the GPUH futures markets, where you can lock in GPUH at a fixed price ahead of time.
The Major Issue
despite the fact that GPUH is an asset which allows gpu access on the cluster, it can't possibly guarantee access on the cluster (consider, for example, the case where all 50 users decide to spend their GPUH at once on a cluster with only 40 gpus).
there seems to be a lot of ad hoc tricks you can do here (perhaps the admins can buy back GPUH at a high price to prevent the server from being oversubscribed), or maybe something like firstcomefirstserve could work, but all those seem like sloppy, fragile fixes, stemming from the fact that theses GPUH are not *pinned* to a time slot

8. Pinned GPU hours (PGPUH)
in this scenario, instead of there just being one asset (GPUH), a new type of asset is created hourly. so if there are 100 users and 10 gpus, then a user will get 0.1 of a march18th5am GPU hour, 0.1 of a march18th6am GPU hour, and so on.
obviously users will want to sell their GPU unless they want to run an experiment, in which case they'd spend enough money to buy one full PGPUH (out of 10 available). because each time slot is a different asset, you don't run into oversubscription problems
9. if you want to run a 48h experiment, it's pretty bad to have to scramble to buy 1 full PGPUH every hour, or risk getting your experiment be terminated. when running an experiment, you'll want to buy a block of GPU allocations. this can be fairly easily automated
10. the GPU hogging problem.
suppose 90% of your users are inactive, but also disabled the autosell order. how do you cope with the fact that 90% of your PGPUH are being distributed to users who aren't participating in the market and no one else can use their PGPUH?
one answer: automatically sell PGPUH after 3 days of inactivity or something
another answer: raise the amount of PGPUH distributed by the server so that GPUs may be oversubscribed in theory, but rarely so in practice
11. the user interface
ok all this market nonsense is pretty complicated to the end user, who usually wants nothing more than the ability to compute things without trouble. so we've got to automate it somehow...
first, let's say that PGPUH are distributed maybe 2 months ahead of time, with the assumption that no one wants to plan their experiments down to the hour more than 2 months ahead of time.
second, to allow for ability of people to plan ahead, an automatic sell order for all PGPUHs is issued by every user. so for example, if PGPUH on april 3 is worth 3 credits historically, a sell order will be automatically issued for that.
third, users can buy blocks of PGPUH ahead of time. so if you plan on running experiments in 3 days, you can run a script which will automatically issue an order for that.
finally, a user who doesn't want to participate in any of this nonsense (mainly point 3), can just run their GPUs at any time, and purchase unused PGPUH at runtime at the current market value. this is basically how the current system works, except instead of being able to do this forever, you have to be able to afford it of course, which is more fair.
12. if everything is taken care of automatically, how will accurate pricing be done? for example, if everyone wants to use GPUs simultaneously, and 80 of 100 users have sold their 0.1 PGPUH for the hour, leaving 2 free GPUs, will the pricing actually go up? what if only 1 out of 100 users want to use a gpu for the hour. will the price of the next PGPUH fall to near 0, as expected of an efficient system? of course this is true in a real market with traders, but we are trying to automate most of it so researchers don't have to waste their time.
answer: each user will have a customizable hardsell price, where if GPU prices reach a certain level, they are willing to kill their currently running experiments and sell their GPUH to another user. this will make it so that you can almost always get a gpu by paying enough
answer: a reasonable hardcoded autosell order based on remaining gpu capacity and historical data will further result in reasonable prices. users can customize this too
answer: as an hour starts, the value of a PGPUH gradually decreases to 0. so the autoseller takes care of things, by adjusting the autosell price to be able to consistently sell of unused PGPUH a good fraction of the time. this should converge to a level where if only one user wants a GPU, all the autosellers would be willing to sell for pretty cheap.
a

what if 3 users want to share 2 gpus  a worked example
suppose there are 3 users, A, B, and C, each starts with 10 credits, and owns 0.7, 0.7, and 0.6 of the next PGPUh. and suppose they all want to run a job at 5 pm today. what happens?
well first suppose the historical price is 1 credit per PGPUH, which means there are already 3 autosell orders on the market for 0.7, 0.7, and 0.6 credits. furthermore, suppose A, B, and C have their hardsell price at 2, 5, and 8 credits resp, so they're willing to sell their PGPUH no matter what for 1.4, 3.5, and 4.8 credits resp.
then, suppose A, B, and C are willing to pay 1, 1.5, and 2 credits to run the job in that one hour block.
so here's the order book, ordered by the issue date
1. A: sell @ 2, all
2. B: sell @ 5, all
3. C: sell @ 8, all
4. A: sell @ 1, amount 0.7
5. B: sell @ 1, amount 0.7
6. C: sell @ 1, amount 0.6
 (below: didn't happen yet) 
7. A: buy @ 1, amount 0.3
8. B: buy @ 1.5, amount 0.3
9. C: buy @ 2, amount 0.4
when order 7 comes out, that cancels order 4, and suppose A buys from B, so the book looks like this
1. A: sell @ 2, all
2. B: sell @ 5, all
3. C: sell @ 8, all
5. B: sell @ 1, amount 0.4
6. C: sell @ 1, amount 0.6
 (below: didn't happen yet) 
8. B: buy @ 1.5, amount 0.6
9. C: buy @ 2, amount 0.4
now A has 1 PGPUH in the bank and 9.7 credits, and B has 0.4 PGPUH and 10.3. B adjusts order amount up from 0.3 to 0.6, cause it needs to buy more now.
next B executes. i don't know how exchanges actually do this, but i'll go with the convention that the trade price is determined by the first order, so C sells at 1 instead of 1.5, leaving us with
1. A: sell @ 2, all
2. B: sell @ 5, all
3. C: sell @ 8, all
 (below: didn't happen yet) 
9. C: buy @ 2, amount 1
B has now 1 PGPUH and 9.4 credits as well, and C has 10.6 credits
note that order 3 and 6 was cancelled, since C can't sell anymore, and C adjusted it's order amount
next, C buys from A, which basically clears the book.
2. B: sell @ 5, all
3. C: sell @ 8, all
Now A has 0 PGPUH and 11.7 credits, B has 1 PGPUH and 10.3 credits, C has 1 PGPUH and 8.6 credits, so GPUs were properly allocated.
but wait, what if C's order went first. let's rewind a bit...
1. A: sell @ 2, all
2. B: sell @ 5, all
3. C: sell @ 8, all
5. B: sell @ 1, amount 0.4
6. C: sell @ 1, amount 0.6
 (below: didn't happen yet) 
8. C: buy @ 2, amount 0.4
9. B: buy @ 1.5, amount 0.6
C fills B's order
1. A: sell @ 2, all
2. B: sell @ 5, all
3. C: sell @ 8, all
 (below: didn't happen yet) 
9. B: buy @ 1.5, amount 1
C ends up with 1 PGPUH and spends 0.4, B now has 10.7 credits
Now A has 1 PGPUH and 9.7 credits, B has 0 PGPUH and 10.7 credits, C has 1 PGPUH and 9.6 credits, again we have success

huh, organizing classes in OOP is actually pretty similar to solving a kcut problem, using semantics as a heuristic
https://en.wikipedia.org/wiki/Minimum_kcut

so i had the sin and cosine of an angle, and i wanted to add perturb that angle by some delta value. so i looked up some sin / cos addition identities on wikipedia. here's the code.
sin_delta = tf.sin(delta)
cos_delta = tf.cos(delta)
#from wikipedia
#sin(α + β) = sin α cos β + cos α sin β
#cos(α + β) = cos α cos β  sin α sin β.
sin = sin * cos_delta + cos * sin_delta
cos = cos * cos_delta  sin * sin_delta
can you spot the bug?

you are recalculating sine before calculating the cosine
mess

gj. i was printing out sin^2 + cos^2 and getting confused about why it wasn't 1

decided to test out some numerical integrators here. using a very simple spring motion a(x) = x
first compare euler to "semiimplicit euler" to leapfrog. euler and semiimplicit euler are first order while leapfrog is second order (supposedly better). semiimplicit and leapfrog are symplectic (good) and euler isn't symplectic.
so first, euler vs sisuler vs leapfrog, time steps of 0.1:
(https://i.imgur.com/I9rTL8Y.png)
so euler goes crazy pretty fast and the other two are so close to each other you almost can't tell the difference and you definitely can't tell which one is better.
so then i unironically named a function "make_god" which basically modifies an integrator into a god integrator which secretly does 100 steps at 1/100th the delta t but only reports the results from the last step. so there's a god euler (really god si euler) and a god leapfrog integrator. i made two gods just incase dividing the timestep by 100 didn't actually make them sufficiently accurate and there would still be errors. i also ramped the timesteps up to 0.5 from 0.1
(https://i.imgur.com/dHE7KV0.png)
so just starting out, both the gods are in such close agreement with each other you can't even see the orange line. it looks like in terms of the amplitude of the oscillations, leapfrog wins over sieuler.
(https://i.imgur.com/ppdyMkB.png)
very interestingly, the error accumulates in the form of precession for both sieuler and leapfrog, and the amount of precession is the same for both. after doing some quick google searches, this is supposed to be the mode of failure for symplectic integrators: they conserve a quantity which is almost energy, so obviously the error comes from elsewhere (aka phase error)
conclusion: hypothesis was confirmed that leapfrog > si euler > euler
note that the popular RK4 integrator is not symplectic and would probably blow up like the euler integrator over sufficiently long timespans, so i didn't bother trying to implement it, which is a pain anyway
question: wait a second, i just read the wikipedia page and si euler is identical to leapfrog and the only difference is that one of them has the velocity offset by half a timestep. so are they the same integrator?
answer: as far as i can tell, pretty much. the initial starting configuration i used was x = 1, v = 1, so the si euler integrator is actually equivalent to the leapfrog integrator with starting configuration x = 1, v_1/2dt = 1. notice this has slightly less total energy, since at time 0, velocity would be slightly less than 1, corresponding to the lesser amplitude.
so yeah, if i just initialized the sieuler configuration with slightly more energy it'd be identical to the leapfrog method, which makes me wonder why leapfrog is second order and si euler is first order.
code attached

hm, but then i came up with another devious scheme to compare leapfrog and si euler. this time the spring force is nonlinear: a(x) = sign(x) * x**2 (basically the typical x but quadratic)
this is apparently a substantially more difficult problem and i had to turn the time steps back down to 0.1 or else even the gods started diverging.
(https://i.imgur.com/ETA3Rjo.png)
ok so clearly si euler is messing up. let's zoom in
(https://i.imgur.com/OgnWLc0.png)
veeery interesting. this definitively shows the superiority of leapfrog over si euler

based on playing around with that integrator i found some bugs in my old gravity sim code
so here's it with everything fixed: a one million body gravity simulation, where each point mass is an entire galaxy, played back at 5 quadrillion times real time
https://youtu.be/pUGAGZvvMpk
edit: eww youtube compression artifacts

when is now?

near the end, seeing as the simulation starts near the beginning of the universe and runs for 16 billion years
the area of the simulation is about 6 millionths of the observable universe (assuming it was 2d)

Wow

playing around with sounds  pretty messy code i whipped up in 5 minutes just to try it out. sample attached.

is that a univision entry in the making i hear?

lmao maybe. technically if i put enough work into it, i could generate sounds as varied as anything you can get out of professional software. i was thinking of doing some xenakis type stuff

wow is ponyreiter going to be making new avant garde music

NERD

i ain't no nerd i'm a MUI nerd

>calling someone a nerd on an astronomical simulation program forum

so for some strange reason, no one has ever produced a robust and performant clustering algorithm for unbalanced clusters on python yet... so i had to implement my own
gt.png: the ground truth clusters. the green cluster contains 99% of all the points
scikit.png: using the standard "k means" algorithm
kc.png: using a kcenters algorithm i made up on the spot
none of scikitlearn's algorithms can really solve this task  at least not any of the reasonably fast and well known algorithms anyway. my implementation in tensorflow runs about 20x faster than kmeans by scikitlearn AND it actually solves the task.
the algorithm is pretty simple: initialize k centers using the well known 2apx solution. then iteratively optimize the centers a la lloyd's algorithm for k means.

i have just written the most useful piece of python code ever
def iscollection(obj):
return isinstance(obj, list) or isinstance(obj, dict) or isinstance(obj, tuple)
def apply_recursively(collection, f):
def dict_valmap(g, dct):
return {k:g(v) for (k,v) in dct.items()}
def f_prime(x):
if iscollection(x):
return apply_recursively(x, f)
else:
return f(x)
if not iscollection(collection):
return f(collection)
else:
map_fn = dict_valmap if isinstance(collection, dict) else map
return type(collection)(map_fn(f_prime, collection))

i coded a ray tracer. two sample images with glass on metal

Cool

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '195326'.

Nice

Good

Like

Thumbsup

Subscribed

my emailssentpermonth plot has gotten more advanced
new features include formatted dates on the x axis, which was surprisingly difficult
and also an endofmonth projection for the current month, in red
(http://i.imgur.com/YHkx0L2.png)

i can't tell if the colors make this more insightful or just more confusing
green = summer break
turqoise = fall semester
purple = spring semester
(http://i.imgur.com/pCEzHrE.png)

a minimal cuda project  it's always annoying to have to remember how to set these up, which is why i've done so right here.
(https://i.imgur.com/peyaKdY.png)

i labeled my axes and have a legend so you should be able to figure out what this plot is of
for konisshi <> spawntown, which lies at roughly (1000, 100) on this graph, it's close to a tie between overworld elytra, nether elytra, and nether ice roads. however since spawntown nether hub is quite clunky, i think overworld elytra ends up being significantly faster
for konisshi <> laplaya, which lies at maybe (4000, 1000) on this graph, nether elytra clearly wins.
for konisshi <> yqtland, which i have no idea how far it is let's say it's at (300, 1000) on this graph, overworld elytra wins
konisshi <> darvincia happens like 5 times a year, so let's say (3000, 10), so nether elytra and overworld elytra are pretty close
if for some reason i went from worldcorner to worldcorner twice a day for a year, that would be about (22000, 1000), that would be a legit reason to build a nether ice boat route
and finally to get from one end of my storage to the other end, 40 blocks away, and something i do constantly, beacon sprinting is the fastest, as expected
factors this graph takes into account
1. how long it takes to build the infrastructure for a given mode of transport, which consists of a onetimecost plus a costpermeter
2. how long it takes to use infrastructure, which includes a pertripcost (such as the 10 seconds you pay to go through two portals) as well as a perdistance cost
3. the "efficiency" of a method  ice boat has less than 1 efficiency since it's hard to make turns. elytra in nether also has < 1 efficiency due to the fact that paths aren't perfectly straight.

Interesting, though it's missing all our glorious rail lines

they didn't show up because they are strictly worse than elytra. maybe when mojang puts high speed rail back in the game

ubv now supports SASL, a method of authentication which allows ubv to be hosted at ip addresses which are othrewise blacklisted by freenode
here's the relevant bits of code, which are definitely not guaranteed to be correct but it works for me
def initialize(self):
self.send("CAP REQ :sasl")
self.send('NICK %s' % conf.NICK)
self.send('USER %s %s %s: Hello World' % (conf.NICK, conf.NICK, conf.NICK))
while u"ACK :sasl" not in self.receive():
pass
self.send("AUTHENTICATE PLAIN")
while u"AUTHENTICATE +" not in self.receive():
pass
key = '%s\0%s\0%s' % (conf.NICK, conf.NICK, conf.SASL_PW)
auth_msg = bytes('AUTHENTICATE '+base64.b64encode(key.encode('utf8').decode('utf8'))+'\n')
print 'sending', auth_msg
self.s.send(auth_msg)
while u"authentication successful" not in self.receive():
pass
self.send("CAP END")
self.send('JOIN %s' % conf.CHANNEL)
the reason this is important is that i'll be moving around for the next few months and my desktop is unlikely to be reliably on, so ubv is now hosted on another aws instance but wait you say doesn't it kind of defeat the point of having blacraft on a temporarily hosted aws instance if you're putting ubv on a permanently hosted instance? well no, because ubv runs on the lightest instance possible, with 487M of ram and something like 1/10th of a cpu core

coding a sea surface temperature simulator so that i can have some inputs for wrf that make sense on pavala, as sea surface temperatures play a huge part of atmospheric forcing and simulating pavala with pavalan land and earth sea surface temperatures provides a worthless result, basically
it doesn't really simulate radiation or advection very well so it's just a shallow water simulation right now, that means there isn't like a sea surface temperature variable being advected around, hence the uniformly colored light blue background
i'm really amazed that with a simple initialization of a symmetric low height ("pressure", kinda) region about the equator you get slow westward propagation of a rossby wave and fast eastward propagation of a kelvin wave
we've been learning about equatorial waves in my tropical meteorology class so it's really cool to see that with basically 3 equations i can see them in action... and like... i made them!
currently wrapping only works going from the eastern hemisphere to the west (so that the kelvin wave can go around), so when the rossby wave reaches the western boundary toward the end of the run it creates weird artifacts
you also get to see the model break down and do weird stuff and i'm not entirely sure what that's all about, but the main important thing to see is that the kelvin wave makes it around the planet almost 1.5 times in the same time (20 days) the rossby wave only goes about halfway, which is about what you would expect.
https://www.youtube.com/watch?v=hlv_D14T14
contours are height/layer depth, arrows are flow in the layer

seems like this would make for a fun computation/graphics project
https://en.wikipedia.org/wiki/Kuramoto_model#/media/File:Spatial_synchronization_patterns_in_variants_of_the_Kuramoto_Model.png

coding challenge: write an algorithm that determines if a sigmar's garden game (from opus magnum) is solvable, and if so, then solve it

so i've been doing some lagbusting on blacraft
first i measured tps while loading various sets of chunks in blacraft, making 36 measurements, each covering a different subset of 28 predefined "subregions".
(https://media.discordapp.net/attachments/255420814114029568/567599138015805458/unknown.png)
then the mspt (milliseconds per tick) is described by mspt = Ax + noise, and the cost is mspt  Ax
i used l1 norm (laplacian noise model) because the measurement error is probably pretty heavy tailed
A is the matrix of coefficients which contains information on which subregions were loaded for each measurement
there are some more details and details, such as the fact that mspt under 50 is not measurable, mspt is always positive, etc, which i took into account
after optimizing the cost, this is what i get
each row is a separate measurement
column 1: the cost associated with this measurement
column 2: the expected mspt for this measurement
column 3: the actual mspt for this measurement
column 4: the error in mspt
column 5/6: the expected and actual tps
anyway if you compare the predicted and actual results they're actually pretty close  under 0.5 tps error in almost all cases, which i'm sure is less than my measurement error
[[ 0.49 50. 50. 0. 20. 20. ]
[ 12.603 136.241 125. 11.241 7.34 8. ]
[ 1.64 58.201 57.143 1.058 17.182 17.5 ]
[ 0.691 62.434 62.5 0.066 16.017 16. ]
[ 1.328 70.809 71.429 0.62 14.123 14. ]
[ 10.701 73.366 83.333 9.967 13.63 12. ]
[ 1.191 70.947 71.429 0.481 14.095 14. ]
[ 0.564 51.333 51.282 0.051 19.481 19.5 ]
[ 0.465 50. 50. 0. 20. 20. ]
[ 2.578 50. 52.083 2.083 20. 19.2 ]
[ 2.741 72.054 74.074 2.02 13.879 13.5 ]
[ 2.867 60.235 62.5 2.265 16.602 16. ]
[ 9.116 68.492 76.923 8.431 14.6 13. ]
[ 0.804 53.788 54.054 0.267 18.592 18.5 ]
[ 0.431 50. 50. 0. 20. 20. ]
[ 1.606 52.89 51.813 1.077 18.907 19.3 ]
[ 1.216 51.935 52.632 0.696 19.255 19. ]
[ 7.083 80.354 74.074 6.279 12.445 13.5 ]
[ 0.074 50. 50. 0. 20. 20. ]
[ 1.606 94.578 95.238 0.66 10.573 10.5 ]
[ 0.165 50. 50. 0. 20. 20. ]
[ 0.208 50. 50. 0. 20. 20. ]
[ 0.543 50. 50.251 0.251 20. 19.9 ]
[ 2.949 50. 52.632 2.632 20. 19. ]
[ 1.575 50. 51.282 1.282 20. 19.5 ]
[ 0.097 50. 50. 0. 20. 20. ]
[ 0.049 50. 50. 0. 20. 20. ]
[ 0.078 50. 50. 0. 20. 20. ]
[ 1.586 50. 51.282 1.282 20. 19.5 ]
[ 0.186 50. 50. 0. 20. 20. ]
[ 0.52 50. 50.251 0.251 20. 19.9 ]
[ 0.121 50. 50. 0. 20. 20. ]
[ 0.014 50. 50. 0. 20. 20. ]
[ 0.112 50. 50. 0. 20. 20. ]
[ 0.103 50. 50. 0. 20. 20. ]
[ 0.638 50. 50.251 0.251 20. 19.9 ]]
this also gives the mspt cost of each subregion  remember each measurement consists of a set of subregions, so this is a decomposition of where that cost comes from
[ 1.193 9.595 33.261 6.168 5.874 5.641 0.187 0. 0.374 3.268
13.511 0.61 0.007 0.012 0.634 4.804 4.96 1.652 2.778 0.001
15.503 3.059 3.746 0.574 0.703 6.552 12.687 6.248]
the first 4 subregions are in order
1. 441 chunks in the end void
2. spawntown spawn chunks
3. 21x21 chunk region in spawntown minus spawn chunks (a donut shape)
4. 500ish chunks of random terrain
and the rest of the subregions are actually a grid pattern over konisshi, which was the main target of this exercise. each of the rest of the subregions are pretty much 5x5 chunks of konisshi.
you can see that all of konisshi adds up to almost 94 mspt, which is pretty hefty. spawntown by comparison is a lightweight 43 mspt (although i'm comparing 540 chunks of konisshi to 289 of spawntown here)
i've attached a plot of these subregions in the correct geographic orientation, and you can see most of the lag is concentrated in a few of these subregions (yellower is laggier)
also attached code, which contains the Greatest List Comphrenension of All Time
measurement_regions = [
[item for sublist in [subregion_map[x] for x in region] for item in sublist]
for region in measurement_regions
]

i am coding optics sim
(https://cdn.discordapp.com/attachments/255420814114029568/593647955081297940/unknown.png)
how does it work? basically it's a limited form of raytracing in 2D, where i use newton raphson to compute the intersection between arbitrary differentiable surfaces (lens surfaces) and rays. i know the ordering of the lens components, so i can just process them sequentially.
here i show light passing through an aspherical lens with a refractive index of 2 (really the "lens" is just composed of two separate surfaces, the first with a refraction *ratio* of 2 and the second 0.5.) and then hitting a plane.
code is complete hacky garbage btw

(https://cdn.discordapp.com/attachments/255420814114029568/594073052434792472/unknown.png)
today's OPTIK sim upgrades include
1. refactoring the code completely so it's guud and ez to work with instead of hacky
2. adding in an aperture object which blocks out of bound light rays
3. refining the plotting

thats pretty cool

this is an excellent dialogue between man and nature. thank you for providing this informatical stimulus to us.

thats pretty cool
thank
this is an excellent dialogue between man and nature. thank you for providing this informatical stimulus to us.
Oh! Oh! I know why!
(https://cdn.discordapp.com/attachments/255420814114029568/594415459567140866/unknown.png)
(https://cdn.discordapp.com/attachments/255420814114029568/594393342532648979/unknown.png)
3 updates today
1. code for automatically generating light sources which point in the right direction (aka into the lenses) so that it's less painful to set up simulations
2. some trickery with adaptive newton raphson step sizes, so for this simulation with 9 surfaces and roughly 1k rays the time went from 250ms down to 18ms, and with increased precision too
3. most importantly, rays have wavelength, plotting converts wavelength to rgb!!!, AND sellmeier dispersion is implemented, resulting in physically accurate chromatic aberration

simulate light rays reflecting inside a raindrop to create a rainbow

(https://cdn.discordapp.com/attachments/255420814114029568/595124394930733067/unknown.png)
TODAY on optik sim we have a few more upgrades
1. native support for geometric planes. previously i'd only implemented a class of spherical surfaces with quadratic and quartic asphericities. this very general class of surfaces includes a simple plane of course, but also is computationally much more expensive.
2. with the help of blazing fast planar geometry from [1], i implemented autofocus  a search algorithm used to move the camera sensor back and forth to minimize the variance of where rays hit on the sensor. the main importance of this is that i can start designing optical systems without having to painfully manually focus the setup
3. my previous experiments with chromatic aberration used a made up material with ridiculous dispersion parameters, because chromatic aberrations are actually generally quite small and hard to see. but now, i've reverted back to using typical borosilicate glass, and i've upgraded the plotting code to show super zoomed in views of exactly where each light source hits the sensor (so even small aberrations are visible)!

(https://cdn.discordapp.com/attachments/255420814114029568/595510473584279611/unknown.png)
TODAY ok optik sim we have a huge image  seriously, this thing is almost 5k by 5k, and i rendered this at half of full res just to make uploading less painful.
1. i set up a standard set of test cases for testing lenses: there are objects at 3 different distances, and 3 different angles relative to the camera, making for 9 objects. i focus the lens to the same 3 different distances, which gives me 27 triplets of (angle, distance, focus point).
2. i wrote code to plot all of this nonsense. i also added code to plot a coarser version of the light (visible in the big 3 subplots on the left), since i think it's useful to be able to see exactly how the rays travel through the system.
3. i fixed some numerical problems with the ray tracing math
interpreting the plot:
first, mentally break down the plot into 3 chunks on the vertical axis, with each chunk containing a big plot of the entire system and 9 small plots on the right.
the 3 chunks correspond to the 3 focus distances: in the first vertical chunk, the camera is focused to the closest object (0.5 m), in the second vertical chunk, 5m, and the third, 100m.
for each focus distance, i simulate how light from all 9 objects travel through the lens. however, in order to keep the figure readable, in the left subplots, i visualize only the 3 lights which are located at the same distance which the lens is focused on.
ON the right 9 subplots, i do visualize how all 9 objects look like as they hit the sensor. each COLUMN of the 9 subplots corresponds to a different distance: the 3 objects at 0.5m, the 3 at 5m, the 3 at 100m. each ROW of the 9 subplots corresponds to a different angle.
so to make this clear: in the first chunk, i would expect the middle row of the first col to be the sharpest, because that's what i'm focusing on. i would still hope that the other rows of the first col are pretty sharp. finally, i don't expect the second and third cols (objects at 5 and 100m away) to be sharp. likewise, in the second chunk, i would expect the middle row of the Second col to be sharp, etc.
each of the 9 small subplots covers an area of 1mm x 1mm. on a typical camera, there are probably somewhere in the ballpark of 50 pixels / mm. so you can see this made up lens is pretty shit because even the best focused points of light (i call them objects but they're really point light sources), are spread out over like 10px
anyway i feel like almost all of the setup is now complete and i can start designing lenses soon

ALSO if you're wondering why the right plots have color but the left rays are white, it's because on the left, you're zoomed out enough that the R, G, and B rays blend together into white!, however if you zoom in enough, even on the left you can see slight chromatic aberrations leading to colors

today we have some Real World Optics.
(https://cdn.discordapp.com/attachments/255420814114029568/596251774730502155/unknown.png)
(https://cdn.discordapp.com/attachments/255420814114029568/596251868481716236/unknown.png)
i generated a picture of a checkerboard, took a bunch of pictures with my phone. then i used it to jointly optimize homographies and distortion parameters of my phone's camera lens
(https://cdn.discordapp.com/attachments/255420814114029568/596251859782729740/unknown.png)
this is a picture of some perfectly horizontal stripes i found on google images
left: a photo i took of my monitor of those stripes
right: same photo, but corrected for lens distortion

can we get a subtraction (or other diff) between the two pics

This message is only viewable with Universe Sandbox Galaxy Edition. Access it and much more with promocode '232475'.

This is, to give a dog and in recompense desire my dog again.

(https://cdn.discordapp.com/attachments/255420814114029568/615777656712986625/unknown.png)
new drizzle experiment
bottom right = high res image of a 2d signal
top left = a simulated image of that signal, where the imaging sensor is 21 x 21 px
going from top left to bottom right, the other images are 10, 100, and 1000 images taken with *the same low res sensor*, but drizzled into a high resolution map. the imaging sensor is jittered with random 1 px translation and random 0.05 radian rotation each time.
i think it's fairly cool to see exactly how much detail can be retrieved even with such a low res sensor. presumably some sort of deconvolution can be applied to undo the blurring caused by finite sized photosites here.

interestong
why isn't this technique used more
(maybe it is already used quite a bit in some fields, i wouldn't know)

afaik it was actually invented for processing Hubble images, where the resolution of the optics exceeds the resolution of the sensor

(https://cdn.discordapp.com/attachments/255420814114029568/616162702196211712/unknown.png)
zoom to see detail... but basically this is the above drizzling technique applied to superres a scene i took 20 images of.
right is the original, left is drizzled
still a bunch of artifacts because it's not quite perfected yet. also both images have a weird tint because i haven't figured out how to apply color correction / calibration yet

I'm pretty sure there's a threshold for the input image quality right? Like at what point would there not be enough detail to make a reasonably detailed drizzled image?
Also isn't this photooptimizing technique, or a technique like this, used for security camera snapshots? I know you see the stuff in movies but it's a real thing right? (Or for like license plates)

ENHANCE

That was the word I was trying to remember mess

I'm pretty sure there's a threshold for the input image quality right? Like at what point would there not be enough detail to make a reasonably detailed drizzled image?
Also isn't this photooptimizing technique, or a technique like this, used for security camera snapshots? I know you see the stuff in movies but it's a real thing right? (Or for like license plates)
well it's not magic. basically there are two bottlenecks (well there are many, but relevant to us) to capturing more details: the quality of the optics in the camera, and the resolution of the sensor.
if sensor resolution is the bottleneck  say each photosite on the camera sensor is 1 mm across, then by shifting the camera exactly 0.5mm and taking another photo, you're basically doubling the resolution of the sensor. and mathematically you can take advantage of that.
of course optics is still a limiting factor, so you can't get infinite superres this way.

today we have an optiksim update!!!!
previously we had this
today i wrote a massive amount of code in order to implement fully automated gay luxury gay space lens design. ok not really, but it was very tricky to get right. and i'm kind of surprised it works at all. and the result is that instead of hand designing lenses, i have an optimization algorithm to do it for me. it is fairly amazing
before optimization
(https://cdn.discordapp.com/attachments/255420814114029568/630320678754582559/unknown.png)
after optimization
(https://cdn.discordapp.com/attachments/255420814114029568/630319956927578112/unknown.png)
observe compared to my previous lens design the sharpness at all angles, instead of only directly in the middle of the image.
the design is inspired by the zeiss protar, considered to be the first modern photographic lens
(https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/ZeissProtartext.svg/1920pxZeissProtartext.svg.png)
my original lens was pretty much completely unusable. my new optimized lens has an average "sharpness" of 0.37mm (the plots on the right are 1mm^2. a modern camera's photosites are about 0.005mm across. so i have a long ways to go. but i calculated it and this lens should be able to generate sharp images up to 200 by 200 px!!!

tmc's game against <the machine>
https://lichess.org/N5vtK3S9#0

high res gcmap project (click to embiggen)
(https://cdn.discordapp.com/attachments/255420814114029568/635555488322551829/unknown.png)

code

owo wats this
(https://cdn.discordapp.com/attachments/640679696891117568/736421103106392114/unknown.png)

i finally hashed out all the issues with my gravity code (which has to take into account periodic boundary conditions and forces)
2^24 ~ 17 million particles > i can run one timestep per 41 seconds (order 4 chebyshev) or 30 seconds (using order 2)
2^22 ~ 4 million particles > one timestep every 7 seconds
2^20 ~ 1 million particles > one timestep every 4 seconds (not really efficient)
(https://cdn.discordapp.com/attachments/640679696891117568/736447317485420614/unknown.png)
next steps are probably
1. figuring out how to draw 17 million objects, cause matplotlib sure isn't going to like it
2. figure out all the right constants so my simulation doesn't blow up
3. running the damn thing

universe sandbox 4 is coming along nicely

That sounds like good performance. About drawing I worked on a simulation once where I used a 2d histogram counting particles within a column and using a density scale which worked well compared to plotting individual particles and I think it was faster

my previous gravity sim was in real world SI/metric units and all that, but this time around, i decided to work in "simulation units", which i call ud, ut, and um (unit distance, unit time, unit mass). so every object in my simulation has mass 1 um, each time step is 1 ut, and the entire simulation fits in a box of size 1 ud by 1 ud.
then (in theory, haven't tested this yet), the only thing i have to change about my sim is to convert the gravitational constant from metric units to sim units.
ud_over_m = size
ut_over_s = timestep
um_over_kg = (density*size**2) / nbodies
gravity_u = gravity * (um_over_kg * ut_over_s**2) / ud_over_m**3
which comes out to roughly 4e16 right now
high school "dimensional analysis" practice really came in handy here
the only tricky point is that i'm trying to simulate cosmological expansion as well, which means that the size of my universe is NOT constant, but since the size of my sim world is constant, this means ud_over_m and therefore the gravitational constant itself is... not constant

(https://cdn.discordapp.com/attachments/640679696891117568/736619904282656778/unknown.png)
1024 objects initialized on a 32x32 grid  you can actually see the starting configuration pretty clearly

(https://cdn.discordapp.com/attachments/640679696891117568/736744714279321671/unknown.png)

steamboat

code steamboat so you can see it before you die

silly me didn't realize until today that the hubble constant isn't constant
y axis: scalefactor of the simulation, 1 being roughly "size at current time"
x axis: time, in 100petaseconds
so the growth of the universe is indeed closer to linear than exponential (what i thought it was before)
(https://cdn.discordapp.com/attachments/640679696891117568/738867974194200746/unknown.png)
this could explain why my results didn't make sense

so i realized what i was doing wrong finally, (in this and months of months of previous attempts). long story short, i wasn't using the correct initial conditions. i managed to track down some lecture notes and papers on how people actually go about setting up the initial conditions of these simulations, and i didn't understand any of the math, and a bunch of the math that i even tried to implement gives bogus results. so i ended up just getting some sort of approximation which doesn't actually use the math (bad), but visually looks about right.
(https://cdn.discordapp.com/attachments/640679696891117568/739197580231049336/unknown.png)
it's so pretty

wow the warmhot intergalactic medium

today... practicing some time series analysis by grabbing some of my co2 ppm data.
to keep the challenge reasonable, i selected a subset of the data, 3 weeks long, where i didn't leave my apartment for any trips (this was surprisingly hard to find). i used the first 2 weeks to develop my prediction model, then verified the model on the last week of data.
i first averaged the data in 15minute groups, just to cut down on the computation load by a factor of 15.
the data exhibits both daily and also weekly patterns, which i factored out in the data preprocessing stages (only to invert the transformation later, of course)
finally, i found it unnecessary to detrend the data
(light blue on the left 2 weeks is my input data)
(https://cdn.discordapp.com/attachments/640679696891117568/749689053141794866/unknown.png)
both a KPSS and ADF test suggested that the data was already quite stationary without any differencing, so i just threw it into an ARIMA model with a grid search (50 experiments) over pdq parameters with corrected aic as the criteria, and i found that (1,0,4) was the optimal parameters
finally, i ran the forecast prodecure (which quickly regressed to the mean, as expected, since the default stance to take when predicting far into the future is to regress to the mean). i also simulated 100 trajectories from the ARIMA model in order to quickly visualize the credible bounds of my forecast
the final results are shown, with dark blue being the actual observed data, yellow being the forecasted PPM (although, as mentioned previously, this quickly regresses to the seasonal means after about a day), and red being the 100 simulated futures. all in all, the forecast seems decent, as the ground truth trajectory rarely deviates from the credible intervals
(https://cdn.discordapp.com/attachments/640679696891117568/749690138514161705/unknown.png)
the onestep prediction (generally not a very useful indication of forecast ability, as it only measures accuracy of forecasting a single step in the future (aka 15 minutes)) had an RMSE of 12.9 ppm, compared to the naive strategy (always predicting the last seen value) at 20.45, and the seasonaltrendfollowing strategy at 14.0 ppm.

import numpy as np
from ipdb import set_trace as st
from glob import glob
import imageio as ii
from tqdm.contrib import tzip
from PIL import Image
mmap = lambda f, xs: list(map(f, xs))
zoom_level = 0
zoom = 2**zoom_level
files = glob('flat/**/*.jpg')
if zoom_level > 0:
files = [x for x in files if '/'+(u'z'*zoom_level)+u'_' in x]
else:
files = [x for x in files if '/z' not in x]
def loc(tilename):
stuff = tilename.split('/')[1].split('.jpg')[0].split('_')
x, y = stuff[2:]
return (int(y),int(x))
ys, xs = zip(*mmap(loc, files))
ys = np.array(ys) #negative because... convention
xs = np.array(xs)
TILESIZE=128
mult = np.int64(TILESIZE / 2**zoom)
xs = (xsxs.min())*mult
ys = (ysys.min())*mult
H = ys.max()+TILESIZE
W = xs.max()+TILESIZE
canvas = np.zeros((H,W,3), dtype = np.uint8)
for tile, x, y in tzip(files, xs, ys):
canvas[y:y+TILESIZE, x:x+TILESIZE] = ii.imread(tile)
im = Image.fromarray(canvas)
del canvas
im = np.array(im.resize(size=np.array(im.size)//zoom, resample=Image.BICUBIC))
ii.imwrite('out.jpg', im, quality=93)
code for fusing dynmap tiles into a world map  this was easier than i expected
output
https://cdn.discordapp.com/attachments/471578400725663745/780148630899130388/out.jpg

Is so big!

you should be glad i've already downsized it in the code, the max dynmap zoom level we have is 4x4 pixels per block, so the "original" image is like 65k by 65k pixels