Skip navigation.

Log in | Sign up

Simple is best ... !

Can life be like a program?

, , ,

.:: Can life be like a program? ::.
Program Life Basics;  // Can life be like a program?  Let's see!
Uses
   LifeLib;
Var             
   Food, Sleep, Water As Needs;
   Happiness As LifeStrength;
   Love As SomethingNeeded(4);
   Age, Death As Integer;
   Junction Person
       Begin
            Health As Status;
        End;        
Const
   GotoSchool;
   Work;
   StayInHome;
  
Begin

   Death := Random(100); // We all know that the death is random.
   Happiness := 2 + Random(5); // Happiness is random too.

     Do
  
            // Should I go to school, to work or stay in home?      
        If (Age < 18) Then
           GotoSchool;
        Else If (Age < 50)
           GotoWork;
        Else
           StayInHome;
        End;


           // Let's try to survive...!
        If Not Food Then
            Person.Health := False
            Happiness := Happiness - 2
        Else
            Happiness := Happiness + 5
        End;
        If Not Water Then
            Person.Health = False
            Happiness := Happiness - 2
        Else
            Happiness := Happiness + 5
        End;
        If Not Sleep Then
            Person.Health := False
            Happiness := Happiness - 2
        Else
            Happiness := Happiness + 5
        End;
        

               // Let's put some love in the game.
        Read(Love);

         Select Case (Love)
             0 : Happiness := Happiness -  20; Break;
             1 : Happiness := Happiness -  10; Break;
             2 : Break;
             3 : Happiness := Happiness + 10; Break;
             4 : Happiness := Happiness + 15; Break;
         End Case;
       

              // Happy?       
        If  (Happiness < -10) Then
            Death := 0                    // Suicide...
        Else If (Happiness < 3) Then
            Person.Health := False    // Get Sick...
        Else If (Happiness > 80) Then
             Death := Death + 1         // Live longer!
             Happiness := Happiness - 20
        End;

             // Am I sick?
        If Not Person.Health Then
              Hospital
        End;
              
          
             // Wow, time is going too fast!! A year has passed.
      Age := Age + 1

     While (Age <= Death);

             // Oops... Game Over.
     Write('Memento Mori...');
     Readkey;
     Write('Game Over');

End.

Procedure Hospital
Var
   Methods As GoodOrBad;

  Begin

          // Can I be saved?
    If (Methods = Good) Then
        Happiness := Happiness + 2
        Death := Death - 1
    Else If (Methods = Bad) Then
        Happiness = Happiness - 2
        Death := Death - 5
    End;
   
  End;
 
Đoạn code này nói về cuộc đời của một con người đến khi chết ...!

Liệu ... cuộc sống có giống 1 chương trình?
Không! Cuộc sống của mình đang và sẽ không đơn giản như đoạn code chưa đến 200 dòng này!


Lang thangCá tháng tư mình tý nữa thì bị lừa ^^

Comments

Anonymous 15. March 2009, 14:43

haohao writes:

anh Tuấn tự viết hay copy paste ở đâu mà nhiều bài hay thế ^^.Hơi hâm mộ đó :d

Phạm Minh Tuấn 15. March 2009, 14:49

Hảo xu cù đấy à ^^
Copy, paste hay tự viết thì quan trọng gì.
Quan trọng là làm sao để thể hiện ra cho mọi người cảm thấy hay thôi :smile:

Rear 22. March 2009, 05:46

:no:

Sai 31. March 2009, 04:25

// Let's put some love in the game.
Read(Love);

Select Case (Love)
0 : Happiness := Happiness - 20; Break;
1 : Happiness := Happiness - 10; Break;
2 : Break;
3 : Happiness := Happiness + 10; Break;
4 : Happiness := Happiness + 15; Break;
End Case;


đoạn này hình như còn thiếu ?

Phạm Minh Tuấn 31. March 2009, 12:53

phiên phiến thôi, chỉ là tượng trưng thôi mà :smile:

Anonymous 7. April 2009, 02:40

Anonymous writes:

có ai chạy thử, xem nó ra cái gì nhỉ? hihi :D

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies

December 2009
S M T W T F S
November 2009January 2010
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31