Results 1 to 6 of 6
  1. Collapse Details
    c code collaboration competition 
    #1
    friends with english jon's Avatar
    Join Date
    Dec 2011
    Location
    alcatraz
    Posts
    4,510
    if you can comprehend what i've started here, this is your chance to express your aesthetic in a new branch of automata

    Code:
    #include <stdlib.h>
    #include <stdint.h>
    #include <string.h>
    
    #define OP_GT   (0)
    #define OP_GTE  (1)
    #define OP_LT   (2)
    #define OP_LTE  (3)
    
    typedef struct grid grid_t;
    typedef struct rule rule_t;
    typedef struct page page_t;
    typedef struct ofst ofst_t;
    
    struct grid
    {
      uint32_t d;
      uint32_t *m;
    };
    
    struct ofst
    {
      int8_t x;
      int8_t y;
    };
    
    struct rule
    {
      uint8_t f   : 1;
      uint8_t op  : 2;
      uint8_t x   : 3;
      uint8_t z   : 2; // not used
    };
    
    struct page
    {
      rule_t  r;
      uint8_t n;
    };
    
    
    void wcell(grid_t *g, uint32_t x, uint32_t y, uint8_t v)
    {
      uint32_t d = g->d;
      if (x >= d || y >= d)
        return;
      g[x + d * y] = v;
    }
    
    
    uint8_t rcell(grid_t *g, uint32_t x, uint32_t y)
    {
      uint32_t d = g->d;
      if (x >= d || y >= d)
        return 0;
      return g[x + d * y];
    }
    
    
    void info(page_t *p, grid_t *g, uint32_t x, uint32_t y)
    {
      offset_t o[8] = {
        { .x = -1, .y = -1 },
        { .x =  0, .y = -1 },
        { .x =  1, .y = -1 },
        { .x =  1, .y =  0 },
        { .x =  1, .y =  1 },
        { .x =  0, .y =  1 },
        { .x = -1, .y =  1 },
        { .x = -1, .y =  0 },
      };
      uint8_t c;
    
      // 0 1 2
      // 7   3
      // 6 5 4
    
      memset(p, 0, sizeof(page_t));
      for (i = 0; i < 8; i++) {
        c = rcell(g, x + o[i].x, y + o[i].y);
        p.n += c;
        p.r = (p.r << 1) | c;
      }
    }
    
    
    void next_step(grid_t *n, grid_t *g, uint32_t x, uint32_t y)
    {
      page_t p;
      info(&p, g, x, y);
      switch (p.r.op)
      {
        case OP_GT:  if (p.r.x > p.n)  wcell(n, x, y, p.r.f); return;
        case OP_GTE: if (p.r.x >= p.n) wcell(n, x, y, p.r.f); return;
        case OP_LT:  if (p.r.x < p.n)  wcell(n, x, y, p.r.f); return;
        case OP_LTE: if (p.r.x <= p.n) wcell(n, x, y, p.r.f); return;
      }
      wcell(n, x, y, rcell(g, x, y));
    }
    
    
    void next_grid(grid_t *n, grid_t *g)
    {
      uint32_t x, y, d;
      d = g->d;
      for (x = 0; x < d; x++)
        for (y = 0; y < d; y++)
          next_step(n, g, x, y);
    }
    
    
    int main (int argc, char **argv)
    {
      grid_t a, b, *v, *w;
    
      v = &a; w = &b;
      memset(v, 0, sizeof(grid_t));
      memset(w, 0, sizeof(grid_t));
    
      // load v
    
      for (;;) {
        draw(v);
        next_grid(w, v);
        if (v == &a) { v = &b; w = &a; }
        else         { v = &a; w = &b; }
      }
    
      return 0;
    }
    it doesn't compile yet. i don't usually need the compiler until the very end. just fill in the blanks and don't talk shit
    Reply With Quote
     

  2. Collapse Details
     
    #2
    Senior Member elezzzark's Avatar
    Join Date
    Feb 2012
    Posts
    2,055
    Code:
    #include<stdio.h>
    
    main()
    {
        printf("YOU SELL WEAPONS TO NARCS, FUCK OFF FAG");
    
    }
    Reply With Quote
     

  3. Collapse Details
     
    #3
    fams casino Dustin's Avatar
    Join Date
    Dec 2011
    Posts
    3,769
    2 advanced 4 me
    Reply With Quote
     

  4. Collapse Details
     
    #4
    my weapons turn me into a m0nde's Avatar
    Join Date
    Dec 2011
    Location
    every once in a while
    Posts
    29,860
    Code:
    /** Retardation key and hashed retardation key. */

    Reply With Quote
     

  5. Collapse Details
     
    #5
    friends with english jon's Avatar
    Join Date
    Dec 2011
    Location
    alcatraz
    Posts
    4,510
    your submissions are taken into consideration
    Reply With Quote
     

  6. Collapse Details
     
    #6
    R.i.p. Garfield 1986-2016 Garfield's Avatar
    Join Date
    Dec 2011
    Location
    Heaven
    Posts
    7,789
    Reply With Quote
     

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •