master
Miloslav Ciz 12 months ago
parent 68a9873928
commit b761dff5c7

@ -4,7 +4,7 @@ Chess is a very old two-player board [game](game.md), perhaps most famous and po
{ There is a nice black and white indie movie called *Computer Chess* about chess programmers of the 1980s, it's pretty good, very oldschool, starring real programmers and chess players, check it out. ~drummyfish }
[Drummyfish](drummyfish.md) has created a suckless/[LRS](lrs.md) chess library [smallchesslib](smallchesslib.md) which includes a simple engine called *smolchess*.
[Drummyfish](drummyfish.md) has created a suckless/[LRS](lrs.md) chess library [smallchesslib](smallchesslib.md) which includes a simple engine called *smolchess* (and also a small chess game in [SAF](saf.md) with said library).
**At [LRS](lrs.md) we consider chess to be one of the best games** for the following reasons:

@ -0,0 +1,3 @@
# Cosine
TODO

@ -1,6 +1,6 @@
# Demoscene
Demoscene is a [hacker](hacking.md) [art](art.md) subculture revolving around making so called [demos](demo.md), programs that produce rich and interesting audiovisual effects and which are sometimes limited by strict size constraints (so called [intros](intro.md)). The scene originated in northern [Europe](europe.md) sometime in 1980s (even though things like screen hacks existed long before) among groups of [crackers](cracker.md) who were adding small signature effect screens into their cracked software (like "digital graffiti"); programming of these cool effects later became an art of its own and started to have their own competitions (sometimes with high financial prizes), so called *[compos](compo.md)*, at dedicated real life events called *[demoparties](demoparty.md)* (which themselves evolved from *[copyparties](copyparty.md)*, real life events focused on [piracy](piracy.md)). The community is still centered mostly in the Europe (primarily Finland), it is underground, out of the mainstream; [Wikipedia](wikipedia.md) says that by 2010 its size was estimated to 10000 people (such people are called *demosceners*).
Demoscene is a [hacker](hacking.md) [art](art.md) subculture revolving around making so called [demos](demo.md), programs that produce rich and interesting audiovisual effects and which are sometimes limited by strict size constraints (so called [intros](intro.md)). The scene originated in northern [Europe](europe.md) sometime in 1980s (even though things like screen hacks existed long before) among groups of [crackers](cracker.md) who were adding small signature effect screens into their cracked software (like "digital graffiti"); programming of these cool effects later became an art of its own and started to have their own competitions (sometimes with high financial prizes), so called *[compos](compo.md)*, at dedicated real life events called *[demoparties](demoparty.md)* (which themselves evolved from *[copyparties](copyparty.md)*, real life events focused on [piracy](piracy.md)). The community is still centered mostly in the Europe (primarily Finland, in some countries demoscene was even officially added to the cultural heritage), it is underground, out of the mainstream; [Wikipedia](wikipedia.md) says that by 2010 its size was estimated to 10000 people (such people are called *demosceners*).
Demoscene is a bittersweet topic: on one side it's awesome, full of beautiful hacking, great ideas and minimalism, on the other side there are secretive people who don't share their source code (most demos are [proprietary](proprietary.md)) and ugly unportable programs that exploit quirks of specific platforms -- common ones are [DOS](dos.md), [Commodore 64](c64.md), [Amiga](amiga.md) or [Windows](windows.md). These guys simply try to make the coolest visuals and smallest programs, with all good and bad that comes with it. Try to take only the good of it.

@ -64,6 +64,7 @@ Are you a noob but see our ideas as appealing and would like to join us? Say no
- That [capitalism](capitalism.md) is probably the most [retarded](retard.md) and dangerous idea in [history](history.md)?
- Thanks to [quantum computing](quantum.md) you can use a computer to [carry out computation](counterfactual_computing.md) without actually running the computer?
- You can mathematically [prove you don't know some information](no_knowledge_proof.md)?
- That in [capitalism](capitalism.md) low end [CPUs](cpu.md) are made by manufacturing a high end CPU and then purposefully crippling it, just for economic reasons? See e.g. [core unlocking](core_unlocking.md). This also goes for car engines etc.
- That a complement of a [formal language](formal_language.md) can be computationally simpler than the original -- for example that a [pushdown automaton](pushdown_automaton.md) cannot tell which strings are of form a^(n)b^(n)c^(n), but it can tell exactly which ones are not?
- That [LGBT](lgbt.md), [feminism](feminism.md) and similar movements are not truly leftist but rather [pseudoleftist](pseudoleft.md) and therefore [fascist](fascism.md)?

@ -18,4 +18,5 @@ It should be made clear that **rust is [shit](shit.md)** AND **CANNOT BE FIXED**
- It is more than anything a **political language trying to push propaganda**, send messages about minorities in tech instead of creating good technology, and "[fight](fight_culture.md)" and destroy languages invented by straight white men -- the most popular activity of rust soydevs seems to be rewriting already existing, well established, tested and greatly optimized programs from scratch in rust. As such language it is mostly written by angry minorities such as [girls](girl.md) and trannies who can't much into technology, hence the completely shit design and implementation.
- **It tries to displace good languages** such as [C](c.md) and sadly, thanks to its populism and political appeal, is becoming popular among masses of coding monkeys who have no idea about technology.
- **It is completely unnecessary** in the first place, a good low level language already exists: [C](c.md). If anything, we need to improve C by making it [simpler](minimalism.md), but overcomplicated C also already exists for those who for some reason want to use a shit language: [C++](cpp.md), and there are of course also slow and safe language well suited for beginners, such as [Python](python.md). Rust is just flushing thousands of manhours (prolly rather soiboihours) down the toilet.
- TODO: MORE, but you get the idea
- Also "rust", what a shitty name lol. Who comes up with these idiotic names? Why do [modern](modern.md) languages and libraries have to be called these shitty things like banana, unicorn hamburger, kangaroo space shuttle etc.?
- TODO: MORE, but you get the idea

@ -62,17 +62,48 @@ Some values of the sine function are:
## Programming
In programming languages sine is generally available in some math library, for example in [C](c.md) the function `sin` is in `math.h`. Spare yourself bugs, **always check if your sin function expects [radians](radian.md) or degrees!**
In programming languages the sine function is generally available in some math library, for example in [C](c.md) the function `sin` is in `math.h`. Spare yourself bugs, **always check if your sin function expects [radians](radian.md) or degrees!**
There exists an **ugly engineering [approximation](approximation.md)** of sine that can be useful sometimes, it says that
**Want to make your own sine function for whatever reason (performance, curiosity, ...)?** Then firstly consider what you expect from it. If you want a small, fast and perhaps integer only `sin` function (the one we'd prefer in [LRS](lrs.md)) that doesn't need extreme accuracy, consider using a **[look up table](lut.md)**. You simply precompute the values of the sine function into a static table in memory and the function just retrieves them when called -- this is super fast. Note that you can save a lot of space by **only storing sine values between 0 and 1/2 pi**, the remaining parts of the function are just different transformations of this part. You can further save space and/or make the function work with [floats](float.md) by further [interpolating](interpolation.md) (even just linearly) between the stored values, for example if `sin(3.45)` is called and you only have values stored for `sin(3.4)` and `sin(3.5)`, you simply average them.
*sin(x) = x, for small x*
Lot of times, e.g. in many calculators where speed isn't really critical, sine is computed using [Taylor series](taylor_series.md) -- a sum of infinitely many terms of which if we take the first *N*, we get an [approximation](approximation.md) of the function (the more terms we add, the more precise we get). For sine the series is
Indeed, sine looks similar to a mere line near 0, but you can see it quickly diverges.
*sin(x) = x - x^3 / 3! + x^5 / 5! - x^7 / 7! + ...*
Adding just the first 3 terms (*x - x^3 / 6 + x^5 / 120*) already gives a very accurate approximation in range <-pi/2,pi/2> (error < 0.5 %). Here is a [C](c.md) function that uses this to compute an 8bit sine (the magic numbers are made so as to incorporate pi while using power of two divisors, also note the use of many operations that will make the function relatively slow):
```
// x = 255 means full angle, returns 0 to 255
unsigned char sin8(unsigned char x)
{
int a = x;
char flip = 0;
if (a > 127)
{
a -= 128;
flip = 1;
}
if (a > 63)
a = 128 - a;
int result = (411999 * a) - (a * a * a * 41);
When implementing your own `sin` function, consider what you expect from it.
a /= 4;
If you want a small, fast and perhaps integer only `sin` function (the one we'd prefer in [LRS](lrs.md)) that doesn't need extreme accuracy, consider using a **[look up table](lut.md)**. You simply precompute the values of the sine function into a static table in memory and the function just retrieves them when called -- this is super fast. Note that you can save a lot of space by **only storing sine values between 0 and 1/2 pi**, the remaining parts of the function are just different transformations of this part. You can further save space and/or make the function work with [floats](float.md) by further [interpolating](interpolation.md) (even just linearly) between the stored values, for example if `sin(3.45)` is called and you only have values stored for `sin(3.4)` and `sin(3.5)`, you simply average them.
a = a * a * a * a * a;
result = (a + result) / 131072;
return flip ? (127 - result) : (127 + result);
}
```
If you just need a super fast and very rough sine-like value, there exists an **ugly engineering approximation** of sine that can be useful sometimes, it says that
*sin(x) = x, for small x*
Indeed, sine looks similar to a mere line near 0, but you can see it quickly diverges.
Very rough and fast approximations e.g. for primitive music synthesis can be done with the traditional very basic [square](square_function.md) or [triangle](triangle_function.md) functions. The following is a simple 8bit linear approximation that's more accurate than square or triangle (approximates sine with a linear function in each octant):
@ -111,7 +142,7 @@ int sinA(int x)
}
```
If you don't need extreme speed there exist very nice sine [approximations](approximation.md), e.g. the extremely accurate **Bhaskara I's approximation** (angle in radians): *sin(x) ~= (16 * x * (pi - x)) / (5 * pi^2 - 4 * x * (pi - x))*. (This formula is actually more elegant for cosine, so it may be even better to consider using that.) Here is a [C](c.md) [fixed point](fixed_point.md) implementation:
Furthermore there exist other nice approximations, such as the extremely accurate **Bhaskara I's approximation** (angle in radians): *sin(x) ~= (16 * x * (pi - x)) / (5 * pi^2 - 4 * x * (pi - x))*. (This formula is actually more elegant for cosine, so it may be even better to consider using that.) Here is a [C](c.md) [fixed point](fixed_point.md) implementation:
```
#define UNIT 1024
@ -142,6 +173,4 @@ int sinInt(int x)
return sign * (16 * x) / ((5 * PI * PI - 4 * x) / UNIT);
}
```
Another approach is to use [Taylor series](taylor_series.md) to approximate sine with a [polynomial](polynomial.md) to whatever precision we need (this is used e.g. in calculators etc.).
```

@ -1,5 +1,7 @@
# Tangram
{ I made a simple tangram game in [SAF](saf.md), look it up if you want to play some tangram. ~drummyfish }
Tangram is a simple, yet greatly amusing old puzzle [game](game.md) in which the player tries to compose a given shape (of which only silhouette is seen) out of given basic geometric shapes such as triangles and squares. It is a rearrangement puzzle. Many thousands of shapes can be created from just a few geometric shapes, some looking like animals, people and man made objects. This kind of puzzles have been known for a long time -- the oldest recorded tangram is Archimedes' box (square divided into 14 pieces), over 2000 years old. In general any such puzzle is called tangram, i.e. it is seen as a family of puzzle games, however tangram may also stand for **modern tangram**, a one with 7 polygons which comes from 18th century China and which then became very popular also in the west and even caused a so called "tangram craze" around the year 1818. Unless mentioned otherwise, we will talk about this modern version from now on.
```

Loading…
Cancel
Save