1. Куча / Говнокод #17677

    +132

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    @echo off
    setlocal EnableDelayedExpansion
    setlocal EnableExtensions
    
    set /a _2=20
    set /a _1=600
    set /a _0=800
    call :mandelbrot _3 0 _0 _1 _2
    echo | set /p ^=!_3!
    
    goto :EOF
    :mandelbrot
    set width_%~2=!%~3!
    set height_%~2=!%~4!
    set max_%~2=!%~5!
    set /a row_%~2=0
    :WHILE_6
    if !row_%~2! LSS !height_%~2! (
      set /a col=0
      :WHILE_5
      if !col! LSS !width_%~2! (
        set /a c_re=^(^(^(!col! - ^(!width_%~2! / 2^)^) * 4^) / !width_%~2!^)
        set /a c_im=^(^(^(!row_%~2! - ^(!height_%~2! / 2^)^) * 4^) / !width_%~2!^)
        set /a x=0
        set /a y=0
        set /a iteration=0
        set /a _9_%~2=0
        if !iteration! LSS !max_%~2! (
          set /a _8_%~2=1
        ) else (
          set /a _8_%~2=0
        )
        set /a _18_%~2=^(1 + %~2^)
        call :or _19_%~2 !_18_%~2! _8_%~2 _9_%~2
        set _10_%~2=!_19_%~2!
        set /a _4_%~2=2
        set _3_%~2=!y!
        set /a _20_%~2=^(1 + %~2^)
        call :pow _21_%~2 !_20_%~2! _3_%~2 _4_%~2
        set _5_%~2=!_21_%~2!
        set /a _1_%~2=2
        set _0_%~2=!x!
        set /a _22_%~2=^(1 + %~2^)
        call :pow _23_%~2 !_22_%~2! _0_%~2 _1_%~2
        set _2_%~2=!_23_%~2!
        set /a _24_%~2=^(1 + %~2^)
        call :plus _25_%~2 !_24_%~2! _2_%~2 _5_%~2
        set _6_%~2=!_25_%~2!
        if !_6_%~2! LEQ 4 (
          set /a _7_%~2=1
        ) else (
          set /a _7_%~2=0
        )
        set /a _26_%~2=^(1 + %~2^)
        call :and _27_%~2 !_26_%~2! _7_%~2 _10_%~2
        set _11_%~2=!_27_%~2!
        :WHILE_4
        if !_11_%~2! EQU 1 (
          set /a x_new=^(^(^(!x! * !x!^) - ^(!y! * !y!^)^) + !c_re!^)
          set /a y=^(^(^(2 * !x!^) * !y!^) + !c_im!^)
          set x=!x_new!
          set /a iteration=^(!iteration! + 1^)
          goto WHILE_4
        )
        if !iteration! LSS !max_%~2! (
          set _14_%~2=!white!
          set _13_%~2=!row_%~2!
          set _12_%~2=!col!
          set /a _30_%~2=^(1 + %~2^)
          call :putpixel _31_%~2 !_30_%~2! _12_%~2 _13_%~2 _14_%~2
          echo | set /p ^=!_31_%~2!
        ) else (
          set _17_%~2=!black!
          set _16_%~2=!row_%~2!
          set _15_%~2=!col!
          set /a _28_%~2=^(1 + %~2^)
          call :putpixel _29_%~2 !_28_%~2! _15_%~2 _16_%~2 _17_%~2
          echo | set /p ^=!_29_%~2!
        )
        set /a col=^(!col! + 1^)
        goto WHILE_5
      )
      set /a row_%~2=^(!row_%~2! + 1^)
      goto WHILE_6
    )
    
    goto :EOF
    :and
    set a_%~2=!%~3!
    set b_%~2=!%~4!
    rem emulation of &&
    if !a_%~2! EQU 1 (
      if !b_%~2! EQU 1 (
        set %~1=1
        goto :EOF
      )
    )
    set %~1=0
    goto :EOF

    Мандельброт (без записи в картинку) на Batch

    Запостил: asm0dey, 22 Февраля 2015

    Комментарии (7) RSS

    • goto :EOF
      :or
      set a_%~2=!%~3!
      set b_%~2=!%~4!
      rem emulation of ||
      if !a_%~2! EQU 1 (
        set %~1=1
        goto :EOF
      )
      if !b_%~2! EQU 1 (
        set %~1=1
        goto :EOF
      )
      set %~1=0
      goto :EOF
      
      goto :EOF
      :pow
      set num_%~2=!%~3!
      set power_%~2=!%~4!
      rem Math.pow
      set counter_%~2=!power_%~2!
      set numberForNow_%~2=!num_%~2!
      :WHILE_7
      if !counter_%~2! GTR 1 (
        set /a numberForNow_%~2=^(!numberForNow_%~2! * !num_%~2!^)
        set /a counter_%~2=^(!counter_%~2! - 1^)
        goto WHILE_7
      )
      set %~1=!numberForNow_%~2!
      goto :EOF
      
      goto :EOF
      :plus
      set a_%~2=!%~3!
      set b_%~2=!%~4!
      rem emulation of +
      set /a _0_%~2=^(!a_%~2! + !b_%~2!^)
      set %~1=!_0_%~2!
      goto :EOF
      
      goto :EOF
      :putpixel
      set col_%~2=!%~3!
      set row_%~2=!%~4!
      set color_%~2=!%~5!
      rem TODO: implement putting pixels on the picture

      Остаток
      Ответить
    • Да это уже серьёзная угроза монолизе в пеинте!
      Ответить
    • Не тот язык назвали брейнфаком...
      Ответить

    Добавить комментарий