Welcome, Guest

Author Topic: Coding  (Read 180055 times)

Darvince

  • *****
  • Posts: 1835
  • 差不多
Re: Python
« Reply #120 on: December 01, 2012, 10:05:37 AM »
holykute

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #121 on: December 07, 2012, 12:55:27 PM »
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.

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: Python
« Reply #122 on: December 08, 2012, 12:14:24 PM »
when will you update baitech? i am getting
BORED OUT OF MY

MIND!!!!!!!!!!!

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #123 on: December 12, 2012, 01:03:59 PM »
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

Darvince

  • *****
  • Posts: 1835
  • 差不多
Re: Python
« Reply #124 on: December 12, 2012, 04:10:41 PM »
<+what about usernames>

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #125 on: December 12, 2012, 04:23:27 PM »
i can split at the '>'

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #126 on: January 11, 2013, 08:52:57 PM »
derp

atomic7732

  • Global Moderator
  • *****
  • Posts: 3828
  • caught in the river turning blue
    • Paladin of Storms
Re: Python
« Reply #127 on: February 08, 2013, 07:03:36 PM »
senary converter

dec to base/base to dec converter

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: Python
« Reply #128 on: February 08, 2013, 07:52:46 PM »
*downloads so it doesn't say 0 downloaded times*
hmm what is dec and base?

atomic7732

  • Global Moderator
  • *****
  • Posts: 3828
  • caught in the river turning blue
    • Paladin of Storms
Re: Python
« Reply #129 on: February 08, 2013, 09:06:24 PM »
decimal

base

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #130 on: February 08, 2013, 09:09:38 PM »
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 brute-force 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

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Python
« Reply #131 on: February 09, 2013, 03:59:12 AM »
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

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #132 on: February 09, 2013, 04:42:50 AM »
it would. i'm trying something with that right now...^

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #133 on: February 09, 2013, 05:46:03 AM »
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

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Python
« Reply #134 on: February 09, 2013, 07:35:43 AM »
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.

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #135 on: February 09, 2013, 07:45:23 AM »
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.

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Python
« Reply #136 on: February 09, 2013, 07:49:55 AM »
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.
« Last Edit: February 09, 2013, 07:59:57 AM by Bla »

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #137 on: February 09, 2013, 08:13:56 AM »
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.

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: Python
« Reply #138 on: February 09, 2013, 08:15:22 AM »
vh is off. a python expert

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Python
« Reply #139 on: February 09, 2013, 08:30:32 AM »
I made it automatically extract all the numbers by using the comma count method.

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #140 on: February 09, 2013, 08:43:38 AM »
instead of doing
Code: [Select]
    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

Code: [Select]
    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

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: Python
« Reply #141 on: February 09, 2013, 08:53:23 AM »
i was going spend forever, but then i used python's calculator!

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Python
« Reply #142 on: February 09, 2013, 08:56:08 AM »
Ok.

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: Python
« Reply #143 on: February 09, 2013, 09:02:40 AM »
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
« Last Edit: February 09, 2013, 09:14:08 AM by bong »

atomic7732

  • Global Moderator
  • *****
  • Posts: 3828
  • caught in the river turning blue
    • Paladin of Storms
Re: Python
« Reply #144 on: February 09, 2013, 10:12:54 AM »
it's not a 'calculator'

You need to use non-integers (684.0/41.0)

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: Python
« Reply #145 on: February 09, 2013, 12:57:49 PM »
ok.
but i mainly use it as a calculator, so
and, it saves a lot more time than typing 'interpeter'

FiahOwl

  • *****
  • Posts: 1234
  • This is, to give a dog and in recompense desire my dog again.
Re: Python
« Reply #146 on: February 20, 2013, 07:20:04 PM »
nsfw

FiahOwl

  • *****
  • Posts: 1234
  • This is, to give a dog and in recompense desire my dog again.
Re: Python
« Reply #147 on: February 20, 2013, 08:06:48 PM »
final update for tonight

atomic7732

  • Global Moderator
  • *****
  • Posts: 3828
  • caught in the river turning blue
    • Paladin of Storms
Re: Python
« Reply #148 on: February 20, 2013, 08:25:29 PM »
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 eye-eh
ai is eye
ei is ay
ie is ee
ae is another ay
« Last Edit: February 20, 2013, 08:36:06 PM by atomic7732 »

vh

  • formerly mudkipz
  • *****
  • Posts: 1138
  • "giving heat meaning"
Re: Python
« Reply #149 on: February 20, 2013, 08:45:08 PM »
added more strings.

now prints long and short words