fork download
  1. <?php
  2. define('MY_LIFE', 3);
  3.  
  4. function SOUL($MY) {return 0xFFFF & $MY;}
  5. function BODY($MY) {return $MY>>0x10;}
  6.  
  7. class emotion {
  8. const neutral = 0; const upbeat = 1; const sleepy = 2; const tired = 3; const pessimistic = 4;
  9. const betrayed = 5; const mad = 6; const afraid = 7; const down = 8; const left_behind = 9;
  10. };
  11.  
  12. define('bormand', 'x!( "@"!, #(&!$ $\&!$ %(\'!$ &T&! \'T& $ !, %0&!$ $X&!$ #$&!$ )$& $ ');
  13.  
  14. define('p_x', 15);
  15. define('p_y', 10);
  16.  
  17. $podushka = array_fill(0, p_x*p_y, 0);
  18.  
  19. function embrace($a, $i) {
  20. $x = 0;
  21. for($j = 0; $j<3; ++$j)
  22. $x += (ord($a[$i+$j])-0x20)<<($j*6);
  23. return $x;
  24. }
  25.  
  26. function make_love($x, $y) {
  27. global $podushka;
  28. $my = $podushka[$x + p_x*$y];
  29. $my_soul = SOUL($my);
  30. if ($my_soul >= strlen(bormand) - 3)
  31. return;
  32. $my_happiness = embrace(bormand, $my_soul);
  33. $dx = 0;
  34. $dy = 0;
  35. switch($my_happiness & 0xFF) {
  36. case emotion::upbeat:
  37. $podushka[$x + $y*p_x] = $my_soul + MY_LIFE + (($my_happiness & 0xFFFF00)<<8);
  38. break;
  39. case emotion::sleepy:
  40. $dx = -1; goto sleep;
  41. case emotion::tired:
  42. $dx = -1; $dy = -1; goto sleep;
  43. case emotion::left_behind:
  44. $dx = -1; $dy = 1; goto sleep;
  45. case emotion::mad:
  46. $dx = 1; goto sleep;
  47. case emotion::betrayed:
  48. $dx = 1; $dy = -1; goto sleep;
  49. case emotion::afraid:
  50. $dx = 1; $dy = 1; goto sleep;
  51. case emotion::pessimistic:
  52. $dy = -1; goto sleep;
  53. case emotion::down:
  54. $dy = 1; goto sleep;
  55. break;
  56. default:
  57. return;
  58. $podushka[($x+$dx)%p_x + ($y+$dy)%p_y*p_x] = BODY($my) ? $my - 0x10000 : $my_soul + MY_LIFE;
  59. $podushka[$x + p_x*$y] = $my_happiness>>8;
  60. }
  61. }
  62.  
  63. $podushka[8+p_x*9] = 1;
  64. for ($t = 0; $t<20; ++$t) {
  65. for ($i = 0; $i<p_x*p_y; ++$i) {
  66. make_love($i%p_x, floor($i/p_x));
  67. }
  68. }
  69. for ($j = 0; $j<p_y; ++$j) {
  70. for ($i = 0; $i<p_x; ++$i) {
  71. $c = $podushka[$i+p_x*$j];
  72. echo(($c>0x20 && $c<0x7e)?chr($c):' ');
  73. }
  74. echo PHP_EOL;
  75. }
  76.  
  77. return 0;
  78.  
Success #stdin #stdout 0.03s 23616KB
stdin
Standard input is empty
stdout
               
   mmm   aa    
  r   % aaaa   
 r     @@ aaa  
 o        nnn  
 o        nnn  
  b      ddd   
   b    ddd    
    b  ddd     
     bddd