Update
This commit is contained in:
parent
b3106e1ec8
commit
a5acdddb82
16 changed files with 1921 additions and 1672 deletions
3
100r.md
Normal file
3
100r.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Hundred Rabbits
|
||||
|
||||
For now see [xxiivv](xxiivv.md).
|
10
c.md
10
c.md
|
@ -2,17 +2,21 @@
|
|||
|
||||
{ We have a [C tutorial](c_tutorial.md)! ~drummyfish }
|
||||
|
||||
C is an [old](old.md) [low level](low_level.md) structured [statically typed](static_typing.md) [imperative](imperative.md) compiled [programming language](programming_language.md), the language that's currently mostly used by [less retarded software](lrs.md). Though by very strict standards it would still be considered [bloated](bloat.md), compared to any mainstream [modern](modern.md) language it is very bullshitless and [KISS](kiss.md), so it is also the go-to language of the [suckless](suckless.md) community as well as most true experts, for example the [Linux](linux.md) and [OpenBSD](openbsd.md) developers, because of its good, relatively simple design, uncontested performance, wide support, great number of compilers, level of control and a greatly established and tested status. C is perhaps the most important language in history, it influenced, to smaller or greater degree, basically all of the widely used languages today such as [C++](c.md), [Java](java.md), [JavaScript](javascript.md) etc., however it is not a thing of the past -- in the area of low level programming C is still the number one unsurpassed language. C is by no means perfect but it is currently probably the best choice of a programming language (along with [comun](comun.md), of course).
|
||||
C is an [old](old.md) [low level](low_level.md) structured [statically typed](static_typing.md) [imperative](imperative.md) compiled [programming language](programming_language.md), it is very fast and currently mostly used by [less retarded software](lrs.md). Though by very strict standards it would still be considered [bloated](bloat.md), compared to any mainstream [modern](modern.md) language it is very bullshitless, [KISS](kiss.md) and greatly established and "culturally stable", so it is also the go-to language of the [suckless](suckless.md) community as well as most true experts, for example the [Linux](linux.md) and [OpenBSD](openbsd.md) developers, because of its good, relatively simple design, **uncontested performance**, **wide support**, great number of compilers, level of control and a greatly established and tested status. C is **perhaps the most important language in history**; it influenced, to smaller or greater degree, basically all of the widely used languages today such as [C++](c.md), [Java](java.md), [JavaScript](javascript.md) etc., however it is not a thing of the past -- in the area of low level programming C is still the number one unsurpassed language. C is by no means perfect but it is currently probably the best choice of a programming language (along with [comun](comun.md), of course).
|
||||
|
||||
{ Look up *The Ten Commandments for C Programmers* by Henry Spencer. ~drummyfish }
|
||||
|
||||
It is usually not considered an easy language to learn because of its low level nature: it requires good understanding of how a [computer](computer.md) actually works and doesn't prevent the programmer from shooting himself in the foot. Programmer is given full control (and therefore responsibility). There are things considered "tricky" which one must be aware of, such as undefined behavior of certain operators and raw pointers. This is what can discourage a lot of modern "coding monkeys" from choosing C, but it's also what inevitably allows such great performance -- undefined behavior allows the compiler to choose the most efficient implementation. On the other hand, C as a language is pretty simple without [modern](modern.md) bullshit concepts such as [OOP](oop.md), it is not as much hard to learn but rather hard to master, as any other true art.
|
||||
It is usually **not considered an easy language to learn** because of its low level nature: it requires good understanding of how a [computer](computer.md) actually works and doesn't prevent the programmer from shooting himself in the foot. Programmer is given full control (and therefore responsibility). There are things considered "tricky" which one must be aware of, such as undefined behavior of certain operators and raw pointers. This is what can discourage a lot of modern "coding monkeys" from choosing C, but it's also what inevitably allows such great performance -- undefined behavior allows the compiler to choose the most efficient implementation. On the other hand, C as a language is pretty simple without [modern](modern.md) bullshit concepts such as [OOP](oop.md), it is not as much hard to learn but rather hard to master, as any other true art.
|
||||
|
||||
Some of the typical traits of C include great reliance on and utilization of **[preprocessor](preprocessor.md)** ([macros](macro.md), the underlying C code is infamously littered with "`#ifdefs`" all over the place which modify the code just before compiling -- this is mostly used for compile-time configuration and/or achieving better performance and/or for [portability](portability.md)), **[pointers](pointer.md)** (direct access to memory, used e.g. for memory allocation, this is infamously related to "shooting oneself in the foot", e.g. by getting [memory leaks](memory_leak.md)) and a lot of **[undefined behavior](undefined_behavior.md)** (many things are purposefully left undefined in C to allow compilers to generate greatly efficient code, but this sometimes lead to weird [bugs](bug.md) or a program working on one machine but not another, so C requires some knowledge of its specification).
|
||||
|
||||
{ Though C is almost always compiled, there have appeared some C interpreters. ~drummyfish }
|
||||
|
||||
C is said to be a **"[portable](portability.md) [assembly](assembly.md)"** because of its low level nature, great performance etc. -- though C is structured (has control structures such as branches and loops) and can be used in a relatively high level manner, it is also possible to write assembly-like code that operates directly with bytes in memory through [pointers](pointer.md) without many safety mechanisms, so C is often used for writing things like hardware [drivers](driver.md). On the other hand some restrain from likening C to assembly because C compilers still perform many transformations of the code and what you write is not necessarily always what you get.
|
||||
|
||||
Mainstream consensus acknowledges that C is among the best languages for writing low level code and code that requires performance, such as [operating systems](operating_system.md), [drivers](driver.md) or [games](game.md). Even scientific libraries with normie-language interfaces -- e.g. various [machine learning](machine_learning.md) [Python](python.md) libraries -- usually have the performance critical core written in [C](c.md). Normies will tell you that for things outside this scope C is not a good language, with which we disagree -- [we](lrs.md) recommend using C for basically everything that's supposed to last, i.e. if you want to write a good website, you should write it in C etc.
|
||||
Mainstream consensus acknowledges that C is among the best languages for writing low level code and code that requires **performance**, such as [operating systems](operating_system.md), [drivers](driver.md) or [games](game.md). Even scientific libraries with normie-language interfaces -- e.g. various [machine learning](machine_learning.md) [Python](python.md) libraries -- usually have the performance critical core written in [C](c.md). Normies will tell you that for things outside this scope C is not a good language, with which we disagree -- [we](lrs.md) recommend using C for basically everything that's supposed to last, i.e. if you want to write a good website, you should write it in C etc.
|
||||
|
||||
**Is C low or high level?** This depends on the context. Firstly back in the day when most computers were programmed in [assembly](assembly.md), C was seen as high level, simply because it offered the highest level of abstraction at the time, while nowadays with languages like [Python](python.md) and [JavaScript](js.md) around people see C as very low level by comparison -- so it really depends on if you talk about C in context of "old" or "modern" programming and which languages you compare it to. Secondly it also depends on HOW you program in C -- you may choose to imitate assembly programming in C a lot, avoid using libraries, touch hardware directly, avoid using complex features and creating your own abstractions -- here you are really doing low level programming. On the other hand you can emulate the "modern" high-level style programming in C too, you can even mimic [OOP](oop.md) and make it kind of "C++ with different syntax", you may use libraries that allow you to easily work with strings, heavy macros that pimp the language to some spectacular abomination, you may write your own garbage collector etc. -- here you are basically doing high level programming in C.
|
||||
|
||||
## History and Context
|
||||
|
||||
|
|
|
@ -220,4 +220,5 @@ Game of Life can be extended/generalized/modified in great number of ways, some
|
|||
|
||||
## See Also
|
||||
|
||||
- [polyworld](polyworld.md)
|
||||
- [polyworld](polyworld.md)
|
||||
- [Resnick's termite](resnicks_termite.md)
|
|
@ -12,6 +12,8 @@ Around 50 AD Heron of Alexandria, an Egyptian mathematician, created a number of
|
|||
|
||||
In the 3rd century Chinese mathematician Liu Hui describes operations with **negative numbers**, even though negative numbers have already appeared before. In 600s AD an Indian astronomer Brahmagupta first used the number **[zero](zero.md)** in a systematic way, even though hints on the number zero without deeper understanding of it appeared much earlier. In 9th century the Mayan empire is [collapsing](collapse.md), though it would somewhat recover and reshape.
|
||||
|
||||
In 1429 Persian mathematician al-Kashi computed [pi](pi.md) to about 14 digit accuracy which was a great leap in this discipline.
|
||||
|
||||
Around the year of [our Lord](jesus.md) 1450 a major technological leap known as the **Printing Revolution** occurred. Johannes Gutenberg, a German goldsmith, perfected the process of producing books in large quantities with the movable type press. This made books cheap to publish and buy and contributed to fast spread of information and better education. Around this time the **Great Wall of China** is being built.
|
||||
|
||||
They year 1492 marks the **discovery of America** by Christopher Columbus who sailed over the Atlantic Ocean, though he probably wasn't the first in history to do so, and it wasn't realized he sailed to America before his death.
|
||||
|
@ -28,7 +30,7 @@ In 1822 [Charles Babbage](charles_babbage.md), a great English mathematician, co
|
|||
|
||||
In 1826 or 1827 French inventor Nicéphore Niépce captured **first [photography](photo.md)** that survived until today -- a view from his estate named Le Gras. About an 8 hour exposure was used (some say it may have taken several days). He used a [camera obscura](camera_obscura.md) and asphalt plate that hardened where the light was shining. Earlier cases of photography existed maybe as early as 1717, but they were only short lived.
|
||||
|
||||
**Sound recording** with phonatograph was invented in 1857 in Paris, however it could not be played back at the time -- the first record of human voice made with this technology can nowadays be reconstructed and played back. It wouldn't be until 1878 when people could both record and play back sounds with [Edison](edison.md)'s improvement of phonatograph. A year later, in 1879, Edison also patented the **light bulb**, even though he didn't invent it -- there were at least 20 people who created a light bulb before him.
|
||||
**Sound recording** with phonatograph was invented in 1857 in Paris, however it could not be played back at the time -- the first record of human voice made with this technology can nowadays be reconstructed and played back. It wouldn't be until 1878 when people could both record and play back sounds with [Edison](edison.md)'s improvement of phonatograph. A year later, in 1879, Edison also patented the **light bulb**, even though he didn't invent it -- there were at least 20 people who created a light bulb before him. [Pi](pi.md) at this time is evaluated to roughly 500 digit accuracy (using Machin's formula).
|
||||
|
||||
Around 1888 so called **war of the currents** was taking place; it was a heated battle between companies and inventors for whether the [alternating](ac.md) or [direct](dc.md) current would become the standard for distribution of electric energy. The main actors were [Thomas Edison](edison.md), a famous iventor and a huge capitalist dick rooting for DC, and George Westinghouse, the promoter of AC. Edison and his friends used false claims and even killing of animals to show that AC was wrong and dangerous, however AC was objectively better, e.g. by its efficiency thanks to using high voltage, and so it ended up winning the war. AC was also supported by the famous genius inventor [Nikola Tesla](tesla.md) who during these times contributed hugely to electric engineering, he e.g. invented an AC motor and Tesla coil and created a system for wireless transmission of electric power.
|
||||
|
||||
|
|
|
@ -12,6 +12,10 @@ Firstly let us welcome you, no matter who you are, no matter your political opin
|
|||
|
||||
OK, let's say this is a set of general advice, life heuristics, pointers and basics of our philosophy, something to get you started, give you a point of view aligned with what we do, help you make a decision here and there, help you free yourself. Remember that by definition **nothing we ever advice is a commandment** or a rule you mustn't ever break, that would be wrong in itself. Some things also may be yet a "thought in progress" and change.
|
||||
|
||||
### How To Read This How To
|
||||
|
||||
Use your eyes to read the letters from left to right and top to bottom. If this is too hard read a how to read a how to read a how to.
|
||||
|
||||
### Required Time To Read
|
||||
|
||||
Depends on how fast you read.
|
||||
|
|
|
@ -8,6 +8,8 @@ Access to the Internet is offered by [ISPs](isp.md) (internet service providers)
|
|||
|
||||
The following are some stats about the Internet as of 2022: there are over 5 billion users world-wide (more than half of them from Asia and mostly young people) and over 50 billion individual devices connected, about 2 billion websites (over 60% in [English](english.md)) on the web, hundreds of billions of emails are sent every day, average connection speed is 24 Mbps, there are over 370 million registered [domain](domain.md) names (most popular [TLD](tld.md) is .com), [Google](google.com) performs about 7 billion web searches daily (over 90% of all search engines).
|
||||
|
||||
PRO TIP: **you should print your own offline Internet** (or maybe we should rather say offline [web](www.md)). Collect your favorite websites and other resources (gopher holes, Usenet threads, images, ...) and make a single dense [PDF](pdf.md) out of them. Process each page so that it's just plain text, remove all graphics and colors, unify the font, make the font small and decrease margins so that you fit as much as possible on a single page to not waste paper. For many pages, like Wikipedia, a small script will be able to do this automatically; the uglier pages may just be edited manually. An easy approach is for example to convert the pages to plain HTML that just contains paragraphs and heading of different levels, then copy-pasting this to LibreOffice, globally editing the font and auto-generate things like table of contents and page numbers, then exporting as PDF. You can even make a script that contains the list of pages you want to scrap so that you can make a newer print a few years later. Once you have the PDF, print it out and have your own tiny offline net :) It will be useful [when the lights go out](collapse.md), it's a physical backup of your favorite sites (the PDF, as a byproduct, is also a single-file backup in electronic form), something no one will be silently censoring under your hands, and it's also just nice to read through printed pages, the experience is better than reading stuff on the screen -- this will be like your own 100% personalized book with stuff you find most interesting, in a form that's comfortable to read.
|
||||
|
||||
## History
|
||||
|
||||
*see also [history](history.md)*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Langton's Ant
|
||||
|
||||
Langton's ant is a simple [zero player](zero_player.md) [game](game.md) and [cellular automaton](cellular_automaton.md) simulating the behavior of an ant that behaves according to extremely simple rules but nevertheless builds a very complex structure. It is similar to [game of life](game_of_life.md). Langton's ant is **[Turing complete](turing_complete.md)** (it can be used to perform any computation that any other computer can).
|
||||
Langton's ant (also *virtual ant* or *vant*) is a simple [zero player](zero_player.md) [game](game.md) and [cellular automaton](cellular_automaton.md) simulating the behavior of an ant that behaves according to extremely simple rules but nevertheless builds a very complex structure. It is similar to [game of life](game_of_life.md). Langton's ant is **[Turing complete](turing_complete.md)** (it can be used to perform any computation that any other computer can).
|
||||
|
||||
**Rules**: in the basic version the ant is placed in a square grid where each square can be either white or black. Initially all squares are white. The ant can face north, west, south or east and operates in steps. In each step it does the following: if the square the ant is on is white (black), it turns the square to black (white), turns 90 degrees to the right (left) and moves one square forward.
|
||||
|
||||
|
@ -151,7 +151,9 @@ int main(void)
|
|||
|
||||
## See Also
|
||||
|
||||
- [Resnick's termite](resnicks_termite.md)
|
||||
- [game of life](game_of_life.md)
|
||||
- [turmite](turmite.md)
|
||||
- [rule 110](rule_110.md)
|
||||
- [cellular automaton](cellular_automaton.md)
|
||||
- [cellular automaton](cellular_automaton.md)
|
||||
- [turtle graphics](turtle_graphics.md)
|
|
@ -1,6 +1,6 @@
|
|||
# Mandelbrot Set
|
||||
|
||||
Mandelbrot set is a famous two dimensional [fractal](fractal.md), a [set](set.md) of [points](point.md) in two dimensional plane that are defined by a specific very simple equation. It turns out this set has an infinitely complex border (i.e. its shape is a fractal) and the whole thing is just [beautiful](beauty.md) to look at, especially when we draw it with colors and start zooming in to various interesting places -- patterns keep emerging down to infinitely small scales so we may keep zooming in forever and still discover new and new things; some patterns show self similarity, some not. Applying tricks to further add colors to inside and outside of the set increases the visual beauty yet more -- rendering Mandelbrot set is in fact a quite popular activity among programmers as it's very easy to [program](programming.md) such visualizations (at least until we reach the limits of [floating point](float.md) precision, then some more cleverness has to be applied; and yes, Mandelbrot can also be rendered only using [fixed point](fixed_point.md)). The origins of exploring this set are somewhere around 1905 when Fatou and Julia explored the equations related to it, however due to the lack of [computers](computer.md) the set couldn't very well be drawn -- this was only achieved much later, the first rendering of the set seems to be from 1978, albeit of very poor resolution. The set is named after Benoit Mandelbrot who is often considered the father of the field of fractal geometry and who researched this particular set a lot. Of course, Mandelbrot set is awesome, it's a like a whole infinite world to explore, hidden in just one simple formula.
|
||||
Mandelbrot set (also M-set) is a famous two dimensional [fractal](fractal.md), a [set](set.md) of [points](point.md) in two dimensional plane that are defined by a specific very simple equation. It turns out this set has an infinitely complex border (i.e. its shape is a fractal) and the whole thing is just [beautiful](beauty.md) to look at, especially when we draw it with colors and start zooming in to various interesting places -- patterns keep emerging down to infinitely small scales so we may keep zooming in forever and still discover new and new things; some patterns show self similarity, some not. Applying tricks to further add colors to inside and outside of the set increases the visual beauty yet more -- rendering Mandelbrot set is in fact a quite popular activity among programmers as it's very easy to [program](programming.md) such visualizations (at least until we reach the limits of [floating point](float.md) precision, then some more cleverness has to be applied; and yes, Mandelbrot can also be rendered only using [fixed point](fixed_point.md)). The origins of exploring this set are somewhere around 1905 when Fatou and Julia explored the equations related to it, however due to the lack of [computers](computer.md) the set couldn't very well be drawn -- this was only achieved much later, the first rendering of the set seems to be from 1978, albeit of very poor resolution. The set is named after Benoit Mandelbrot who is often considered the father of the field of fractal geometry and who researched this particular set a lot. Of course, Mandelbrot set is awesome, it's a like a whole infinite world to explore, hidden in just one simple formula.
|
||||
|
||||
{ Pretty amazing ASCII rendering of the Mandelbrot set can be found at http://www.mrob.com/pub/muency/asciigraphics.html. ~drummyfish }
|
||||
|
||||
|
@ -55,6 +55,7 @@ The following are some **attributes** of the Mandelbrot set:
|
|||
- **area**: approximately 1.5052; this is a current best estimate, the area is not easy to calculate (it may be estimated e.g. with [Monte Carlo](monte_carlo.md) methods).
|
||||
- It is **symmetric** along the *x* axis.
|
||||
- It's proven the set is **connected**, i.e. it's just a single "island".
|
||||
- The number [pi](pi.md) is embedded in the shape of the set in a hugely mysterious way which was discovered by mistake by David Bolle in 1991 who tried to measure the width of the gap touching the point [-0.75,0] -- as he increased precision of his iterative algorithm, the number of iterations started to approximate digits of pi.
|
||||
- ...
|
||||
|
||||
**How to explore Mandelbrot set?** There are about billion programs for this, but a quite nice FOSS one is e.g. [Xaos](xaos.md).
|
||||
|
|
|
@ -14,7 +14,7 @@ Pedophilia (also paedophilia or paedosexuality) is a sexual orientation towards
|
|||
|
||||
*NOTE for pedophobes:* please attend [this anonymous self-help program](unretard.md).
|
||||
|
||||
Unlike for example pure [homosexuality](gay.md), pedophilia is completely natural, normal (with many studies confirming this, some links e.g. [here](https://incels.wiki/w/Scientific_Blackpill#It_is_normal_for_healthy_men_to_find_pubescent_.26_prepubescent_females_sexually_arousing)) and not any more harmful than any other orientation, however it is nowadays wrongfully, for political reasons, labelled a "disorder" (just as homosexuality used to be not a long time ago). It is the forbidden, tabooed, censored and bullied sexual orientation of the [21st century](21st_century.md), even though all healthy people are pedophiles -- just don't pretend you've never seen a [jailbait](jailbait.md) you found sexy, people start being sexually attractive exactly as soon as they become able to reproduce; furthermore when you've gone without sex long enough and get extremely horny, you get turned on by anything that literally has some kind of hole in it -- this is completely normal. Basically everyone has some kind of weird fetish he hides from the world, there are people who literally fuck cars in their exhausts, people who like to eat shit, dress in diapers and hang from ceiling by their nipples, people who have sexual relationships with virtual characters etc. -- this is all considered normal, but somehow once you get an erection seeing a hot 17 year old girl, you're a demon that needs to be locked up and cured, if not executed right away, just for a thought present in your mind.
|
||||
Unlike for example pure [homosexuality](gay.md), pedophilia is completely natural and normal -- many studies confirm this (some links e.g. [here](https://incels.wiki/w/Scientific_Blackpill#It_is_normal_for_healthy_men_to_find_pubescent_.26_prepubescent_females_sexually_arousing)) but if you're not heavily brainwashed you don't even need any studies (it's really like wanting to see studies on whether men want to have sex with women at all): wanting to have sex with young, sexually mature girls who are able to reproduce is, despite it being forbidden by law, as normal as wanting to have sex with a woman that is married to someone else, despite it being culturally forbidden, or wanting to punch someone who is really annoying, despite it being forbidden by law. No one can question that pedophilia is natural, the only discussion can be about it being harmful and here again it has to be said it is NOT any more harmful than any other orientation. Can it harm someone? Yes, but so can any other form of sex or any human interaction whatsoever, that's not a reason to ban it. Nevertheless, pedophilia is nowadays wrongfully, mostly for political and historical reasons, labeled a "disorder" (just as homosexuality used to be not a long time ago). It is the forbidden, tabooed, censored and bullied sexual orientation of the [21st century](21st_century.md), even though all healthy people are pedophiles -- just don't pretend you've never seen a [jailbait](jailbait.md) you found sexy, people start being sexually attractive exactly as soon as they become able to reproduce; furthermore when you've gone without sex long enough and get extremely horny, you get turned on by anything that literally has some kind of hole in it -- this is completely normal. Basically everyone has some kind of weird fetish he hides from the world, there are people who literally fuck cars in their exhausts, people who like to eat shit, dress in diapers and hang from ceiling by their nipples, people who have sexual relationships with virtual characters etc. -- this is all considered normal, but somehow once you get an erection seeing a hot 17 year old girl, you're a demon that needs to be locked up and cured, if not executed right away, just for a thought present in your mind.
|
||||
|
||||
Even though one cannot choose this orientation and even though pedophiles don't hurt anyone any more than for example gay people do, they are highly oppressed and tortured. Despite what the propaganda says, a **pedophile is not automatically a rapist** of children (a pedophile will probably choose to never actually even have sex with a child) any more than a gay man is automatically a rapist of people of the same sex, and watching [child porn](child_porn.md) won't make you want to rape children any more than watching gay porn will make you want to rape people of the same sex. Nevertheless the society, especially the fascists from the [LGBT](lgbt.md) movement who ought to know better than anyone else what it is like to be oppressed only because of private sexual desires, actively hunt pedophiles, [bully](cancel_culture.md) them and lynch them on the Internet and in the [real life](irl.md) -- this is done by both both civilians and the state (I shit you not, in [Murica](usa.md) there are whole police teams of pink haired lesbians who pretend to be little girls on the Internet and tease guys so that they can lock them up and get a medal for it). LGBT activists proclaim that a "child can't consent" but at the same time tell you that "a prepubescent child can make a decision about changing its sex" (yes, it's happening, even if parent's agreement is also needed, would parents also be able to allow a child to have sex if it wishes to?). There is a literal **witch hunt** going on against completely innocent people, just like in the middle ages. Innocent people are tortured, castrated, cancelled, rid of their careers, imprisoned, beaten, rid of their friends and families and pushed to suicide sometimes only for having certain files on their computers or saying something inappropriate online (not that any of the above is ever justified to do to anyone, even the worst criminal).
|
||||
|
||||
|
|
22
pi.md
22
pi.md
|
@ -1,6 +1,8 @@
|
|||
# Pi
|
||||
|
||||
Pi is one of the most important and famous [numbers](number.md), equal to approximately 3.14, most popularly defined as the ratio of a circle's circumference to its diameter (but also definable in other ways). It is one of the most fundamental mathematical constants of our universe and appears extremely commonly in [mathematics](math.md), nature and, of course, [programming](programming.md). When written down in traditional decimal system, its digits go on and on without end and show no repetition or simple pattern, appearing "random" and [chaotic](chaos.md) -- as of 2021 pi has been evaluated by [computers](computer.md) to 62831853071796 digits. In significance and properties pi is similar to another famous number: [e](e.md).
|
||||
Pi is one of the most important and famous [numbers](number.md), equal to approximately 3.14, most popularly defined as the ratio of a circle's circumference to its diameter (but also definable in other ways). It is one of the most fundamental mathematical constants of our universe and appears extremely commonly in [mathematics](math.md), nature and, of course, [programming](programming.md). When written down in traditional decimal system, its digits go on and on without end and show no repetition or simple pattern, appearing "random" and [chaotic](chaos.md) -- as of 2021 pi has been evaluated by [computers](computer.md) to 62831853071796 digits. In significance and properties pi is similar to another famous number: [e](e.md). Pi day is celebrated on March 14.
|
||||
|
||||
{ Very nice site about pi: http://www.pi314.net. ~drummyfish }
|
||||
|
||||
Pi is a [real](real_number.md) [transcendental](transcendental.md) number, i.e. simply put *it cannot be defined by a "simple" equation* (it is not a root of any [polynomial](polynomial.md) equation). As a transcendental number it is also an [irrational](irrational.md) number, i.e. it cannot be written as an integer [fraction](fraction.md). Mathematicians nowadays define pi via the period of the [exponential function](exp.md) rather than geometry of circles. If we stick to circles, it is [interesting](interesting.md) that in [non-Euclidean](non_euclidean.md) geometry the value of "pi" could be measured to different values (if we draw a circle on an equator of a ball, its circumference is just twice its diameter, i.e. "pi" would be measured to be just 2, reveling the curvature of space).
|
||||
|
||||
|
@ -12,7 +14,9 @@ Pi to 100 binary fractional digits is:
|
|||
|
||||
11.001001000011111101101010100010001000010110100011000010001101001100010011000110011000101000101110000...
|
||||
|
||||
Some people memorize digits of pi for [fun](fun.md) and competition, the world record as of 2022 is 70030 memorized digits. Some people make [mnemonics](mnemonic.md) for remembering the digits of pi (this is known as *PiPhilology*), for example *"Now I fuck a pussy screaming in orgasm"* is a sentence that helps remember the first 8 digits (number of letters in each word encodes the digit).
|
||||
Among the first 50 billion digits the most common one is 8, then 4, 2, 7, 0, 5, 9, 1, 6 and 3.
|
||||
|
||||
Some people memorize digits of pi for [fun](fun.md) and competition, the official world record as of 2022 is 70030 memorized digits, however Akira Haraguchi allegedly holds an unofficial record of 100000 digits (made in 2006). Some people make [mnemonics](mnemonic.md) for remembering the digits of pi (this is known as *PiPhilology*), for example *"Now I fuck a pussy screaming in orgasm"* is a sentence that helps remember the first 8 digits (number of letters in each word encodes the digit).
|
||||
|
||||
**PI IS NOT INFINITE**. [Soyence](soyence.md) popularizators and nubs often say shit like "OH LOOK pi is so special because it infiniiiiiite". Pi is completely finite with an exact value that's not even greater than 4, what's infinite is just its expansion in [decimal](decimal.md) (or similar) numeral system, however this is nothing special, even numbers such as 1/3 have infinite decimal expansion -- yes, pi is more interesting because its decimal digits are non-repeating and appear [chaotic](chaos.md), but that's nothing special either, there are infinitely many numbers with the same properties and mysteries in this sense (most famously the number [e](e.md) but besides it an infinity of other no-name numbers). The fact we get an infinitely many digits in expansion of pi is given by the fact that we're simply using a system of writing numbers that is made to handle integers and simple fractions -- once we try to write an unusual number with our system, our [algorithm](algorithm.md) simply ends up stuck in an [infinite loop](infinite_loop.md). We can create systems of writing numbers in which pi has a finite expansion (e.g. base pi), in fact we can already write pi with a single symbol: *pi*. So yes, pi digits are interesting, but they are NOT what makes pi special among other numbers.
|
||||
|
||||
|
@ -24,16 +28,26 @@ What makes pi special then? Well, mostly its significance as one of the most fun
|
|||
|
||||
Evaluating many digits of pi is mathematically [interesting](interesting.md), programs for computing pi are sometimes used as [CPU](cpu.md) [benchmarks](benchmark.md). There are programs that can search for a position of arbitrary string encoded in pi's digits. However in practical computations we can easily get away with pi approximated to just a few decimal digits, **you will NEVER need more than 20 decimal digits**, not even for space flights (NASA said they use 15 places).
|
||||
|
||||
One way to judge the quality of pi approximation can be to take the number of pi digits it accurately represents versus how many digits there are in the approximation formula -- this says kind of the approximation's [compression](compression.md) ratio. But other factors may be important too, e.g. simplicity of evaluation, functions used etc.
|
||||
|
||||
An ugly engineering [approximation](approximation.md) that's actually usable sometimes (e.g. for fast rough estimates with integer-only hardware) is just (infamously almost made the legal value of pi by the so called Indiana bill in 1897)
|
||||
|
||||
pi ~= 3
|
||||
|
||||
A simple fractional approximation (correct to 6 decimal fractional digits) is
|
||||
A simple fractional approximation (correct to 6 decimal fractional digits, by Tsu Chung Chih) is
|
||||
|
||||
pi ~= 355/113
|
||||
|
||||
Such a fraction can again be used even without [floating point](float.md) -- let's say we want to multiply number 123 by pi, then we can use the above fraction and compute 355/113 * 123 = (355 * 123) / 113.
|
||||
|
||||
Srinivasa Ramanujan made a great number of pi approximations, e.g. an improvement of the previous to (14 correct digits):
|
||||
|
||||
pi ~= 355/113 * (1 - 0.0003/3533)
|
||||
|
||||
Similarly Plouffe, e.g. (30 correct digits):
|
||||
|
||||
pi ~= ln(262537412640768744)/sqrt(163)
|
||||
|
||||
Leibnitz formula for pi is an infinite series that converges to the value of pi, however it converges very slowly { Quickly checked, after adding million terms it was accurate to 5 decimal fractional places. ~drummyfish }. It goes as
|
||||
|
||||
pi = 4 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + ...
|
||||
|
@ -46,6 +60,8 @@ A simple **[algorithm](algorithm.md)** for computing approximate pi value can be
|
|||
|
||||
Another simple approach is [monte carlo](monte_carlo.md) estimation of the area of a unit circle -- by generating random (or even regularly spaced) 2D points (samples) with coordinates in the range from -1 to 1 and seeing what portion of them falls inside the circle we can estimate the value of pi as *pi = 4 * x/N* where *x* is the number of points that fall in the circle and *N* the total number of generated points.
|
||||
|
||||
Digits of pi also emerge when trying to measure some distances inside [Mandelbrot set](mandelbrot_set.md) (see David Bolle, 1991) -- this can perhaps also be exploited.
|
||||
|
||||
[Spigot](spigot.md) algorithm can be used for computing digits of pi one by one, without [floating point](float.md). Bailey-Borwein-Plouffe formula (discovered in 1995) interestingly allows computing Nth hexadecimal (or binary) digit of pi, WITHOUT having to compute previous digits (and in a time faster than such computation would take). In 2022 Plouffe discovered a similar formula for computing Nth decimal digit.
|
||||
|
||||
The following is a [C](c.md) implementation of the Spigot algorithm for calculating digits of pi one by one that doesn't need [floating point](float.md) or special arbitrary length data types, adapted from the original 1995 paper. It works on the principle of converting pi to the decimal base from a special mixed radix base 1/3, 2/5, 3/7, 4/9, ... in which pi is expressed just as 2.22222... { For copyright clarity, this is NOT a web copy paste, it's been written by me according to the paper. ~drummyfish }
|
||||
|
|
|
@ -17,7 +17,7 @@ int square(int x)
|
|||
return x * x;
|
||||
}
|
||||
|
||||
int main()
|
||||
int main(void)
|
||||
{
|
||||
for (int i = 0; i < 5; ++i)
|
||||
printf("%d squared is %d\n",i,square(i));
|
||||
|
@ -39,11 +39,16 @@ Which prints:
|
|||
We divide programming languages into different groups. Perhaps the most common divisions is to two groups:
|
||||
|
||||
- **compiled** languages: Meant to be transformed by a [compiler](compiler.md) to a [native](native.md) (directly executable) binary program, i.e. before running the program we have to run it through the process of compilation into runnable form. These languages are typically more efficient but usually more difficult to program in, less flexible and the compiled programs are non-portable (can't just be copy-pasted to another computer with different [architecture](isa.md) and expected to run; note that this doesn't mean compiled languages aren't [portable](portability.md), just that the compiled EXECUTABLE is not). These languages are usually [lower level](low-level), use static and strong [typing](typing.md) and more of manual [memory management](memory_management.md). Examples: [C](c.md), [C++](cpp.md), [go](go.md), [Haskell](haskell.md) or [Pascal](pascal.md).
|
||||
- **interpreted** languages: Meant to be interpreted by an [interpreter](interpreter.md) "on-the-go", i.e. what we write we can also immediately run; these languages are often used for [scripting](scripting.md). To run such program you need the interpreter of the language installed on your computer and this interpreter reads the [source code](source_code.md) as it is written and performs what it dictates (well, this is actually simplified as the interpreter normally also internally does a kind of quick "lightweight" compilation, but anyway...). These languages are generally less efficient (slower, use more RAM) but also more flexible, easier to program in and [independent of platforms](platform_independent.md). These languages usually [higher-level](high_level.md), use weak and dynamic [typing](typing.md) and automatic [memory management](memory_management.md) ([garbage collection](garbage_collection.md), ...). Examples: [Python](python.md), [Perl](perl.md), [JavaScript](js.md) and [BASH](bash.md).
|
||||
- **interpreted** languages: Meant to be interpreted by an [interpreter](interpreter.md) "on-the-go", i.e. what we write we can also immediately run; these languages are often used for **[scripting](scripting.md)**. To run such program you need the interpreter of the language installed on your computer and this interpreter reads the [source code](source_code.md) as it is written and performs what it dictates (well, this is actually simplified as the interpreter normally also internally does a kind of quick "lightweight" compilation, but anyway...). These languages are generally less efficient (slower, use more RAM) but also more flexible, easier to program in and [independent of platforms](platform_independent.md). These languages usually [higher-level](high_level.md), use weak and dynamic [typing](typing.md) and automatic [memory management](memory_management.md) ([garbage collection](garbage_collection.md), ...). Examples: [Python](python.md), [Perl](perl.md), [JavaScript](js.md) and [BASH](bash.md).
|
||||
|
||||
Sometimes the distinction here may not be completely clear, for example Python is normally considered an interpreted language but it can also be compiled into [bytecode](bytecode.md) and even native code. [Java](java.md) is considered more of a compiled language but it doesn't compile to native code (it compiles to bytecode). [C](c.md) is traditionally a compiled language but there also exist C interpreters. [Comun](comun.md) is meant to be both compiled and interpreted etc.
|
||||
|
||||
We can divide language in many more ways, for example based on their **[paradigm](paradigm.md)** (roughly its core idea/model/"philosophy", e.g. [impertaive](imperative.md), [declarative](declarative.md), [object-oriented](oop.md), [functional](functional.md), [logical](logical.md), ...), **purpose** (general purpose, special purpose), computational power ([turing complete](turing_complete.md) or weaker), level of **[abstraction](abstraction.md)** (high, low), [typing](data_type.md) (strong, weak, dynamic, static) or function evaluation (strict, lazy).
|
||||
Another common division is by **level of [abstraction](abstraction.md)** roughly to (keep in mind the transition is gradual and depends on context, the line between low and high level is extremely fuzzy):
|
||||
|
||||
- **[low level](low_level.md)**: Languages which are so called "closer to [hardware](hardware.md)" ("glorified [assembly](assembly.md)"), using little to no abstraction (reflecting more how a computer actually works under the hood without adding too many artificial concepts above it, allowing direct access to memory with [pointers](pointer.md), ...), for this they very often use plain [imperative](imperative.md) paradigm), being less comfortable (requiring the programmer to do many things manually), less flexible, less safe (allowing shooting oneself in the foot). However (because [less is more](less_is_more.md)) they have great many advantages, e.g. being [simple](kiss.md) to implement (and so more [free](freedom.md)) and **greatly efficient** (being fast, memory efficient, ...). One popular definition is also that "a low level language is that which requires paying attention to the irrelevant". Low level languages are **typically compiled** (but it doesn't have to be so). Where exactly low level languages end is highly subjective, many say [C](c.md), [Fortran](fortran.md), [Forth](forth.md) and similar languages are low level (normally when discussing them in context of new, very high level languages), others (mainly the older programmers) say only [assembly](assembly.md) languages are low level and some will even say only [machine code](machine_code.md) is low level.
|
||||
- **[high level](high_level.md)**: Languages with higher level of abstraction than low level ones -- they are normally more complex (though not always), interpreted (again, not necessarily), comfortable, dynamically typed, beginner friendly, "safe" (having various safety mechanism, automatic checks, automatic memory management such as [garbage collection](garbage_collection.md)) etc. For all this they are typically slower, less memory efficient, and just more [bloated](bloat.md). Examples are [Python](python.md) or [JavaScript](js.md).
|
||||
|
||||
We can divide language in many more ways, for example based on their **[paradigm](paradigm.md)** (roughly its core idea/model/"philosophy", e.g. [impertaive](imperative.md), [declarative](declarative.md), [object-oriented](oop.md), [functional](functional.md), [logical](logical.md), ...), **purpose** (general purpose, special purpose), computational power ([turing complete](turing_complete.md) or weaker, many definitions of a programming language require Turing completeness), [typing](data_type.md) (strong, weak, dynamic, static) or function evaluation (strict, lazy).
|
||||
|
||||
A computer language consists from two main parts:
|
||||
|
||||
|
@ -68,7 +73,7 @@ Now that we have a specification, i.e. the idea, someone has to realize it, i.e.
|
|||
|
||||
A new language comes to existence just as other things do -- when there is a reason for it. I.e. if someone feels there is no good language for whatever he's doing or if someone has a brilliant idea and want to write a PhD thesis or if someone smokes too much weed or if a corporation wants to control some software platform etc., a new language may be made. This often happen gradually (again, like with many things), i.e. someone just starts modifying an already existing language -- at first he just makes a few macros, then he starts making a more complex preprocessor, then he sees it's starting to become a new language so he gives it a name and makes it a new language -- such language may at first just be transpiled to another language (often [C](c.md)) and over time it gets its own full compiler. At first a new language is written in some other language, however most languages aim for **[self hosted](self_hosting.md) implementation**, i.e. being written in itself. This is natural and has many advantages -- a language written in itself proves its maturity, it becomes independent and as it itself improves, so does its own compiler. Self hosting a language is one of the greatest milestones in its life -- after this the original implementation in the other language often gets deletes as it would just be a burden to keep [maintaining](maintenance.md) it.
|
||||
|
||||
**So can a language be [bloated](bloat.md)?** Well, yes, if we consider that a very complicated language just cannot be implemented in a simple, non-bloated way -- we can say the language itself is inevitably bloated. It may contain features that will be rarely used, it may be inelegant etc. However many times when referring to language we just refer to its implementation(s). **How to tell if language is bloated?** One can get an idea from several things, e.g. list of features, [paradigm](paradigm.md), size of its implementations, size of the specification, year of creation (newer mostly means more bloat) and so on. However be careful, many of these are just clues, for example small specification may just mean it's vague. Even a small self hosted implementation doesn't have to mean the language is small -- imagine e.g. a language that just does what you write in plain English; such language will have just one line self hosted implementation: "Implement yourself." But to actually [bootstrap](boot.md) the language will be immensely difficult and will require a lot of bloat.
|
||||
**So can a language be inherently fast, [bloated](bloat.md) etc.?** When we say a language is fast, bloated, memory efficient and so on, we often refer to its implementations because, as mentioned, a language is just an idea which can be implemented in many ways with different priorities and tradeoffs, so just keep in mind that talking about languages like this usually refers to the implementations. But on the other hand yes, a language CAN itself be seen as inherently having a similar property because it's simply such that its implementations more or less have to have this property. A very complicated language just cannot be implemented in a simple, non-bloated way, an extremely high level and flexible language cannot be implemented to be among the fastest -- so referring to language implementations we also a little bit refer to the language itself as an implementation reflects the abstract language's properties. **How to tell if language is bloated?** One can get an idea from several things, e.g. list of features, [paradigm](paradigm.md), size of its implementations, size of the specification, year of creation (newer mostly means more bloat) and so on. However be careful, many of these are just clues, for example small specification may just mean it's vague. Even a small self hosted implementation doesn't have to mean the language is small -- imagine e.g. a language that just does what you write in plain English; such language will have just one line self hosted implementation: "Implement yourself." But to actually [bootstrap](boot.md) the language will be immensely difficult and will require a lot of bloat.
|
||||
|
||||
**Can you use multiple programming languages for one project?** Yes, though it may be a burden, so don't do it just because you can. Combining languages is possible in many ways, e.g. by embedding a [scripting](scripting.md) language into a compiled language, linking together object files produces by different languages, creating different programs that communicate over network etc.
|
||||
|
||||
|
|
3284
random_page.md
3284
random_page.md
File diff suppressed because it is too large
Load diff
207
resnicks_termite.md
Normal file
207
resnicks_termite.md
Normal file
|
@ -0,0 +1,207 @@
|
|||
# Resnick's Termite
|
||||
|
||||
WORK IN PROGRESS
|
||||
|
||||
{ Found this in the book *The Computational Beauty of Nature*. --drummyfish }
|
||||
|
||||
Resnick's termite is a simple [cellular automaton](cellular_automaton.md) simulating behavior of ants, demonstrating how even a very dumb behavior of a single agent can lead to higher collective intelligence once we increase the number of the agents. The simulation was made by Mitchel Resnick, the theme is similar to that of [Langton's ant](langtons_ant.md) but Resnick's termites are stochastic, [nondeterministic](determinism.md), they rather show how statistics/randomness in behavior help many ants build tunnels in sand. The game demonstrates how randomly scattered chips start getting chunked together and form tunnels once we let ants with extremely simple behavior work together on moving the chips. Besides this demonstration however there doesn't seem to be anything more interesting going on (at least until we start to modify and tweak the thing somehow).
|
||||
|
||||
The system is defined quite simply: we have a world made of cells, each cell can be either empty or have a wooden chip on it. In this world we have a number of ants, each of which behaves by the following [algorithm](algorithm.md):
|
||||
|
||||
1. Randomly walk around until you bump into a chip.
|
||||
2. If you are not carrying a chip, pick up the one you bumped into, otherwise drop the chip you are carrying. Go to step 1.
|
||||
|
||||
The original implementation had ants who had direction (up, right, down, left) and on each step could make a random turn to the right or left. If an ant bumped into a chip it turned 180 degrees. These things prevented some annoying patterns like an ant just picking up a chip and immediately dropping it etc. Some further modifications were suggested like giving the ants some simple sense of sight or teleporting them randomly after dropping the chip.
|
||||
|
||||
```
|
||||
iteration 0:
|
||||
----------------------------------------------------------------
|
||||
| , , ' ' , ' , ; ; ' ',,'' ', ' ' |
|
||||
| ' , , ' ' ' ',, ;' ,,, ,,, ; ' ;, |
|
||||
|, , ', ; ' ' ', ' , ' ',' ' ,, '' , ',|
|
||||
| ' ,;'' , ,', , , ' , '',' '',; ' , ,, ', |
|
||||
| , ',, ,,', , , ; ;', ,';' ,', ' , ' ;; ', |
|
||||
| ', ' ' ; ,, , , , ' , , ' , , , ' |
|
||||
| , ,', ,' ' '' ' ,' ' ; , ' ' ; , , ' ,, , , '|
|
||||
| , '' '' ' , ; ; ,;' '' ; ; ' '|
|
||||
| , ,, ;'' ', ; ' ' ' ,' ,,,, , , ', ,',,'; |
|
||||
| ' '',,' , ' ' , '',, ,, ,',' ' ; ' ' ,; |
|
||||
|',, ' , , , ' , , ' ;,, ' ' ,, ,';, , ; ;, ' ;|
|
||||
|, ' ' ' ' ;, ,,,; ', ; ' , ' '; , ' ; , ';, , |
|
||||
| ' ,' ', ' , , ' ', '' ' , ; ; ,, ,,, ;, ',' ', ' |
|
||||
|',, ' , ''' ' ,, ',' ' ' '' ,, , ', ' ',''|
|
||||
| , , , ,,';,;,, , , ' ,' ', ' ; ' |
|
||||
| , ' ,' , ; ' , , , , ' , '; ,, , ','', |
|
||||
| ,', ,' ' ,, ''' , ' ' ', ', ,,, ',|
|
||||
| ,',, ,, '; ,' ' ' ', ' , ' , ' ,; ; ' |
|
||||
|'' ',' ' , ' ,, , ' , ; ' ,'' , ,' ; ,', |
|
||||
| , ' ; , ' '''; , '',' , ' , '' ' ', |
|
||||
| ' , ' ' ' , , ' ,' '' ,', , ;,',,', '|
|
||||
| ' ', ''''; ''' , ' ,', ,'' ;' , , ' , , ;|
|
||||
|,, , ', ' , ;'' ' ' ,', ' , ,' ,, ' , |
|
||||
| ',', ' , ',' ,;, ,; ',,, ' ', ' ; |
|
||||
|' , ' , ' , ' ' , ; ' ' , ; ,; '' ' ,'' |
|
||||
| ; , ,;,; ' , ' '' , , , , ,,,' ' ,,' ,|
|
||||
| ' ,' '' ',, ' ', ' ; ; , ,, ' , |
|
||||
| , ; , ,;' , ' , '' ' '', , ; , , ,''' ' '|
|
||||
|, ;, , ' ,, ; ',,;,;'; ; ; , '' , ', |
|
||||
|,' '; , , ,, ' ,' '' ' ,' , '' ' ,, , ', , |
|
||||
|; ' ''' ' , , , ' ' , ,, ,' |
|
||||
|; , ' ' ' ' ', ''',, ', , ' , ,'|
|
||||
----------------------------------------------------------------
|
||||
|
||||
iteration 5963776:
|
||||
----------------------------------------------------------------
|
||||
| , ;;'; ' ;'; ';,, , ' , , ;' ,''; |
|
||||
| ';, ; ,,, , ,, ;,,'', ,,, ,; ; |
|
||||
| , ' ,' ,, '';' ' ' , ' ' '';|
|
||||
|, ,, , ,, ''; , ; ,';;,; |
|
||||
|' , ,,,'' '' ' ' ' ' '' ;' ,'''|
|
||||
|, ''; ,, ,'; , ;, ,, ; ; ,, ; |
|
||||
| ' , '' ' ';, ' ',; ; '';, ,' |
|
||||
| '', ' ', , ; '', '' ' , '',,, ' ,'|
|
||||
|, ; , ;' ' ; , ; ;; ,, ;|
|
||||
|, ; '; , ' ,;' ;;' ,''; |
|
||||
| ' , '; ;, ' ''' |
|
||||
|; ',' ,';,;' ' ,, , ' ; ', |
|
||||
|;, ,, ' ',;, , ;,,' |
|
||||
| ,';' ;'; ' ,,, '; '|
|
||||
|,, , ' , ' ;'''', ' ; , ' |
|
||||
|' ;,,;' '' ';,, ' ,, ; ';' ''' ,, ,,, ,|
|
||||
|,, ;, , ';; , ; ;, ', ,, ;' ,, ;;|
|
||||
| ;, ,;,;', ' ;;, '' ', ; |
|
||||
| ; , ' ,'' ,,' ,, ;' ;;,;; ' ',,;'' , |
|
||||
| ,; , , '' ' ,;, ,, ''' ' ;' |
|
||||
| ; ,;, , '' ' ;; ;; ; ' ' ,,' '' ,,; ,' ,|
|
||||
| , '' ';; ''' ,,;' ''' ' ' ; ;;' |
|
||||
| ,; ' ;;; ,, ,,''; ; ;', ;,,; , |
|
||||
|' ,; ,' ' , ; ' ' ,|
|
||||
|'' ,;,, ''; ' '' '' ,, |
|
||||
|'' ;, ,,, ;' '';,, ;' , , |
|
||||
| ,, ' ';;' ,' ';, |
|
||||
| , , , ',,; ;' '; |
|
||||
| ,, ;; , , ' ;, |
|
||||
| , ', '' , ; , ;, ;, |
|
||||
| '',,'' '' ,' ' ;, '' |
|
||||
| ,,'' ,, ' ; '' ' ; ';' ' ' ' ,, , ; ' |
|
||||
----------------------------------------------------------------
|
||||
```
|
||||
|
||||
Here is an extremely basic implementation in [C](c.md) (without the fancy behavior improvements mentioned above, to keep the code short):
|
||||
|
||||
```
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define WORLD_SIZE 64
|
||||
#define ANTS 200
|
||||
#define CHIP_DENSITY 5
|
||||
|
||||
unsigned char world[WORLD_SIZE * WORLD_SIZE]; // 0: empty, 1: chip
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int pos;
|
||||
unsigned char chip;
|
||||
} Ant;
|
||||
|
||||
Ant ants[ANTS];
|
||||
|
||||
void printHBorder(void)
|
||||
{
|
||||
for (int i = 0; i < WORLD_SIZE + 2; ++i)
|
||||
putchar((i != 0 && i != WORLD_SIZE + 1) ? '-' : ' ');
|
||||
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
void printWorld(void)
|
||||
{
|
||||
printHBorder();
|
||||
|
||||
for (int y = 0; y < WORLD_SIZE; y += 2)
|
||||
{
|
||||
putchar('|');
|
||||
for (int x = 0; x < WORLD_SIZE; ++x)
|
||||
{
|
||||
int n = y * WORLD_SIZE + x;
|
||||
|
||||
switch ((world[n] << 1) | (world[n + WORLD_SIZE]))
|
||||
{
|
||||
case 1: putchar('\''); break;
|
||||
case 2: putchar(','); break;
|
||||
case 3: putchar(';'); break;
|
||||
default: putchar(' '); break;
|
||||
}
|
||||
}
|
||||
|
||||
putchar('|');
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
printHBorder();
|
||||
}
|
||||
|
||||
void updateAnts(void)
|
||||
{
|
||||
for (int i = 0; i < ANTS; ++i)
|
||||
{
|
||||
int newPos = // this just randomly moves in one direction
|
||||
(WORLD_SIZE * WORLD_SIZE +
|
||||
ants[i].pos +
|
||||
((rand() % 2) ? ((rand() % 2) ? -1 : 1) :
|
||||
((rand() % 2) ? -1 * WORLD_SIZE : WORLD_SIZE)))
|
||||
% (WORLD_SIZE * WORLD_SIZE);
|
||||
|
||||
if (world[newPos]) // stepped on a chip?
|
||||
{
|
||||
if (ants[i].chip)
|
||||
{ // has chip; drop the chip
|
||||
if (!world[ants[i].pos])
|
||||
{
|
||||
ants[i].chip = 0;
|
||||
world[ants[i].pos] = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // no chip; pick up the chip
|
||||
world[newPos] = 0;
|
||||
ants[i].chip = 1;
|
||||
}
|
||||
}
|
||||
|
||||
ants[i].pos = newPos;
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
srand(123);
|
||||
|
||||
for (int i = 0; i < WORLD_SIZE * WORLD_SIZE; ++i)
|
||||
world[i] = (rand() % CHIP_DENSITY) == 0;
|
||||
|
||||
for (int i = 0; i < ANTS; ++i)
|
||||
{
|
||||
ants[i].pos = rand() % (WORLD_SIZE * WORLD_SIZE);
|
||||
ants[i].chip = 0;
|
||||
}
|
||||
|
||||
int i;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (i % 65536 == 0)
|
||||
{
|
||||
printf("iteration %d:\n",i);
|
||||
printWorld();
|
||||
}
|
||||
|
||||
updateAnts();
|
||||
i++;
|
||||
}
|
||||
|
||||
printWorld();
|
||||
return 0;
|
||||
}
|
||||
```
|
File diff suppressed because one or more lines are too long
|
@ -3,8 +3,8 @@
|
|||
This is an autogenerated article holding stats about this wiki.
|
||||
|
||||
- number of articles: 553
|
||||
- number of commits: 688
|
||||
- total size of all texts in bytes: 2961941
|
||||
- number of commits: 689
|
||||
- total size of all texts in bytes: 2965186
|
||||
|
||||
longest articles:
|
||||
|
||||
|
@ -24,6 +24,18 @@ longest articles:
|
|||
latest changes:
|
||||
|
||||
```
|
||||
Date: Mon Feb 12 20:36:38 2024 +0100
|
||||
art.md
|
||||
ascii_art.md
|
||||
jesus.md
|
||||
main.md
|
||||
mandelbrot_set.md
|
||||
quaternion.md
|
||||
ram.md
|
||||
random_page.md
|
||||
sw.md
|
||||
wiki_pages.md
|
||||
wiki_stats.md
|
||||
Date: Mon Feb 12 12:09:17 2024 +0100
|
||||
anarch.md
|
||||
bloat.md
|
||||
|
@ -45,16 +57,6 @@ Date: Sun Feb 11 21:31:18 2024 +0100
|
|||
random_page.md
|
||||
wiki_pages.md
|
||||
wiki_stats.md
|
||||
Date: Sun Feb 11 21:17:16 2024 +0100
|
||||
fractal.md
|
||||
lrs_wiki.md
|
||||
main.md
|
||||
mandelbrot_set.md
|
||||
minimalism.md
|
||||
plan9.md
|
||||
random_page.md
|
||||
wiki_pages.md
|
||||
wiki_stats.md
|
||||
```
|
||||
|
||||
most wanted pages:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
{ Still researching this shit etc. ~drummyfish }
|
||||
|
||||
XXIIVV is a [soynet](soynet.md) website and personal [wiki](wiki.md) (similar concept to [our wiki](lrs_wiki.md)) of a Canadian [egoist](egoism.md) [minimalist](minimalism.md)/esoteric programmer/artist/[generalist](generalism.md) David Mondou-Labbe who calls himself "Devine Lu Linvega" ([lmao](lmao.md)) who is a part of an artist/programmer group called [Hundred Rabbits](100r.md) (100r) who live on a small ship. David seems to be a normie [SJW](sjw.md) [fascist](fascist.md), proclaiming "aggressivity" on his web (under "/ethics.html" on his site). The site is accessible at http://wiki.xxiivv.com/site/home.html. There are some real good and pretty bad things about it.
|
||||
XXIIVV is a [soynet](soynet.md) website and personal [wiki](wiki.md) (similar concept to [our wiki](lrs_wiki.md)) of a Canadian [egoist](egoism.md) [minimalist](minimalism.md)/esoteric programmer/artist/[generalist](generalism.md) David Mondou-Labbe who calls himself "Devine Lu Linvega" ([lmao](lmao.md)) who is a part of a highly cringe artist/programmer group called [Hundred Rabbits](100r.md) (100r) who live on a small ship/boat. David seems to be a normie [SJW](sjw.md) [fascist](fascist.md), proclaiming "aggressivity" on his web (under "/ethics.html" on his site). The site is accessible at http://wiki.xxiivv.com/site/home.html. There are some real good and pretty bad things about it.
|
||||
|
||||
{ Holy shit his webring is cringe and toxic as fuck. One huge gay nazi wannabe "artist" circlejerk. It's like a small village worth of the kind of psychopaths who draw cute childish drawings of tiny animals with small hearts and love all around while at the same time advocating live castration of anyone who dislikes them. ~drummyfish }
|
||||
|
||||
|
|
Loading…
Reference in a new issue