11 ms·
Show HN: Matrix rain, Conway's Game of Life and Mandelbrot set for terminals
- rs23296008n1 7y agoI like the speed and dynamic aspects. Use of 256 colours means extra shades etc. Simple effect and very good. Now I want to dust off my old snake game and upgrade it to 3D.
- Zhyl 7y agoAs a fan of terminals, matrix rain, Conway's game of life and Mandelbrot sets, this is relevant to my interests.
- Mashimo 7y agoThose terminal matrix rain animations are always super slow for me at higher resolution. Using two cores 100%. Maybe because I run through WSL?
- akinomyoga 7y agoThank you for your comment. I'm not sure for your specific case, but generally the performance largely depends on the terminal emulators in my experience. For example, xterm and Windows ConPTY are super slow which are sometimes 100 times slower than the fastest terminals. urxvt (rxvt-unicode), alacritty, terminology are usually fast. xfce4-terminal, qterminal, mintty are acceptable. VTE based terminals (GNOME terminal, lxterminal, etc.), termit, etc. are slow in my environments.
- akinomyoga 7y agoActually one of the reason why I wrote this program is to test the terminal performances. When I'm searching the benchmark data of Alacritty, I found this issue https://github.com/alacritty/alacritty/issues/289#issue-200130020 https://github.com/alacritty/alacritty/issues/289#issue-2001... where the existing Matrix rain program "cmatrix" is mentioned. I tried "cmatrix" in my terminal (I'm using a terminal which I wrote from scratch for myself) and found that the Matrix rain of "cmatrix" is cheaper than I expected. That is the reason why I wrote "cxxmatrix", a version with additional optical effects written in C++.
- tyingq 7y agoThe default WSL terminal is slow. I always install an X server. VcXsrv works great, with good Windows clipboard support. Then you can use urxvt or some other Linux terminal that's faster.
- hoov 7y agoI've tried a bunch of X servers, but with a 4k display, they're all too slow to be usable. I'm settling for running WSL inside Alacritty for now.
- tyingq 7y agoI use VcXsrv in the multiwindow mode where it uses the Windows 10 window manager for each X app, instead of being fullscreen. Is that also slow on a 4k screen?
- craftinator 7y agoLol, the downfall of high powered output hardware. It then requires equally high powered input hardware. Solving this problem is my life now.
- bnjms 7y agoAre you running the new Windows Terminal (Preview)? If not, and you try it, is it any better?
- Mashimo 7y agoThat made it even worse.
- rolandog 7y agoThis is so cool! Thank you for the great effort.
- mark_l_watson 7y agoSo very cool. I just built and installed it on my MacBook. Looks great on Apple's standard terminal, and I think a little bit better even on ITerm 2.
- saagarjha 7y agoInterestingly, it was exceedingly laggy on Terminal.app for me. iTerm seemingly handled it better.
- mark_l_watson 7y agoThanks, that is what I tried to say: better on ITerm.
- GeertJohan 7y agoA long time ago I wrote gomatrix: https://github.com/GeertJohan/gomatrix https://github.com/GeertJohan/gomatrix It's a Matrix emulator inspired by cmatrix. It doesnt have as many features as this posts one (e.g. just 2 colors for the kanas), but was a fun exercise to learn Go. Pull requests welcome :)
- akinomyoga 7y agoThank you for your comment. Do you have some screenshots, animated GIFs or videos of gomatrix which I can link from cxxmatrix README (https://github.com/akinomyoga/cxxmatrix#the-matrix-rains-in-terminals https://github.com/akinomyoga/cxxmatrix#the-matrix-rains-in-...)? I could only find unofficial one https://www.youtube.com/watch?v=mUXFxSmZMis https://www.youtube.com/watch?v=mUXFxSmZMis (maybe I can add a link to this unofficial one)
- saagarjha 7y agoOh boy, neither GCC nor Clang liked the Unicode one bit: $ make 2>&1 | head c++ -std=c++17 -Wall -Wextra -Os -MD -MP -MF cxxmatrix.dep -c -o cxxmatrix.o cxxmatrix.cpp In file included from cxxmatrix.cpp:595: glyph.inl:78:2: error: converting to execution character set: Invalid argument 78 | {U'�', 21, {127, 65, 65, 65, 65, 65, 127, }}, | ^~~~ glyph.inl:79:2: error: converting to execution character set: Invalid argument 79 | {U'�', 21, {573695, 2072768, 104616, 104344, 37000, 1609860, 430211, }}, | ^~~~ glyph.inl:80:2: error: converting to execution character set: Invalid argument 80 | {U'�', 21, {164354, 260859, 2015779, 1221155, 692770, 429602, 1238014, }},
- superkuh 7y agoYou made it further than I did. The majority of machines out there today probably do not support the required -std=c++17. I know none of my OS installs (and their compilers) do.
- saagarjha 7y agoI think Xcode has shipped with a compliant C++17 compiler for over a year, but I used GCC to compile this one :)
- akinomyoga 7y agoThank you. This issue is discussed here https://github.com/akinomyoga/cxxmatrix/issues/3 https://github.com/akinomyoga/cxxmatrix/issues/3 It is caused by the UTF-8 unaware awk. I haven't yet figured out why it happens, but at least you need to set your locale to one of UTF-8 locales.
- Tagbert 7y agoBack in the 80s when most people were using DOS text screens, we would sometime play a joke on a friend/coworker. We would get on their computer and run a small terminate-and-stay-resident (background process) program called rain.com. It would sit in the background while they ran their word processor or spreadsheet. After some time, it would cause one character to “fall” down the screen. They would see it happen and not know what was going on. Then it would make another charter fall. By then, the person would usually call out to someone else to come and look at this weird thing. But then the program would up the rate and start dropping multiple charters. It kept increasing the rate and eventually all of the characters on their screen had rained down and were in a pile on the bottom of the screen. At that point, we would press some key combination and their original screen would appear. That is usually when we would let them in on the joke and reboot their machine to remove the TSR Rain. People didn’t lock their computers back then. :)
- anderspitman 7y agoGreat work! This is one of the best rain implementations I've seen. A while back I implemented[0] a (pretty basic) Matrix rain in JavaScript that will pull your latest public GitHub contributions and use that for the rain text. Demo here[1]. And of course my useless Game of Life icons, golicaons[2] (demo [3]). [0]: https://github.com/anderspitman/redpill https://github.com/anderspitman/redpill [1]: https://anderspitman.net/apps/redpill/ https://anderspitman.net/apps/redpill/ [2]: https://github.com/anderspitman/golicons https://github.com/anderspitman/golicons [3]: https://anderspitman.net/apps/golicons/ https://anderspitman.net/apps/golicons/
- pluc 7y agoThere is a screensaver that does Matrix rain with GitHub's latest public commits: https://github.com/winterbe/github-matrix-screensaver https://github.com/winterbe/github-matrix-screensaver
- tylerneylon 7y agoI few years ago I put together a basic Mandelbrot terminal animation: https://gist.github.com/tylerneylon/e70a684b88809f74168f3a3618fd98a4 https://gist.github.com/tylerneylon/e70a684b88809f74168f3a36... It runs nicely in Python 2 (and slower in Python 3). Here's a nice code golf Mandelbrot that also uses no image library (it produces a bmp file): https://codegolf.stackexchange.com/a/23465 https://codegolf.stackexchange.com/a/23465
- laretluval 7y agoOnce everyone is working from home it is going to be prime time for terminal-based yak shaving.
- stallmanite 7y agoAlong those lines but from a more general angle I bet tons of other really useful things get done that maybe wouldn’t have otherwise.
- willis936 7y agoNeeded to run make twice but it’s running on a raspberry pi 4 + raspbin stable.
- meanmrmustard92 7y agoThis is fantastic. What arguments should I pass ./cxxmatrix to get the mandelbrot set or game of life? Can't seem to get it to work / couldn't figure it out from the repo.
- akinomyoga 7y agoPlease just wait for several minutes.
- justinhj 7y agoI've been playing around with the code, you can just comment out the bits you don't want to run in the main function... // buff.s1number(); // for (int i = 1; i < argc; i++) // buff.s2banner(argv[i]); // buff.s3rain(2800, buffer::s3rain_scroll_func_tanh); buff.s4conway(); // buff.s5mandel(); // Infinite rain //buff.s3rain(0, buffer::s3rain_scroll_func_const);
- WantonQuantum 7y agoRuns noticeably faster for me if I change -Os to -Ofast