Welcome, Guest

Author Topic: Coding  (Read 184413 times)

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: Python
« Reply #240 on: July 06, 2013, 10:16:36 AM »
i got an error message

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #241 on: July 06, 2013, 10:27:53 AM »
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 2013-3-4-2004.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
« Last Edit: July 06, 2013, 10:34:36 AM by vh »

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: Python
« Reply #242 on: July 06, 2013, 07:13:44 PM »
no pil

atomic7732

  • Global Moderator
  • *****
  • Posts: 3829
  • caught in the river turning blue
    • Paladin of Storms
Re: Python
« Reply #243 on: July 08, 2013, 08:47:05 PM »
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

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: Python
« Reply #244 on: July 09, 2013, 04:17:20 AM »
i need a program that clicks every 30-45 seconds, and it has to be random. by click i mean like a left click

Darvince

  • *****
  • Posts: 1837
  • 差不多
Re: Python
« Reply #245 on: July 09, 2013, 04:25:43 AM »
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.

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: Python
« Reply #246 on: July 09, 2013, 04:30:38 AM »
well fuck i'll test it on another account

atomic7732

  • Global Moderator
  • *****
  • Posts: 3829
  • caught in the river turning blue
    • Paladin of Storms
Re: Python
« Reply #247 on: July 09, 2013, 12:43:35 PM »
how did they even know he had a bot, or did they?

and how could they tell if it clicked at random?

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #248 on: July 13, 2013, 09:46:22 AM »
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
Code: [Select]
>>>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

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #249 on: July 13, 2013, 10:16:40 AM »
protip #2:

representing the number 1 as a '64-bit big-endian integer' just means

00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000001


argghh terminology

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #250 on: July 15, 2013, 01:19:43 AM »
item copying tip:

Code: [Select]
>>>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
Code: [Select]
e = list(g)
or
Code: [Select]
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,
Code: [Select]
import copy
e = copy.deepcopy(g)

atomic7732

  • Global Moderator
  • *****
  • Posts: 3829
  • caught in the river turning blue
    • Paladin of Storms
Re: Python
« Reply #251 on: July 25, 2013, 12:04:10 AM »
I was messing around with PIL (Python Image Library) and created a simple image based on random colors.

Code: [Select]
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)
« Last Edit: July 25, 2013, 12:19:39 AM by atomic7732 »

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #252 on: July 25, 2013, 04:13:01 AM »
huh pretty

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Python
« Reply #253 on: July 25, 2013, 05:20:11 AM »
Nice, could be adapted to generate planetary ring textures maybe? Or maybe textures for gas giants.

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #254 on: July 25, 2013, 07:49:47 AM »
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.

atomic7732

  • Global Moderator
  • *****
  • Posts: 3829
  • caught in the river turning blue
    • Paladin of Storms
Re: Python
« Reply #255 on: July 26, 2013, 04:37:56 PM »
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

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #256 on: July 26, 2013, 05:51:38 PM »
what do you mean by coastline data? images of coastline?

atomic7732

  • Global Moderator
  • *****
  • Posts: 3829
  • caught in the river turning blue
    • Paladin of Storms
Re: Python
« Reply #257 on: July 26, 2013, 06:47:52 PM »
like

numbers

latitude and longitude

locations

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #258 on: July 26, 2013, 07:34:34 PM »
of what? every point on the coastline?

atomic7732

  • Global Moderator
  • *****
  • Posts: 3829
  • caught in the river turning blue
    • Paladin of Storms
Re: Python
« Reply #259 on: July 26, 2013, 09:11:13 PM »
yes

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #260 on: August 10, 2013, 12:24:17 AM »
tkinter documentation is surprisingly sparse. here's an alpha version of URANCO (uranium enrichment company simulator)
« Last Edit: August 10, 2013, 12:29:09 AM by vh »

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #261 on: September 09, 2013, 02:45:28 PM »
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.

matty406

  • *****
  • Posts: 82
Re: Python
« Reply #262 on: September 12, 2013, 04:58:48 AM »
what is this

Darvince

  • *****
  • Posts: 1837
  • 差不多
Re: Python
« Reply #263 on: September 12, 2013, 10:42:45 AM »
pyGCM = python Global Climate Simulator.

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: Python
« Reply #264 on: September 21, 2013, 09:22:52 AM »
my first python program done :)

Darvince

  • *****
  • Posts: 1837
  • 差不多
Re: Python
« Reply #265 on: September 21, 2013, 12:27:48 PM »
i was expecting it to be tkinter and nothing else

Darvince

  • *****
  • Posts: 1837
  • 差不多
Re: Python
« Reply #266 on: September 22, 2013, 01:03:44 AM »
global climate model

atomic7732

  • Global Moderator
  • *****
  • Posts: 3829
  • caught in the river turning blue
    • Paladin of Storms
Re: Python
« Reply #267 on: September 22, 2013, 02:02:49 AM »
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 pressure-gradient force. My ocean model only takes into account coriolis and a sine wave approximation of winds.
« Last Edit: September 22, 2013, 02:17:09 AM by atomic7732 »

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #268 on: September 22, 2013, 06:05:37 AM »
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

atomic7732

  • Global Moderator
  • *****
  • Posts: 3829
  • caught in the river turning blue
    • Paladin of Storms
Re: Python
« Reply #269 on: September 22, 2013, 10:32:18 AM »
if calc1 > 0 and calc1 <= 1:
                newgrid[r-1][c-1].append(calc1*cell.t)
            if calc8 > 0 and calc8 <= 1:
                newgrid[r][c-1].append(calc8*cell.t)

it likes the first one but errors the other?