Page 1 of 1

Mine circle pathing code

Posted: 2009.10.11 (02:14)
by Yoshimo

Code: Select all

def circler(x, y, mines, velocity, radius):
   m = mines
   v = velocity
   r = radius
   d = 360.0/m
   m = 360.0/m
   i = 0
   while d <= 360.000:
      if i == 0:
         s = ['!12^', str(x), ',', str(y), '^^^,7,0,', str(v), ',', str(d), ',', str(r)]
         s = "".join(s)
         i = 1
         d += d
      else:
         a = ['!12^', str(x), ',', str(y), '^^^,7,0,', str(v), ',', str(d), ',', str(r)]
         a = "".join(a)
         s += a
         i += 1
         d += m
   s = ''.join(s)
   print(s)
For use with Python 3.1. Took about 2 hours.

If you for some reason don't have Python 3.1, just contact me on IRC and I'll provide what you need.

EXAMPLE
EXAMPL2
Mines generated by Python.

Re: Mine circle pathing code

Posted: 2009.10.11 (02:23)
by T3chno
That is so cool.

Nice job Bio.

Re: Mine circle pathing code

Posted: 2009.10.11 (02:47)
by Yoshimo
Something slightly playable:
Also, new code bit if you're really picky about what needs to be where, plus explaination.

Code: Select all

def circler(x, y, mines, velocity, radius, offset):
   m = mines
   o = offset
   v = velocity
   r = radius
   d = 360.0/m
   m = 360.0/m
   i = 0
   while d <= (360.000+o):
      if i == 0:
         s = ['!12^', str(x), ',', str(y), '^^^,7,0,', str(v), ',', str(d+o), ',', str(r)]
         s = "".join(s)
         i = 1
         d += d
      else:
         a = ['!12^', str(x), ',', str(y), '^^^,7,0,', str(v), ',', str(d+o), ',', str(r)]
         a = "".join(a)
         s += a
         d += m
   s = ''.join(s)
   print(s)
Note that this was way painful to write on it's lonesome, explaining will be harder then balls. (which, on second thought, isn't very hard at all. -_- )

Code: Select all

def circler(x, y, mines, velocity, radius, offset):
This line is the magick maker. This defines what you're going to do, and tells you what parameters to put in. 'x, y' are the centre's coords, 'mines' is how many mines you want in the circle, 'velocity' is how fast the mines rotate, 'radius' is the circles radius, distance between any mine and what you put for 'x, y', to clarify it's importance. 'offset' can be 0 most of the time, but if you want the degree of the mines offset just a little, put how many degree's you want in for this.

Code: Select all

m = mines
   o = offset
   v = velocity
   r = radius
   d = 360.0/m
   m = 360.0/m
   i = 0
Turns long variables into short ones, and sets 'i' to equal one. 'i' is what tells Pthon to go to the initiating 'mine string', the foundation of the rest of the mines.
Take a look at the fifth and sixth lines. -->>{{((These tell the degrees between each mine.))}}<<-- the .0 in '360.0' tells Python to make it a float instead of an int, for much greater percision.

Code: Select all

while d <= (360.000+o):
Tells python to continue making more mines while the circle is not complete. 'd' will equal '360+o' when all the mines are in place.

Code: Select all

s = ['!12^', str(x), ',', str(y), '^^^,7,0,', str(v), ',', str(d+o), ',', str(r)]
God, this will be hard to explain. This line gave me so much trauma.

Tells Python that 's' a large assortment of shit that will be combined into the code of one circle-pathed mine. Lemme break it down.
'!12^' is what the base of a mines code in N is, right? It won't make a mine without this bit.
'str(x), ',', str(y)' will take the integers or floats you should have put for x and y into the coords for the mines centre. the "','," puts a comma inbetween the two coordinates, makeing it one coord in 2d.
'^^^,7,0,' says that the mine will have circle pathing. The , at the end of the string helps us avoid needing another ',',, shortening the code slightly. Trivial, but meh.
'str(v)' is the speed of the mine's circling, 'str(d+o)' is where the mine should be, the degrees plus the offset, 'str(r)' is the radius.

Code: Select all

s = "".join(s)
's' is just an assortment of seperated strings right now, this turns it into one large string, the code for one mine.

Code: Select all

 i = 1
         d += d
Says that 'i' equals 1, shutting off this part of the script until 'i' equals 0 again, which doesn't happen in our script.
'd += d' says that 'd' know equals d*2, the next degree increment, making it so there aren't a ton of rotating mines all in one spot.

Code: Select all

else:
If our 'if i == 0:' statement isn't true, we go here.

Code: Select all

 a = ['!12^', str(x), ',', str(y), '^^^,7,0,', str(v), ',', str(d), ',', str(r)]
What we had before, except instead having 's' equal all that shit, 'a' does now. 's' is our base, saying that 's' equals ruins everything we just did, and makes it so we can't have anything more.

Code: Select all

a = ''.join(a)
s += a
Turns 'a' into a code for a single circling mine, and adds it on too our base, 's'. See how we'd be screwed over in the last line if we said 's = [...]' instead of 'a = [...]'?

Code: Select all

d += m
We made two seperate variables equal the same thing in the beginning, 'm' and 'd'. If we kept going with 'd += d', we'd get something along the lines of 'd*2*2*2*2*2*2*2' after a while. Not good. 'm' never changes, except for the beginning, so we use it to add on to 'd', creating a new degree for the mine to start in.

Code: Select all

s = ''.join(s)
   print(s)
Joins 's' into one überstring, what we put in Nreality to make the mines circle, and then prints it out for us to see.

Whew, that took about 30 minutes to explain. =\[/spoiler]

Re: Mine circle pathing code

Posted: 2009.10.11 (04:39)
by squibbles
Bio, <3

Re: Mine circle pathing code

Posted: 2009.10.11 (06:45)
by sidke
Cool beans, Bio.

Re: Mine circle pathing code

Posted: 2009.10.11 (16:08)
by Yoshimo
Latest rendition allows for more versatility, letting you make mine, gold, bblocks, guasses, and player, although player doesn't really go well with circle path. =[

Code: Select all

def circler(x, y, number_of, velocity, radius, offset, objID):
   m = number_of
   o = offset
   v = velocity
   j = objID
   r = radius
   d = 360.0/m
   m = 360.0/m
   i = 0
   while d <= (360.000+o):
      if i == 0:
         s = ['!', str(j), '^', str(x), ',', str(y), '^^^,7,0,', str(v), ',', str(d+o), ',', str(r)]
         s = "".join(s)
         i = 1
         d += d
      else:
         a = ['!', str(j), '^', str(x), ',', str(y), '^^^,7,0,', str(v), ',', str(d+o), ',', str(r)]
         a = "".join(a)
         s += a
         d += m
   s = ''.join(s)
   print(s)

Re: Mine circle pathing code

Posted: 2009.10.11 (16:53)
by Rhekatou
It just puts a million mines in one spot =(

Re: Mine circle pathing code

Posted: 2009.10.11 (17:52)
by Yoshimo
Rhekatou wrote:It just puts a million mines in one spot =(
I'm quite sure you're using it wrong. Tell me what you input.

Re: Mine circle pathing code

Posted: 2009.11.16 (02:17)
by n0_ma11y
I am absoulutely clueless about any of this.

Re: Mine circle pathing code

Posted: 2009.12.18 (02:26)
by Rhekatou
BionicCryonic wrote:
Rhekatou wrote:It just puts a million mines in one spot =(
I'm quite sure you're using it wrong. Tell me what you input.
Your examples one and two.

Re: Mine circle pathing code

Posted: 2010.01.02 (04:08)
by Nexx
Rhekatou wrote:
BionicCryonic wrote:
Rhekatou wrote:It just puts a million mines in one spot =(
I'm quite sure you're using it wrong. Tell me what you input.
Your examples one and two.
It's NReality code, Rhekatou.

And cool beans, Bio, though my comp is too lame to handle it, especially the gold/bounceblock one.