Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Life Programming

Life Programming

Scheduled Pinned Locked Moved The Lounge
50 Posts 22 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Bikash Prakash Dash

    Its not a serious discussion man , lets hav a fun.

    L Offline
    L Offline
    Lost User
    wrote on last edited by
    #28

    Bikash Prakash Dash wrote:

    Its not a serious discussion man

    It was my "attempt" at describing my life as a program; what you read was the output. Then again, most 'ere just want the codez, not the details, so;

    using System;
    class Coffee { /* lot's of sugar */ } class Code { /* On Error Resume 0 */ }
    enum ClassesOfLife { Human, Mammal, Fish, Programmer }
    private class Life: IDisposable // I ain't that static, just clone me :D
    {
    bool alive = true; // Life should be alive by default, or it won't run
    public ClassesOfLife Class { get; set; }
    public bool EOL(int dummy) { return !alive; } // dummy = true :)

    Code Consume(Coffee\[\] food) { return new Code(); } 
    static void Main(string\[\] args)
    {
        Func SomeRandomThing = delegate(int chance) // obfuscated?
            { return 0 == new Random((int)Environment.TickCount).Next(0, chance); };
    
        using (var Life = new Life() { Class = ClassesOfLife.Programmer })
        {
            while (!Life.EOL(1)) // the intention is to live forever
            {
                var food = new Coffee\[\] { new Coffee(), new Coffee() };
                if (SomeRandomThing(20)) food = null;
                var code = Life.Consume(food);
                if (SomeRandomThing(4)) code = null; // "external events", aka heisenbug
                if (null == code) Life.alive = false;
                if (SomeRandomThing(100)) 
                    throw new NotImplementedException("No, we still got three days until the deadline, right?");
                Console.WriteLine("Heartbeat, @" + Environment.TickCount);
            }
        }
        Console.ReadKey();
    }
    void IDisposable.Dispose()
    {
        alive = false;
        Console.WriteLine("Disposed!"); // be sure to turn of inheritance.
    }
    

    }

    Be warned before running the code that it did not survive it's first code-review. It seems that the code does not reproduce, and thus, does not count as "life" in the way a biologist looks at it.

    Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

    B 1 Reply Last reply
    0
    • OriginalGriffO OriginalGriff

      I think we'd all be in trouble if there were two... :laugh:

      The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #29

      OriginalGriff wrote:

      I think we'd all be in trouble if there were two... :laugh:

      There are times that I'd really like to invoke a collection of Griffs, but then I'd just be using you :)

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

      OriginalGriffO 1 Reply Last reply
      0
      • L Lost User

        Bikash Prakash Dash wrote:

        Its not a serious discussion man

        It was my "attempt" at describing my life as a program; what you read was the output. Then again, most 'ere just want the codez, not the details, so;

        using System;
        class Coffee { /* lot's of sugar */ } class Code { /* On Error Resume 0 */ }
        enum ClassesOfLife { Human, Mammal, Fish, Programmer }
        private class Life: IDisposable // I ain't that static, just clone me :D
        {
        bool alive = true; // Life should be alive by default, or it won't run
        public ClassesOfLife Class { get; set; }
        public bool EOL(int dummy) { return !alive; } // dummy = true :)

        Code Consume(Coffee\[\] food) { return new Code(); } 
        static void Main(string\[\] args)
        {
            Func SomeRandomThing = delegate(int chance) // obfuscated?
                { return 0 == new Random((int)Environment.TickCount).Next(0, chance); };
        
            using (var Life = new Life() { Class = ClassesOfLife.Programmer })
            {
                while (!Life.EOL(1)) // the intention is to live forever
                {
                    var food = new Coffee\[\] { new Coffee(), new Coffee() };
                    if (SomeRandomThing(20)) food = null;
                    var code = Life.Consume(food);
                    if (SomeRandomThing(4)) code = null; // "external events", aka heisenbug
                    if (null == code) Life.alive = false;
                    if (SomeRandomThing(100)) 
                        throw new NotImplementedException("No, we still got three days until the deadline, right?");
                    Console.WriteLine("Heartbeat, @" + Environment.TickCount);
                }
            }
            Console.ReadKey();
        }
        void IDisposable.Dispose()
        {
            alive = false;
            Console.WriteLine("Disposed!"); // be sure to turn of inheritance.
        }
        

        }

        Be warned before running the code that it did not survive it's first code-review. It seems that the code does not reproduce, and thus, does not count as "life" in the way a biologist looks at it.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        B Offline
        B Offline
        Bikash Prakash Dash
        wrote on last edited by
        #30

        Quote:

        Console.WriteLine("Heartbeat, @" + Environment.TickCount);

        haha Like this line

        1 Reply Last reply
        0
        • M Marco Bertschi

          Without me, many things wouldn't be able to run.

          cheers Marco Bertschi


          Twitter | Articles


          You have absolutely no idea how glad I am that I have no idea at all. - OriginalGriff I'm at peace with the world and myself. - Me

          M Offline
          M Offline
          Mladen Jankovic
          wrote on last edited by
          #31

          I'm sure you meant ntoskrnl.exe or some other versions of Windows kernel.

          more from me | GALex: C++ Library for Advanced Genetic Algorithms

          1 Reply Last reply
          0
          • L Lost User

            OriginalGriff wrote:

            I think we'd all be in trouble if there were two... :laugh:

            There are times that I'd really like to invoke a collection of Griffs, but then I'd just be using you :)

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

            OriginalGriffO Offline
            OriginalGriffO Offline
            OriginalGriff
            wrote on last edited by
            #32

            You don't Dispose of me that easily!

            The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
            "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

            1 Reply Last reply
            0
            • B Bikash Prakash Dash

              Hi friends , lets innovate a new programming language called Life Programming. Describe your lifestyle with a program.

              R Offline
              R Offline
              Ravi Bhavnani
              wrote on last edited by
              #33

              while (CanCode()) {
              Exist();
              }
              Die();

              /ravi

              My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

              1 Reply Last reply
              0
              • M Marco Bertschi

                Without me, many things wouldn't be able to run.

                cheers Marco Bertschi


                Twitter | Articles


                You have absolutely no idea how glad I am that I have no idea at all. - OriginalGriff I'm at peace with the world and myself. - Me

                A Offline
                A Offline
                AspDotNetDev
                wrote on last edited by
                #34

                Well, they wouldn't need to anymore, and they could get rid of the restraining order.

                Thou mewling ill-breeding pignut!

                D 1 Reply Last reply
                0
                • L LloydA111

                  Xyzzy

                         .-.
                        |o,o|
                     ,| \_\\=/\_      .-""-.
                     ||/\_/\_\\\_\\    /\[\] \_ \_\\
                     |\_/|(\_)|\\\\  \_|\_o\_LII|\_
                        \\.\_./// / | ==== | \\
                        |\\\_/|"\` |\_| ==== |\_|
                        |\_|\_|    ||" ||  ||
                        |-|-|    ||LI  o ||
                        |\_|\_|    ||'----'||
                       /\_/ \\\_\\  /\_\_|    |\_\_\\
                  
                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #35

                  plover

                  MVVM# - See how I did MVVM my way ___________________________________________ Man, you're a god. - walterhevedeich 26/05/2011 .\\axxx (That's an 'M')

                  1 Reply Last reply
                  0
                  • OriginalGriffO OriginalGriff

                    private partial class myLife {}

                    The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                    B Offline
                    B Offline
                    Bikash Prakash Dash
                    wrote on last edited by
                    #36

                    if(this) dothat(); else if(that) dothis(); else crazy();

                    OriginalGriffO 1 Reply Last reply
                    0
                    • A AspDotNetDev

                      Well, they wouldn't need to anymore, and they could get rid of the restraining order.

                      Thou mewling ill-breeding pignut!

                      D Offline
                      D Offline
                      dusty_dex
                      wrote on last edited by
                      #37

                      AspDotNetDev wrote:

                      Well, they wouldn't need to anymore, and they could get rid of the restraining order.

                      Lol. :laugh: :laugh: :laugh:

                      1 Reply Last reply
                      0
                      • B Bikash Prakash Dash

                        if(this) dothat(); else if(that) dothis(); else crazy();

                        OriginalGriffO Offline
                        OriginalGriffO Offline
                        OriginalGriff
                        wrote on last edited by
                        #38

                        Good grief no! I multitask: "this", "that" and "crazy" are parallel processes wherever possible. ;)

                        The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                        B 1 Reply Last reply
                        0
                        • D DaveAuld

                          Wish it was that easy, I keep getting a 'Syntax Error' and I won't run!

                          Dave Find Me On: Web|Facebook|Twitter|LinkedIn


                          Folding Stats: Team CodeProject

                          OriginalGriffO Offline
                          OriginalGriffO Offline
                          OriginalGriff
                          wrote on last edited by
                          #39

                          I get a "Invalid operation" exception when I try to jog, does that count?

                          The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                          D 1 Reply Last reply
                          0
                          • OriginalGriffO OriginalGriff

                            Good grief no! I multitask: "this", "that" and "crazy" are parallel processes wherever possible. ;)

                            The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                            B Offline
                            B Offline
                            Bikash Prakash Dash
                            wrote on last edited by
                            #40

                            in a state of confusion now

                            OriginalGriffO 1 Reply Last reply
                            0
                            • B Bikash Prakash Dash

                              in a state of confusion now

                              OriginalGriffO Offline
                              OriginalGriffO Offline
                              OriginalGriff
                              wrote on last edited by
                              #41

                              Why? Don't you do several things at the same time? I thought everyone did.

                              The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                              B 1 Reply Last reply
                              0
                              • OriginalGriffO OriginalGriff

                                I get a "Invalid operation" exception when I try to jog, does that count?

                                The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                                D Offline
                                D Offline
                                DaveAuld
                                wrote on last edited by
                                #42

                                Sure does!

                                Dave Find Me On: Web|Facebook|Twitter|LinkedIn


                                Folding Stats: Team CodeProject

                                1 Reply Last reply
                                0
                                • OriginalGriffO OriginalGriff

                                  Why? Don't you do several things at the same time? I thought everyone did.

                                  The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                                  B Offline
                                  B Offline
                                  Bikash Prakash Dash
                                  wrote on last edited by
                                  #43

                                  YA I DO , BT NOW I'M IN CONFUSE

                                  OriginalGriffO 1 Reply Last reply
                                  0
                                  • B Bikash Prakash Dash

                                    YA I DO , BT NOW I'M IN CONFUSE

                                    OriginalGriffO Offline
                                    OriginalGriffO Offline
                                    OriginalGriff
                                    wrote on last edited by
                                    #44

                                    Sorry, I don't do SHOUTY txtspk, would you care to try again using your full keyboard? BTW: if I can write this on a tablet without a dedicated keyboard, surely you can do the same with a full, proper keyboard? :laugh:

                                    The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

                                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                    1 Reply Last reply
                                    0
                                    • B Bikash Prakash Dash

                                      Hi friends , lets innovate a new programming language called Life Programming. Describe your lifestyle with a program.

                                      G Offline
                                      G Offline
                                      Gary Huck
                                      wrote on last edited by
                                      #45

                                      using System; namespace LifeIsABitch { interface Bitch { // ... } class Program { static void Main(string[] args) { Bitch life; die(); } static void die() { // ... } } }

                                      1 Reply Last reply
                                      0
                                      • B Bikash Prakash Dash

                                        Hi friends , lets innovate a new programming language called Life Programming. Describe your lifestyle with a program.

                                        S Offline
                                        S Offline
                                        StatementTerminator
                                        wrote on last edited by
                                        #46

                                        while(alive) { wake(); eat(); poop(); if(workday) { work(); } eat(); poop(); if(lucky) { haveSex(); } else { cryWank(); } Debug.Assert(this.Meaning > 0, null); sleep(); }

                                        I C 2 Replies Last reply
                                        0
                                        • S StatementTerminator

                                          while(alive) { wake(); eat(); poop(); if(workday) { work(); } eat(); poop(); if(lucky) { haveSex(); } else { cryWank(); } Debug.Assert(this.Meaning > 0, null); sleep(); }

                                          I Offline
                                          I Offline
                                          IndifferentDisdain
                                          wrote on last edited by
                                          #47

                                          Sadly (or amazingly), I actually learned something on this thread. I never knew about Debug.Assert until wasting time on this thread. So thanks for that and justifying my procrastination.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups