Welcome, Guest

Author Topic: Coding  (Read 262290 times)

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: Coding
« Reply #510 on: June 01, 2015, 07:20:51 PM »
is epoch the new thing for epic
jkjk i aint dat stupid

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Coding
« Reply #511 on: July 11, 2015, 01:48:19 AM »
« Last Edit: July 11, 2015, 02:05:30 AM by vh »

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Coding
« Reply #512 on: July 11, 2015, 02:28:59 AM »
Cute

blotz

  • Formerly 'bong'
  • *****
  • Posts: 813
  • op pls
Re: Coding
« Reply #513 on: July 12, 2015, 07:43:36 PM »
its ubox 0.00001

Darvince

  • *****
  • Posts: 1842
  • 差不多
Re: Coding
« Reply #514 on: July 12, 2015, 07:59:54 PM »
it looks like it tries to swirl but then it doesnt'

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Coding
« Reply #515 on: July 18, 2015, 12:15:42 AM »
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

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

Code: [Select]
a = x1+y1*1j
b = x2+y2*1j
def distance(a,b):
    return abs(a-b)

BAM JUST EIGHT CHARACTERS LOOK AT THAT EFFICIENCY this is the power of complexes

Darvince

  • *****
  • Posts: 1842
  • 差不多
Re: Coding
« Reply #516 on: July 18, 2015, 12:22:21 AM »
kol

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Coding
« Reply #517 on: July 18, 2015, 01:32:46 AM »
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


Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Coding
« Reply #518 on: July 18, 2015, 03:08:46 AM »
Kolkute

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Coding
« Reply #519 on: July 21, 2015, 02:09:30 PM »
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

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Coding
« Reply #520 on: July 26, 2015, 02:40:18 PM »
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.

Code: [Select]
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 = 1-area
print area
« Last Edit: July 26, 2015, 03:25:57 PM by vh »

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Coding
« Reply #521 on: July 26, 2015, 03:38:47 PM »
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

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Coding
« Reply #522 on: August 12, 2015, 01:30:27 PM »
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

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Coding
« Reply #523 on: August 12, 2015, 02:29:19 PM »
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.

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Coding
« Reply #524 on: August 12, 2015, 05:35:45 PM »
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_max-x_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

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Coding
« Reply #525 on: August 16, 2015, 08:04:45 AM »
my gravity sim code

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Coding
« Reply #526 on: August 16, 2015, 08:39:19 AM »
i've pressed 10 million keys in the last year

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Coding
« Reply #527 on: August 16, 2015, 11:03:39 AM »
Nice chart kol

Darvince

  • *****
  • Posts: 1842
  • 差不多
Re: Coding
« Reply #528 on: August 16, 2015, 03:11:17 PM »
can i have whenpulse

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Coding
« Reply #529 on: August 16, 2015, 04:22:22 PM »
yes.

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Coding
« Reply #530 on: September 03, 2015, 03:15:22 PM »

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Coding
« Reply #531 on: September 03, 2015, 04:01:41 PM »
Kol joke code languages are the best.

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Coding
« Reply #532 on: September 04, 2015, 07:21:51 PM »
i wrote some code to format c code for me
it turns this:

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

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

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Coding
« Reply #533 on: September 05, 2015, 02:51:15 PM »
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


Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Coding
« Reply #534 on: September 07, 2015, 12:33:25 PM »
From a Game of Life assignment for a computer science course
(written in MatLab though)




atomic7732

  • Global Moderator
  • *****
  • Posts: 3848
  • caught in the river turning blue
    • Paladin of Storms
Re: Coding
« Reply #535 on: September 07, 2015, 12:50:04 PM »
cute

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

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Coding
« Reply #536 on: September 09, 2015, 06:50:32 AM »
wowowowoowowowowowowowowowow

Bla

  • Global Moderator
  • *****
  • Posts: 1013
  • The stars died so you can live.
Re: Coding
« Reply #537 on: September 21, 2015, 03:28:30 PM »
Finished a numeric integration-thing 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:





(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.
« Last Edit: September 21, 2015, 03:37:11 PM by Bla »

vh

  • formerly mudkipz
  • *****
  • Posts: 1140
  • "giving heat meaning"
Re: Coding
« Reply #538 on: September 21, 2015, 04:10:42 PM »
wow cute

atomic7732

  • Global Moderator
  • *****
  • Posts: 3848
  • caught in the river turning blue
    • Paladin of Storms
Re: Coding
« Reply #539 on: September 21, 2015, 04:16:55 PM »
the new universe sandbox everyone :P