diff --git a/chess.md b/chess.md index 03d1b80..fa0b2cb 100644 --- a/chess.md +++ b/chess.md @@ -1,20 +1,21 @@ # Chess -Chess is an old two-player board [game](game.md), perhaps most famous and popular among all board games in history. It is a complete information game that simulates a battle of two armies on a 64x64 board with different battle pieces. Chess has a world-wide competitive community and is considered an intellectual sport but is also a topic of active research (chess is unlikely to be ever solved due to its non-trivial rules combined with enormous state space, Shannon estimated the number of possible games at 10^120) and programming (many chess engines, [AI](ai.md)s and frontends are being actively developed). +Chess is an old two-player board [game](game.md), perhaps most famous and popular among all board games in history. It is a [complete information](complete_information.md) game that simulates a battle of two armies on a 64x64 board with different battle pieces. Chess has a world-wide competitive community and is considered an intellectual sport but is also a topic of active research (chess is unlikely to be ever solved due to its non-trivial rules combined with enormous state space, Shannon estimated the number of possible games at 10^120) and programming (many chess engines, [AI](ai.md)s and frontends are being actively developed). { 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*. -**At [LRS](lrs.md) we consider chess to be one of the best games**, if not the very best one, for the following reasons: +**At [LRS](lrs.md) we consider chess to be one of the best games** for the following reasons: - It is just a greatly interesting and deep game in which luck plays minimal role. -- **It is [suckless](suckless.md)**, the rules are very simple, it can be implemented on simple 8bit computers. The game doesn't even require a computer to play and chess masters don't even need a physical board to play (they can completely visualize it in memory). In the end one can in theory just play against himself in his head, achieving ultimate freedom: the only dependency of the game is one's brain, i.e. it becomes a [brain software](brain_software.md). Chess is extremely inexpensive, doesn't discriminate against poor people and will survive even the most extreme technological [collapse](collapse.md). +- **It is greatly [suckless](suckless.md)**, the rules are very simple, it can be implemented on simple 8bit computers. Of course the game doesn't even require a computer, just a board and a few pieces -- chess masters don't even need a board to play (they can completely visualize the games in memory). In the end one can in theory just play against himself in his head, achieving the ultimate freedom: the only dependency of the game is one's brain, i.e. it becomes a [brain software](brain_software.md). Chess is extremely inexpensive, doesn't discriminate against poor people and will survive even the most extreme technological [collapse](collapse.md). - **No one owns chess**, the game is hundreds of years old and many books about it are also already in the [public domain](public_domain.md). It is extremely free. - It is a basis for other derived games, for example many different chess variants or chess puzzles which can be considered a "singleplayer chess game". - It is a source of many interesting [mathematical](math.md) and programming challenges. +- It seems to strike the right balance of simplicity and complexity, it is very simple but not so trivial as to be ever solved in a foreseeable future. -## Chess in General +## Chess In General Chess evolved from ancient board games in India in about 6th century. Nowadays the game is internationally governed by **FIDE** which has taken the on role of an authority that defines the official rules: FIDE rules are considered to be the standard chess rules. FIDE also organizes tournaments, promotes the game and keeps a list of registered players whose performance it rates with so called Elo system –⁠ based on the performance it also grants titles such as **Grandmaster** (GM, strongest), **Internation Master** (IM, second strongest) or **Candidate Master** (CM). @@ -28,7 +29,7 @@ Currently the best player in the world is pretty clearly Magnus Carlsen from Nor During [covid](covid.md) chess has experienced a small boom among normies and [YouTube](youtube.md) chess channels have gained considerable popularity. This gave rise to [memes](meme.md) such as the bong cloud opening popularized by a top player and streamer Hikaru Nakamura; the bong cloud is an intentionally shitty opening that's supposed to taunt the opponent (it's been even played in serious tournaments lol). -## Chess and Computers +## Chess And Computers {[This](https://www.youtube.com/watch?v=DpXy041BIlA) is an absolutely amazing video about weird chess algorithms :) ~drummyfish} @@ -82,7 +83,50 @@ Many other aspects come into the AI design such as opening books (databases of b ## Rules -TODO +The exact rules of chess and their scope may depend on situation, this is just a sum up of rules generally used nowadays. + +The start setup of a chessboard is following (lowercase letters are for black pieces, uppercase for white pieces, on a board with colored squares A1 is black): + +``` + _______________ + /8 |r n b q k b n r| + r | 7 |p p p p p p p p| + a | 6 |. . . . . . . .| + n | 5 |. . . . . . . .| + k | 4 |. . . . . . . .| + s | 3 |. . . . . . . .| + | 2 |P P P P P P P P| + \1 |R N B Q K B N R| + """"""""""""""" + A B C D E F G H + \_____________/ + files +``` + +Players take turns in making moves, white always starts. A move consists of moving one (or in special cases two) of own pieces from one square to another, possibly capturing (removing from the board) one opponent's piece -- except for a special en passant move capturing always happens by moving one piece to the square occupied by the opposite color piece (which gets removed). Of course no piece can move to a square occupied by another piece of the same color. A move can NOT be skipped. A player wins by giving a **checkmate** to the opponent (making his king unable to escape attack) or if the opponent resigns. If a player is to move but has no valid moves, the game is a draw, so called **stalemate**. If neither player has enough pieces to give a checkmate, the game is a draw, so called **dead position**. There are additional situation in which game can be drawn (threefold repetition of position, 50 move rule). Players can also agree to a draw. A player may also be declared a loser if he cheated, if he lost on time in a game with clock etc. + +The individual pieces and their movement rules are: + +- **pawn** (`P`): Moves 1 square forward (white towards 8th rank, black towards 1st rank), unless that square is occupied by any piece (even enemy piece, pawns cannot capture going forward). From its start position a pawn can optionally move 2 squares if neither of the 2 forward squares are occupied. Pawn can capture enemy pieces 1 square diagonally forward (i.e. 1 square forward right or 1 square forward left). +- **rook** (`R`): Moves any number of squares either horizontally or vertically, but cannot jump over any pieces, however can capture (i.e. land) on a square occupied by enemy piece and capture it. +- **knight** (`N`): Can jump over pieces (both friendly and enemy), moves in "L" shapes, i.e. from its square a knight can jump to (with a possible capture) a square 2 squares in one direction and 1 square in the perpendicular direction (e.g. 2 squares down and 1 square right, or 2 squares right and 1 square up etc.). +- **bishop** (`B`): Moves like rook but diagonally, i.e. a bishop will only ever be able to move on squares of one color (the one it starts on). +- **queen** (`Q`): Can move both like bishop and rook. +- **king** (`K`): Can move (and capture) to any of the 8 immediately neighboring squares. + +**Check**: If the player's king is attacked, i.e. it is immediately possible for an enemy piece to capture the king, the player is said to be in check. A player in check has to make such a move as to not be in check after that move. + +A player cannot make a move that would leave him in check! + +**Castling**: If a player hasn't castled yet and his king hasn't been moved yet and his kingside (queenside) rook hasn't been moved yet and there are no pieced between the king and the kingside (queenside) and the king isn't and wouldn't be in check on his square or any square he will pass through or land on during castling, short (long) castling can be performed. In short (long) castling the king moves two squares towards the kingside (queenside) rook and the rook jumps over the king to the square immediately on the other side of the king. + +**Promotion**: If a pawn reaches the 1st or 8th rank, it is promoted, i.e. it has to be switched for either queen, rook, bishop or knight of the same color. + +**Checkmate**: If a player is in check but cannot make any move to get out of it, he is checkmated and lost. + +**En passant**: If a pawn moves 2 squares forward (from the start position), in the immediate next move the opponent can take it with a pawn in the same way as if it only moved 1 square forward (the only case in which a piece captures a piece by landing on an empty square). + +Threefold repetition is a rule allowing a player to claim a draw if the same position (piece positions, player's turn, castling rights, en passant state) occurs three times (not necessarily consecutively). The 50 move rule allows a player to claim a draw if no pawn has moved and no piece has been captured in last 50 moves (both players making their move counts as a single move here). ## See Also diff --git a/hash.md b/hash.md index d116d0d..f305a4d 100644 --- a/hash.md +++ b/hash.md @@ -1,15 +1,17 @@ # Hash -Hash is a number computed by a **hash function**, a function that takes some data and turns it into a number (the hash) that's much smaller than the data itself, has a fixed size (number of [bits](bit.md)) and which has additional properties such as being completely different from hash values computed from very similar data. Thanks to these properties hashes have a very wide use in [computer science](compsci.md) -- they are often used to quickly compare whether two pieces of non-small data, such as documents, are the same, they are used in indexing structures such as **hash tables** which allow for quick search of data, and they find a great use in [cryptocurrencies](crypto.md) and [security](security.md), e.g. for [digital signatures](sigital_signature.md). Hashing is extremely important and as a programmer you won't be able to avoid encountering hashes somewhere in the wild. +Hash is a number that's computed from some data in a [chaotic](chaos.md) way and which is used for many different purposes, e.g. for quick comparisons (instead of comparing big data structures we just compare their hashes) or mapping data structures to table indices. -{ Talking about wilderness, Hyenas and other animals have their specific smells that are created by bacteria in them and are unique to each individual depending on the exact mix of the bacteria. They use these smells to quickly identify each other. The smell is kind of like the animal's hash. But of course the analogy isn't perfect, for example similar mixes of bacteria may produce similar smells, which is not how hashes should behave. ~drummyfish } +Hash is computed by a **hash function**, a function that takes some data and turns it into a number (the hash) that's in terms of [bit](bit.md) width much smaller than the data itself, has a fixed size (number of [bits](bit.md)) and which has additional properties such as being completely different from hash values computed from very similar (but slightly different) data. Thanks to these properties hashes have a very wide use in [computer science](compsci.md) -- they are often used to quickly compare whether two pieces of non-small data, such as documents, are the same, they are used in indexing structures such as **hash tables** which allow for quick search of data, and they find a great use in [cryptocurrencies](crypto.md) and [security](security.md), e.g. for [digital signatures](sigital_signature.md) or storing passwords (for security reasons in databases of users we store just hashes of their passwords, never the passwords themselves). Hashing is extremely important and as a programmer you won't be able to avoid encountering hashes somewhere in the wild. + +{ Talking about wilderness, hyenas have their specific smells that are determined by bacteria in them and are unique to each individual depending on the exact mix of the bacteria. They use these smells to quickly identify each other. The smell is kind of like the animal's hash. But of course the analogy isn't perfect, for example similar mixes of bacteria may produce similar smells, which is not how hashes should behave. ~drummyfish } It is good to know that we distinguish between "normal" hashes used for things such as indexing data and [cryptographic](cryptography.md) hashes that are used in computer security and have to satisfy some stricter mathematical criteria. For the sake of simplicity we will sometimes ignore this distinction here. Just know it exists. It is generally given that a hash (or hash function) should satisfy the following criteria: - **Have fixed size** (given in bits), even for data that's potentially of variable size (e.g. text strings). -- **Be fast to compute**. This is mostly important for non-security uses, cryptographic hashes may prioritize other properties to guarantee the hash safety. +- **Be fast to compute**. This is mostly important for non-security uses, cryptographic hashes may prioritize other properties to guarantee the hash safety. But a hash function certainly can't take 10 minutes to compute :) - **Have uniform mapping**. That is if we hash a lot of different data the hashes we get should be uniformly spread over the space of the hashes, i.e. NOT be centered around some number. This is in order for hash tables to be balanced, and it's also required in security (non-uniform hashes can be easier to reverse). - **Behave in a [chaotic](chaos.md) manner**, i.e. hashes of similar data should be completely different. This is similar to the point above; a hash should kind of appear as a "random" number associated to the data (but of course, the hash of the same data has to always be the same when computed repeatedly, i.e. be [deterministic](determinism.md)). So if you change just one bit in the hashed data, you should get a completely different hash from it. - **Minimize collisions**, i.e. the probability of two different values giving the same hash. Mathematically collisions are always possible if we're mapping a big space onto a smaller one, but we should try to reduce collisions that happen in practice. This property should follow from the principle of uniformity and chaotic behavior mentioned above. @@ -27,23 +29,48 @@ Some common uses of hashes are: ## Code Example -Let's say we want a has function for string which for any [ASCII](ascii.md) string will output a 32 bit hash. How to do this? We need to make sure that every character of the string will affect change the resulting hash. +Let's say we want a has function for string which for any [ASCII](ascii.md) string will output a 32 bit hash. How to do this? We need to make sure that every character of the string will affect the resulting hash. -First though that may come to mind could be for example to multiply the ASCII values of all the characters in the string. However there are at least two mistakes in this: firstly short strings will result in small values as we'll get a product of fewer numbers. Secondly reordering the characters in a string (i.e. its [permutations](permutation.md)) will not change the hash at all (as with multiplication order is insignificant)! These violate the properties we want in a hash function. If we used this function to implement a hash table and then tried to store strings such as "abc", "bca" and "cab", all would map to the same hash and cause collisions that would negate the benefits of a hash table. +First thought that may come to mind could be for example to multiply the ASCII values of all the characters in the string. However there are at least two mistakes in this: firstly short strings will result in small values as we'll get a product of fewer numbers (so similar strings such as "A" and "B" will give similar hashes, which we don't want). Secondly reordering the characters in a string (i.e. its [permutations](permutation.md)) will not change the hash at all (as with multiplication order is insignificant)! These violate the properties we want in a hash function. If we used this function to implement a hash table and then tried to store strings such as "abc", "bca" and "cab", all would map to the same hash and cause collisions that would negate the benefits of a hash table. -The following is a better function, a variant of a function used in sdbm: +TODO + +## Nice Hashes + +{ Reminder: I make sure everything on this Wiki is pretty copy-paste safe, I only copy short (probably uncopyrightable) snippets or public domain code and additionally also reformat and change them a bit, so don't be afraid of the snippets. ~drummyfish } + +The [*hash prospector* project](https://github.com/skeeto/hash-prospector) ([unlicense](unlicense.md)) created a way for automatic generation of integer hash functions with nice statistical properties which work by [XORing](xor.md) the input value with a bit-shift of itself, then multiplying it by a constant and repeating this a few times. The functions are of the format: ``` -uint32_t stringHash(const char *s) +uint32_t hash(uint32_t n) { - uint32_t result = 123; - - while (*s) - { - r = s + (result << 16) + (result << 6) - result; - s++; - } - - return result; + n = A * (n ^ (n >> S1)); + n = B * (n ^ (n >> S2)); + return n ^ (n >> S3); } -``` \ No newline at end of file +``` + +Where *A*, *B*, *S1*, *S2* and *S3* are constants specific to each function. Some nice constants found by the project are: + +| A | B |S1 |S2 |S3 | +|----------|----------|---|---|---| +|303484085 |985455785 |15 |15 |15 | +|88290731 |342730379 |16 |15 |16 | +|2626628917|1561544373|16 |15 |17 | +|3699747495|1717085643|16 |15 |15 | + +The project also explores 16 bit hashes, here is a nice hash that doesn't even use multiplication! + +``` +uint16_t hash(uint16_t n) +{ + n = n + (n << 7); + n = n ^ (n >> 8); + n = n + (n << 3); + n = n ^ (n >> 2); + n = n + (n << 4); + return n ^ (n >> 8); +} +``` + +TODO: more (strings etc.) \ No newline at end of file diff --git a/less_retarded_society.md b/less_retarded_society.md index 51dc26f..8082172 100644 --- a/less_retarded_society.md +++ b/less_retarded_society.md @@ -6,12 +6,13 @@ Note that this society is an ideal model, i.e. it can probably not be achieved 1 ## FAQ -- **Isn't it utopia?** As explained above, the society is an ideal model that's probably not 100% achievable, but we are pretty certain we can get extremely close to the ideal in the real world implementation, there are no known obstacles to it. Even if we couldn't get very close to the ideal, it would be better to get a little closer than not, there is no logic in refusing to try. Every major invention happened for the first time one day, even when it's been called impossible, history is basically a constant stream of such events. +- **Isn't it utopia?** As explained above, the society is an ideal model that's probably not 100% achievable, but we are pretty certain we can get extremely close to the ideal in the real world implementation, there are no known obstacles to it. Even if we couldn't get very close to the ideal, it would be better to get a little closer than not, there is no logic in refusing to try. Every major invention happened for the first time one day, even when it's been called impossible; for example before [Wikipedia](wikipedia.md) practically everyone would tell you the principles on which it would be built (free voluntary work, allowing anyone to edit) were utopian. History is basically a constant stream of events proving our disbeliefs wrong. - **How is this different from "communism", "socialism" and other movements/ideologies that brought so much suffering and eventually failed anyway?** We are very different especially by NOT advocating revolutions, violence and forceful application of our ideas, we simply educate, show what's wrong and what the solution is. We know that only a voluntary, non-violent change based on facts and rational thinking can succeed in long term. The mistake of every failed "utopian" ideology was that it was forced, oppressive and in the end served only a few as opposed to everyone, no matter what the initial idea was. These ideologies fought other ideologies, creates cults of personalities and propaganda to manipulate masses. We do not fight anyone, we simply show the truth and offer it to people and believe that this truth can't be unseen. Once enough people see the truth and know what the logical solution is, a change will happen naturally, peacefully and inevitably, without any force. - **Isn't your society unnatural?** In many way yes, it's unnatural just as clothes, computers or humans living over 70 years are unnatural. Civilization by definition means resisting the cruelness of nature, however our proposed society is to live as much as possible in harmony with the nature and is much more natural than our current society which e.g. pushes sleep deprivation, high consumption of antidepressants, addiction to social networks and so on. - **Won't people get bored? What will motivate people? If they have everything why would they even get out of bed? Haven't you seen the mouse utopia experiments?** It is a mistake to think that competition and the necessity of making living is the only or even the main driving force of human behavior and creativity (on the contrary, it is usually what makes people commit suicides, i.e. lose the sense of their lives). Human curiosity, playfulness, the joy of collaboration, boredom, sense of altruism, socialization, seeking of life meaning and recognition and many other forces drive our behavior. Ask yourself: why do people have hobbies when no one is forcing them to it? Why don't you bore yourself to death in your spare time? Why don't rich people who literally don't have to work bore themselves to death? Why doesn't your pet dog that's not forced to hunt for food bore himself to death? Maslow's hierarchy of needs tells us that once people fulfill basic needs such as that for obtaining food, they naturally start to pursue higher ones such as that for socializing or doing science or art. Unlike rats in small cages people show interests in seeking satisfaction of higher needs than just food and sex, even those that aren't scientist try to do things such as sports, photography, woodwork or gardening, just for the sake of it. It's not that there would be a lack challenges in our society, just that we wouldn't force arbitrary challenges on people. - **If you say it's possible, why wasn't it done before?** Firstly small scale communities working on anarchist and peaceful principles have existed for a long time in environments that allow it, e.g. those that have abundance of resources. Globally society couldn't reach this state because only until recently we lacked the technology to provide such an ideal environment globally, i.e. only until recently we have been forced by the nature to compete for basic resources such as food and space to live. However with computers, factories, high level of automation and other technology and knowledge we posses, we now have, for the first time in history, the capability to establish an environment with abundance of resources for everyone. Nowadays only social inertia in the form of [capitalism](capitalism.md) is ARTIFICIALLY keeping scarcity and social competition in place -- getting rid of this obsolete system is now needed to allow establishment of our ideal society. - **How will you make people work?** We won't, in an ideal society people don't need to work, all work is done by machines -- that's the point of creating machines in the first place. In practice there may in a foreseeable future be the need for small amounts of human work such as overlooking the machines, but the amount of work can be so small that volunteers will easily handle it -- especially with people having no burden of working day jobs there should be no shortage of volunteers. Remember that by abandoning the current system 99% of "bullshit work" (marketing, lawyers, bureaucracy, fashion, ...) will disappear. +- **Does elimination of bullshit jobs mean my favorite activity will disappear?!** Unless your hobby is something like killing people for fun, we don't aim to force anyone quitting anything he likes to do, on the contrary we aim exactly to establish the freedom to do anything one desires. So if you like e.g. designing clothes, you are free to do so as a form of art, we just argue against e.g. socially forced necessity to follow fashion in clothing and making capitalist business out of it, which is what we call "bullshit". We believe most bullshit activities that were invented by capitalism, such as marketing, will simply naturally disappear once capitalism ends, there is no need to force it. - **How will society make progress?** Just as it always had: by science, curiosity, necessity etc. - **How do you prevent natural human selfish and violent behavior?** Violent and selfish behavior is natural in us just as peaceful and altruistic behavior, we have two sides and which one shows is mostly determined by the conditions in which we live. Nowadays we think people are extremely selfish and violent because we live in society that highly fuels the "evil" side in us, when we're forced to fight for basic living and grow up in a highly competitive environment, it's no surprise most adapt to this and grow up being "dicks". If we're forced to fight for food and brainwashed since birth that "life is a fight", we will be selfish and violent, just as wild wolves are violent while pet dogs whose needs are secured and who were raised peacefully are mostly completely peaceful. If we have abundance and grow up in a society that naturally rejects any violence, we will grow up to solve conflicts peacefully and think of others, just as nowadays we e.g. naturally learn to wear clothes because simply everyone does it and there is little reason not to. If we make resources abundant, there will be no need for selfishness -- do you see anyone stealing air from others out of selfishness? No, because there is no need for it, air is abundant. By changing the environment people live and grow up in we will make 99.99% of people abandon violence and selfish interests (note the remaining natural need for selfishness and competition can be satisfied e.g. with games). - **How will you prevent chaos without laws or rules for the people?** We don't say there should be no rules, we are just against complicated written law that no one can even comprehend (even lawyers don't know all laws nowadays) and that has so little in common with morality. Our society works on the basis of moral rules that all stem from the common goal of well being of living beings and that are derived and taught by people themselves -- for example one moral rule that all people would learn would be that money is bad for society (along with the reasons why it is so) and even though there would be no police "enforcing" this rule, the rule would be effective by the fact that absolute majority of people would simply refuse to use money -- in a society where most people know capitalism is bad for them capitalism can't work. Note the importance of the fact that people wouldn't just be taught to memorize such rules as "facts set in stone" (as is our current law), emphasis would be put on people deriving their moral code and understanding how their behavior affects others, people would learn and teach by example. diff --git a/netstalking.md b/netstalking.md index 70ca2a7..0b6b0bc 100644 --- a/netstalking.md +++ b/netstalking.md @@ -1,6 +1,6 @@ # Netstalking -Netstalking means searching for obscure, hard-to-find and somehow valuable (even if only by its entertaining nature) information buried in the depths of the [Internet](internet.md), for example searching for funny photos on Google Streetview (https://9-eyes.com/), unindexed [deepweb](deepweb.md) sites or secret documents on [FTP](ftp.md) servers. Netstalking is relatively unknown in the English-speaking world but is pretty popular in Russian communities. +Netstalking means searching for obscure, hard-to-find and somehow valuable (even if only by its entertaining nature) information buried in the depths of the [Internet](internet.md) (and similar networks), for example searching for funny photos on Google Streetview (https://9-eyes.com/), unindexed [deepweb](deepweb.md) sites or secret documents on [FTP](ftp.md) servers. Netstalking is relatively unknown in the English-speaking world but is pretty popular in Russian communities. Netstalking can be divided into two categories: diff --git a/palette.md b/palette.md new file mode 100644 index 0000000..27ca9c2 --- /dev/null +++ b/palette.md @@ -0,0 +1,100 @@ +# Palette + +In [computer graphics](graphics.md) palette is a set of possible colors that can be displayed, the term usually refers to a selected smaller subset of all colors that can in theory be displayed (large sets of colors tend to be called [color spaces](color_space.md) rather than palettes). Nowadays mainstream computers are powerful enough to work with over 6 million 24bit [RBG](rbg.md) colors (so called True Color) practically without limitations so the use of palettes is no longer such a huge thing, but with resource-limited machines, such as [embedded](embedded.md) devices and older computers, the use of palettes is sometimes necessary or at least offers many advantages (e.g. saving a lot of memory). Nevertheless palettes find uses even in "[modern](modern.md)" graphics, e.g. in the design of image formats that save space. Palettes are also greatly important in [pixel art](pixel_art.md) as an artistic choice. + +Palettes usually contain a few to few thousand colors and the number is normally a power of 2, i.e. we see palettes with number of colors being 8, 16, 256, 2048, etc. -- this has advantages such as efficiency (fully utilizing color indices, keeping memory aligned etc.). Palettes can be general purpose or specialized (for example some image formats such as [GIF](gif.md) create a special palette for every individual image so as to best preserve its colors). Palettes can also be explicitly stored (the palette colors are stored somewhere in the memory) or implicit (the color can somehow be derived from its index, e.g. the [565](565.md) palette). + +Palettes are related to **[screen modes](screen_mode.md)** -- systems that work with palettes will usually offer to set a specific screen mode that defines parameters such as screen [resolution](resolution.md) and number of colors we can use, i.e. the number of colors of our palette (we can normally set the colors in a palette). Modes that make use of palettes are called **indexed** because each pixel in memory is stored as an index to the palette (for example if we have a palette {red, yellow, white}, a pixel value 0 will stand for *red*, 1 for *yellow* and 2 for *white*) -- the palette serves as a color [look-up table](lut.md) (CLUT). Non-indexed modes on the other hand store the color directly (i.e. there will typically be a direct RGB value stored for each pixel). We can see that an indexed mode (i.e. choosing to use a palette) will save a lot of memory for the [framebuffer](framebuffer.md) ([VRAM](vram.md)) thanks to reducing the number of bits per [pixel](pixel.md): e.g. when using an 8 bit palette, storing each pixel (index) will take up 1 byte (8 bits, 256 colors) while in a non-indexed 24 bit RGB mode (over 6 million colors) each pixel will take 3 bytes (24 bits), i.e. three times as much. The same goes for using bigger palettes: e.g. using a 16 bit palette (65536 colors) will take four times as much memory for storing pixels than a 4 bit palette (16 colors). Note that even in indexed modes we may sometimes be able to draw pixels of arbitrary color with so called **direct** writes to the display, i.e. without the color being stored in framebuffer. With palettes we may see the use of [dithering](dithering.md) to achieve the illusion of mixing colors. + +Using palettes has also more advantages, for example we can cycle the palette colors or quickly switch it for another palette and so e.g. increase contrast or apply some color effect (this trick was used e.g. in [Doom](doom.md)). Palettes can be constructed in clever ways (for example in [Anarch](anarch.md)) so that it is e.g. easy to make a color brighter or darker by simply incrementing or decrementing its index (while increasing brightness of a three-component RGB value is complex and slow) -- as we generally process big numbers of pixels this can lead to tremendous speed ups. Having fewer colors also makes them easier to compare and so easily implement things such as [pixel art upscaling](pixel_art_upscaling.md) (huge number of colors generally forces us to compare pixels with some amount of bias which is slower). + +**Can palettes be [copyrighted](copyright.md)?** We hope not, that would indeed be pretty fucked up, however [trademarks](trademark.md) already allowed corporations to own even single colors (Milka chocolate's lilac color), and some websites for sharing palettes claim that a picture of a palette can be copyrighted as some kind of a "digital painting", even though they acknowledge a set of colors as such can't be copyrighted. So for maximum safety try to create your own palette (and share it under [CC0](cc0.md) to spare others the same pain) as a first option, as a second option use a palette that's explicitly shared under free terms ([CC0](cc0.md) is probably best), and if you absolutely have to reuse someone else's "proprietary" palette, at least reorder its colors and possibly slightly change the RGB values to make it a bit distinct. + +## Examples + +Example of a basic 8 color palette may be (the color notation is in [hexadecimal](hex.md) `#rrggbb` format): + +``` +#000000 #808080 #ffffff #ff0000 #00ff00 #0000ff #ffff00 #00ffff +black gray white red green blue yellow cyan +``` + +The following is a general purpose 256 color palette made by [drummyfish](drummyfish.md) and used in [Anarch](anarch.md). It is based on [HSV](hsv.md) model: it divides colors into 4 saturations, 10 or 11 hues and 8 levels of value ("brightness") which can easily be changed by incrementing/decrementing the color index (which in Anarch was exploited for ligtening up and darkening textures depending on distance). + +``` +#000000 #242424 #494949 #6d6d6d #929292 #b6b6b6 #dbdbdb #ffffff +#201515 #402a2a #604040 #805555 #a06a6a #c08080 #e09595 #ffaaaa +#201b15 #40372a #605240 #806e55 #a08a6a #c0a580 #e0c195 #ffdcaa +#1d2015 #3b402a #596040 #778055 #95a06a #b3c080 #d1e095 #edffaa +#172015 #2f402a #466040 #5e8055 #75a06a #8dc080 #a5e095 #bcffaa +#152019 #2a4033 #40604c #558066 #6aa080 #80c099 #95e0b3 #aaffcc +#15201f #2a403f #40605f #55807f #6aa09f #80c0bf #95e0df #aafffe +#151920 #2a3340 #404c60 #556680 #6a80a0 #8099c0 #95b3e0 #aaccff +#171520 #2e2a40 #464060 #5d5580 #746aa0 #8c80c0 #a395e0 #b9aaff +#1d1520 #3b2a40 #594060 #775580 #956aa0 #b380c0 #d195e0 #eeaaff +#20151b #402a37 #604053 #80556f #a06a8b #c080a7 #e095c3 #ffaadd +#200a0a #401515 #602020 #802a2a #a03535 #c04040 #e04a4a #ff5555 +#20170a #402e15 #604520 #805c2a #a07435 #c08b40 #e0a24a #ffb955 +#1b200a #374015 #536020 #6e802a #8aa035 #a6c040 #c2e04a #dcff55 +#f200a0 #1e4015 #2d6020 #3c802a #4ba035 #5bc040 #6ae04a #79ff55 +#a20130 #154026 #206039 #2a804c #35a060 #40c073 #4ae086 #55ff99 +#a201f0 #15403f #20605f #2a807e #35a09e #40c0be #4ae0de #55fffd +#a13200 #152640 #203960 #2a4c80 #3560a0 #4073c0 #4a86e0 #5599ff +#e0a200 #1d1540 #2c2060 #3a2a80 #4935a0 #5840c0 #664ae0 #7455ff +#1b0a20 #371540 #532060 #6e2a80 #8a35a0 #a640c0 #c24ae0 #dd55ff +#200a17 #40152f #602047 #802a5e #a03576 #c0408e #e04aa6 #ff55bc +#200000 #400000 #600000 #800000 #a00000 #c00000 #e00000 #ff0000 +#201100 #402200 #603300 #804500 #a05600 #c06700 #e07900 #ff8a00 +#1d2000 #3a4000 #586000 #758000 #92a000 #b0c000 #cde000 #eaff00 +#c20000 #184000 #246000 #308000 #3ca000 #48c000 #54e000 #60ff00 +#200500 #400a00 #600f00 #801500 #a01a00 #c01f00 #e02400 #ff2900 +#201600 #402d00 #604300 #805a00 #a07000 #c08700 #e09e00 #ffb400 +#172000 #2e4000 #466000 #5d8000 #74a000 #8cc000 #a3e000 #baff00 +#620000 #c40000 #126000 #188000 #1ea000 #24c000 #2ae000 #30ff00 +#b00200 #160040 #210060 #2d0080 #3800a0 #4300c0 #4f00e0 #5900ff +#1c0020 #390040 #550060 #720080 #8f00a0 #ab00c0 #c800e0 #e400ff +#200012 #400024 #600036 #800048 #a0005a #c0006c #e0007e #ff008f +``` + +Another generally usable 256 color palette is the [332](332.md) palette which can be used as an implicit palette -- it doesn't have to be stored in memory because in the 332 format the color index determines the color in the following way: the upper 3 bits encode the amount of red, the following 3 bits encode the amount of green and the remaining 2 bits encode the amount of blue (blue gets fewest bits because human eye is least sensitive to it). The RGB values of this palette are following. + +``` +#000000 #000055 #0000aa #0000ff #002400 #002455 #0024aa #0024ff +#004800 #004855 #0048aa #0048ff #006d00 #006d55 #006daa #006dff +#009100 #009155 #0091aa #0091ff #00b600 #00b655 #00b6aa #00b6ff +#00da00 #00da55 #00daaa #00daff #00ff00 #00ff55 #00ffaa #00ffff +#240000 #240055 #2400aa #2400ff #242400 #242455 #2424aa #2424ff +#244800 #244855 #2448aa #2448ff #246d00 #246d55 #246daa #246dff +#249100 #249155 #2491aa #2491ff #24b600 #24b655 #24b6aa #24b6ff +#24da00 #24da55 #24daaa #24daff #24ff00 #24ff55 #24ffaa #24ffff +#480000 #480055 #4800aa #4800ff #482400 #482455 #4824aa #4824ff +#484800 #484855 #4848aa #4848ff #486d00 #486d55 #486daa #486dff +#489100 #489155 #4891aa #4891ff #48b600 #48b655 #48b6aa #48b6ff +#48da00 #48da55 #48daaa #48daff #48ff00 #48ff55 #48ffaa #48ffff +#6d0000 #6d0055 #6d00aa #6d00ff #6d2400 #6d2455 #6d24aa #6d24ff +#6d4800 #6d4855 #6d48aa #6d48ff #6d6d00 #6d6d55 #6d6daa #6d6dff +#6d9100 #6d9155 #6d91aa #6d91ff #6db600 #6db655 #6db6aa #6db6ff +#6dda00 #6dda55 #6ddaaa #6ddaff #6dff00 #6dff55 #6dffaa #6dffff +#910000 #910055 #9100aa #9100ff #912400 #912455 #9124aa #9124ff +#914800 #914855 #9148aa #9148ff #916d00 #916d55 #916daa #916dff +#919100 #919155 #9191aa #9191ff #91b600 #91b655 #91b6aa #91b6ff +#91da00 #91da55 #91daaa #91daff #91ff00 #91ff55 #91ffaa #91ffff +#b60000 #b60055 #b600aa #b600ff #b62400 #b62455 #b624aa #b624ff +#b64800 #b64855 #b648aa #b648ff #b66d00 #b66d55 #b66daa #b66dff +#b69100 #b69155 #b691aa #b691ff #b6b600 #b6b655 #b6b6aa #b6b6ff +#b6da00 #b6da55 #b6daaa #b6daff #b6ff00 #b6ff55 #b6ffaa #b6ffff +#da0000 #da0055 #da00aa #da00ff #da2400 #da2455 #da24aa #da24ff +#da4800 #da4855 #da48aa #da48ff #da6d00 #da6d55 #da6daa #da6dff +#da9100 #da9155 #da91aa #da91ff #dab600 #dab655 #dab6aa #dab6ff +#dada00 #dada55 #dadaaa #dadaff #daff00 #daff55 #daffaa #daffff +#ff0000 #ff0055 #ff00aa #ff00ff #ff2400 #ff2455 #ff24aa #ff24ff +#ff4800 #ff4855 #ff48aa #ff48ff #ff6d00 #ff6d55 #ff6daa #ff6dff +#ff9100 #ff9155 #ff91aa #ff91ff #ffb600 #ffb655 #ffb6aa #ffb6ff +#ffda00 #ffda55 #ffdaaa #ffdaff #ffff00 #ffff55 #ffffaa #ffffff +``` + +A similar one is the [565](565.md) palette that uses 2 bytes to encode RGB with 5 bits for red, 6 for green and 5 for blue (most bits are allocated to green to which human eye is most sensitive). + +## See Also + +- [color ramp](color_ramp.md) \ No newline at end of file diff --git a/wiby.md b/wiby.md index 1c1f891..4612c48 100644 --- a/wiby.md +++ b/wiby.md @@ -1,6 +1,6 @@ # Wiby -Wiby is a [minimalist](minimalism.md) non-corporate [web](www.md) [search engine](search_engine.md) for old-style non-[bloated](bloat.md) (web 1.0) websites. Searching on wiby will yield small, simple websites, mostly non-interactive, static [HTML](html.md) personal/hobby sites, small community sites and obscure weird sites -- this kind of searching is not only [fun](fun.md), adventurous and nostalgic [90s](90s.md) like experience, but it actually leads to finding useful information which on corporate search engines like [Google](google.md) or [Bing](bing.md) get buried under billions of useless noise sites and links to "content platforms" like [YouTube](youtube.md) and [reddit](reddit.md). We highly recommend searching on wiby. +Wiby is a [minimalist](minimalism.md) non-corporate [web](www.md) [search engine](search_engine.md) for old-style non-[bloated](bloat.md) (web 1.0, "[smol web](smol_internet.md)") websites. Searching on wiby will yield small, simple websites, mostly non-interactive, static [HTML](html.md) personal/hobby sites, small community sites and obscure weird sites -- this kind of searching is not only [fun](fun.md), adventurous and nostalgic [90s](90s.md) like experience, but it actually leads to finding useful information which on corporate search engines like [Google](google.md) or [Bing](bing.md) get buried under billions of useless noise sites and links to "content platforms" like [YouTube](youtube.md) and [reddit](reddit.md). We highly recommend searching on wiby. It can be accessed at https://wiby.me and https://wiby.org. Of course, no [JavaScript](js.md) is needed! Clicking "surprise me" on wiby is an especially entertaining activity.