Mine circle pathing code

Talk about Unreality's Dronie winning N 1.4 mod, NReality, here!
User avatar
The 700 Club
Posts: 744
Joined: 2008.10.17 (00:28)
NUMA Profile: http://nmaps.net/user/BionicCryonic
Location: Lethal Lava Land

Postby Yoshimo » 2009.10.11 (02:14)

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.
spoiler

Image
Image


User avatar
Cross-Galactic Train Conducter
Posts: 2354
Joined: 2008.09.27 (00:31)
NUMA Profile: http://nmaps.net/user/T3chno
MBTI Type: ENTJ
Location: foam hands
Contact:

Postby T3chno » 2009.10.11 (02:23)

That is so cool.

Nice job Bio.
Image

User avatar
The 700 Club
Posts: 744
Joined: 2008.10.17 (00:28)
NUMA Profile: http://nmaps.net/user/BionicCryonic
Location: Lethal Lava Land

Postby Yoshimo » 2009.10.11 (02:47)

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]
spoiler

Image
Image


User avatar
Demon Fisherman
Posts: 1246
Joined: 2008.10.01 (23:37)
NUMA Profile: http://nmaps.net/squibbles
MBTI Type: ENFP
Location: Canberra

Postby squibbles » 2009.10.11 (04:39)

Bio, <3
spoiler

Nmaps.net

Tsukatu wrote:I don't know what it is, squibbles, but my brain keeps inserting "black" into random parts of your posts these days.
I totally just read that as, "I'd hate to be the only black guy stuck using v1.4."
[/ispoiler]

Raigan and the Horse-Woman
Raigan and the Horse-Woman
Posts: 182
Joined: 2008.09.27 (02:14)
NUMA Profile: www.nmaps.net/user/sidke
Steam: www.steamcommunity.com/id/shagdish
Location: ⑨ 
Contact:

Postby sidke » 2009.10.11 (06:45)

Cool beans, Bio.
spoiler

辻菜摘が好きじゃー ヽ(´ー`)ノ sig by peking duck


User avatar
The 700 Club
Posts: 744
Joined: 2008.10.17 (00:28)
NUMA Profile: http://nmaps.net/user/BionicCryonic
Location: Lethal Lava Land

Postby Yoshimo » 2009.10.11 (16:08)

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

Image
Image


User avatar
Radio Douchebag
Posts: 1026
Joined: 2009.04.29 (01:03)
NUMA Profile: http://nmaps.net/user/Rhekatou
Location: PAL

Postby Rhekatou » 2009.10.11 (16:53)

It just puts a million mines in one spot =(
Image

User avatar
The 700 Club
Posts: 744
Joined: 2008.10.17 (00:28)
NUMA Profile: http://nmaps.net/user/BionicCryonic
Location: Lethal Lava Land

Postby Yoshimo » 2009.10.11 (17:52)

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.
spoiler

Image
Image


User avatar
Member
Posts: 27
Joined: 2009.08.23 (12:32)
NUMA Profile: http://nmaps.net/user/n0_ma11y

Postby n0_ma11y » 2009.11.16 (02:17)

I am absoulutely clueless about any of this.
Image
Image
map pack ^

User avatar
Radio Douchebag
Posts: 1026
Joined: 2009.04.29 (01:03)
NUMA Profile: http://nmaps.net/user/Rhekatou
Location: PAL

Postby Rhekatou » 2009.12.18 (02:26)

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.
Image

User avatar
Beyond a Perfect Math Score
Posts: 834
Joined: 2008.09.30 (06:37)
NUMA Profile: http://nmaps.net/user/Nexx
MBTI Type: INTJ
Location: California, USA

Postby Nexx » 2010.01.02 (04:08)

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.


Who is online

Users browsing this forum: No registered users and 12 guests