Monday, September 4, 2023

Definition of a game

Having a technical definition that we can agree on may make communication easier since there are some things currently called "games" that really aren't games. So, what EXACTLY is a game? This may seem like a silly question but the following highly detailed answer will be useful whenever exact terms are needed.

A game can be defined with a series of dichotomies:

  1. If a piece of entertainment is interactive then it is a plaything. Otherwise it is media (eg: a movie, books).
  2. If a plaything has at least 1 hard rule then it is an activity. Otherwise it is imaginative play (eg: kids playing house, improvisational comedy).
  3. If an activity has a defined end, then it is an exercise. Otherwise it is a pastime (eg: jogging, fishing, D&D).
  4. If an exercise has scoring then it is a challenge. Otherwise it is recreation (eg: Karaoke, Square dancing).
  5. If a challenge has uncertainty, then it is a contest. Otherwise it is a measurement (eg: "who is taller?").
  6. If a contest has an opponent, then it is a conflict. Otherwise it is a puzzle (eg: Rubik's cube or the card game solitaire).
  7. If a conflict can interfere with an opponent, then it is a game. Otherwise (players can only outperform opponents) it is a competition.

Additionally, all conflicts can be further divided:

  1. If a conflict's opponent is another player, then it is competitive. Otherwise, the artificial opponent acts according to a rule system. Competitive games: baseball, western chess, Super Smash Bros Ultimate (when PvP). Competitive competitions (not a great term): judged gymnastics, competitive figure skating, talent show.
  2. If a noncompetitive conflict only has a single player, then it is solo. Solo games: board game final girl, UnderTale. Solo competitions: golf (when solo) due to par, the board game Turing Machine since when solo you compare your score to a "par" which acts as an opponent score.
  3. A noncompetitive conflict with multiple players is cooperative. Cooperative games: Spirit Island, Monster Hunter World online. Cooperative competition: board game Turing Machine (I don't know another example of an artificial opponent that you have to outperform. I don't think this game even officially has a cooperative mode)

Stop here for TL;DR.

This blog post was inspired by https://www.youtube.com/watch?v=2owa2s8GdlM (26:56) Luck and Skill in Games by GDC (2013 GDC, designer Skaff Elias) which stated that nearly every definition of game includes indeterminacy (which I called uncertainty). This video is great (the info is great; the presentation is ok) and it needs more love (hence the shout out). Although it already has more views than my blog will ever get so 🤷.

The above strict definition of game is for things that are definitely games (see examples in the conflict dichotomies). For everything that we call "games" the only common trait is that the entertainment is interactive (and therefore a plaything). Non-game playthings are not inferior but some considerations are different (game theory and min-maxing might not apply) and the interaction is of a different kind (you can't "play to win" if there is no winning).

Note that it is possible for an entertainment of 1 type to become another type by adding/removing criteria. Jogging for a while with no particular goal is a pastime but can be made into a solo competition like "let's see if I can run 3 laps around my house within 1 minute". Also a few of the terms used aren't the best ("competitive competition" is the worst). I'll welcome feedback if anyone can improve them (I said to my 0 readers).

The easiest way to justify my definition is to criticize Chris Crawford's definition which is a series of dichotomies (this is also where I got some of my terms):

  1. If a creative expression is made for money, then it is entertainment. If it was made for its own beauty then it's art.
  2. If a piece of entertainment is interactive then it is a plaything.
  3. If a plaything has goals associated with it then it is a challenge. Otherwise, it is a toy.
  4. If a challenge has an "active agent against whom you compete" then it is a conflict. Otherwise, it is a puzzle.
  5. If a player in a conflict is allowed to attack an opponent to interfere with them then it is a game. Otherwise, if players can only outperform opponents, then it is a competition.

Which I copied from https://en.wikipedia.org/wiki/Game#Chris_Crawford (then reworded) because I don't have time to read his 476 book "Chris Crawford on Game Design". I'll explain what's good with my definition and bad with his definition in order of the points:

-/1 (purpose) Chris's #1 isn't a dichotomy: there are other creative expressions such as tools which are made for utility. "Entertainment" would be difficult to define nor is it necessary since we don't need an infinitely regressive chain, we only need the term right above the common ancestor of all things that use the common usage of "game". Thus, my definition starts with entertainment since the meaning is intuitive and it is the term above plaything (which is the common ancestor).

1/2 (interactive) My #1 and Chris's #2 match (his lacks an alternate term). Plaything is the common ancestor of the common term for "game" and thus this point is an important inclusion since it separates entertainment that aren't considered games by any definition. The common term only requires interaction which influences how a thing is played with.

2/- (at least 1 hard rule) My #2 (which Chris doesn't have) is an important component of a game that's easy to meet the requirements of. Having at least 1 hard rule means that breaking said rule(s) is cheating. "Let's pretend we work in a cafe" is a plaything that you can't really cheat in because there aren't any enforced rules. It is possible to not be interacting properly but every rule is based on social expectations of how to play with others which is flexible compared to rules on what actions is/isn't allowed. You could argue that all rules in Dungeons and Dragons 5e are flexible due to the game master having all authority however every game master will have some kind of hard rules (which may differ by GM). It is definitely possible to cheat in D&D. You might think that the difference between "not playing properly" and "cheating" is subjective however the difference I'm making is that all rules for playing pretend are based on the social expectations of your group whereas D&D has rules that exist independent of groups (which each group applies as needed).

The card game Mao is an edge case since it does have a set of hard rules which aren't revealed then has "if you break these rules, you get penalty X" which acts as a meta-rule in the game. You could argue that breaking the hidden rules isn't cheating but it still definitely has hard rules. Additionally, some games have rules that change over time in which case to qualify it needs to have at least 1 hard rule at all times (although it need not be the same one). There may still be some other edge cases and gray zones that I haven't thought of but I've nailed it down as objectively as I could. Additionally, my #2 is important because separating plaything (the common ancestor) is the first deviation between technical definition and common definition of game.

3/- (a defined end) Chris's #3 implies what my #3 explicitly states. Games must have a pre-defined rule stating when the activity will end. Examples: after 10 minutes, when someone plays their last card, when all players pass, or when the round ends after someone scores at least 30 points. "Games" like D&D are called "tabletop role-playing games" but they don't meet my strict definition of game because they have no defined end and as such it isn't possible to win or lose (see my #4). It has at best a partially defined ending: you might say that if all players die (TPK) then the game ends but that's not entirely true since there's nothing stopping players from making new characters and continuing the same plot. A TTRPG only ends when the players and GM say it's over (for any reason). There's no rule that requires a typical TTRPG to end.

4/3 (scoring) My #4 matches Chris's #3 but I used a better term. Games must have a way to determine win/lose/tie. The scoring need not be quantitative (although it typically is). A talent show can use qualitative scoring if a judge decides which is better without providing a number (nor an audience vote count). Example of a competitive game with qualitative scoring: boxing. If 1 boxer falls over unconscious then the outcome is clear even without a judge but there's no number for how well each side did. A typical TTRPG has no way to win/lose: you play to have fun regardless of character death. In fact, the role-playing game Fiasco (which I think bills itself as a TTRPG which doesn't seem correct to me but I have no definition for TTRPG so I can't disprove it) a player will often intentionally kill their character because it makes for a better plot. A TPK in Fiasco sounds like it'd be a great time which emphasizes that there's no win/lose (having the most white dice isn't a player "win" either). I know I'm harping on TTRPGs not technically being games but they are seemingly asymmetric competitive games so I'm being clear on why that's not the case despite some considerations for asymmetric competitive games applying. In D&D 5e you don't/can't play to beat the GM nor is he playing to win.

5/- (uncertainty) Chris's #4 implies what my #5 explicitly states. The outcome of a game (the scoring) must initially be uncertain. The presence of an opponent (Chris's #4) does make an outcome uncertain because the opponent adds a means of failure. This requirement is listed right after scoring because scoring is the thing that is uncertain. All games will certainly eventually end but who will win the game and by how much isn't known before the game starts. For example: the first time "who is taller?" is done it is uncertain who is taller. It turns out that Alice is taller than Bob. Immediately after this competition is resolved Bob wants a rematch and it is found that their heights haven't changed in the past minute. It wouldn't make sense for Bob to keep demanding rematches because he has no chance of winning. The outcome is known before the rematch even starts. This goes against the intuitive definition of "game". For a game to be fair every player must stand some chance of winning otherwise it would be something else, like a performance demonstrating the perfect strategy. This is the problem for "solved games" which is a game theory term for games that have unbeatable strategies ("solutions"). Chess is effectively unsolvable but tic-tac-toe's solution is so simple that adults never bother playing the game. Uncertainty being a hard requirement is more of an axiom than something I can defend but the point seems well accepted (as per that GDC video). Additionally, it's difficult to lack uncertainty so this point is of no consequence. The importance of it being listed is to discuss how uncertainty is done in a game: player skill or random numbers/cards etc (better explained in that GDC video).

6/4 (an opponent) My #6 mostly matches Chris's #4. However (quoting wikipedia) "Crawford admits that this is a subjective test. Video games with noticeably algorithmic artificial intelligence can be played as puzzles; these include the patterns used to evade ghosts in Pac-Man." That's absurd. Pac-Man is a game by my strict definition. Chris should use a more objective definition like mine. It doesn't matter how dumb an opponent is: it's still an opponent (artificial or not). The board game Spirit Island is a cooperative game where the enemy is controlled by drawing a card from a deck (then following a few steps). This opponent is very predictable (especially if you don't have events), eg "noticeably algorithmic AI". Pac-Man and Spirit Island are obviously games (by my strict definition). Chris's #4 effectively excludes all cooperative games which is naive and unnecessary. Ideally all points in the definition of a game would be objective and this item is easy to enforce objectively (see next point).

7/5 (can interfere) My #7 matches Chris's #5. If an opponent has any way to interfere (or you attack it) then it should clearly be called an opponent. In the case of a solo/cooperative competition: that's where "is this an opponent?" becomes less clear. I say that if a human opponent (including a team) could do X but X is being done by a system instead then it's an artificial opponent. For example: a metal puzzle that you try to remove the ring from doesn't have an opponent because humans can't control physics. Conversely: when playing golf solo you can compare your strokes to par. This is an artificial opponent because a human could have had that many strokes.

After starting to write this post I saw https://www.youtube.com/watch?v=1kNi3cLB0sI (26:31) "RPGs Were Never About Roleplaying" by "Adam Millard - The Architect of Games". Which does a great job of defining each type of RPG and explaining the common ancestor (investing in a playable character). Likewise, everything that qualifies for the common term "game" does have a spot on my technical definition of game. And I identified the common ancestor as plaything.

Pure software RNG can be truly random

This is a sequel to https://skyspiral7.blogspot.com/2014/09/truly-random.html so read that first. I noticed that Wikipedia was using the phrase "true random" without ever defining what is required for a generator to be truly random. Wikipedia seems to imply that true randomness requires measuring physical things for entropy and that software alone can't do it.

In my last post about randomness, I said "A truly random event has an outcome (or occurrence) that can never be predicted" which is true but not specific enough. If God is the only person who can predict the event and humans never can then that should also be considered true random. But "humans can never predict (even using tools like computers)" is still more strict than it needs to be.

The whole point is indeed to be impossible to predict but consider a 6 sided die: if a computer knows the exact inputs it could predict the result. If a computer doesn't know the inputs then it would have to guess the height from table, spin, initial orientation, and size of die at a minimum (table's friction, die's friction, die's weight, and die's fairness are minor). However, there are way too many possible values to guess compared to the 6 possible outcomes. This means that given a lack of information about the inputs it is easier to guess the outcome than to simulate the process. This makes the process effectively truly random since without the inputs there's no possible formula. Therefore, I propose this definition: a truly random event has an outcome (or occurrence) that can't currently be predicted with more certainty than evenly spread over every possible outcome. Given more information something can lose the "true" status but as long as it is "true" then prediction is impossible which means that a pure software pseudorandom number generator could achieve true randomness (hold your fire there's more requirements to come). To explain why I'll use OTP as an example.

I won't explain how a One Time Pad (OTP) works since it isn't very relevant (you can look it up: it's simple). OTP's perfect encryption relies on the lack of pattern which is only possible if the keys are truly random. Suppose Alice encrypted a message using OTP but the key was digits of pi. Eve knows that Alice's message starts with "DearBob" so she subtracts and sees that the keys would have to be 3141592 and Eve realizes that this is pi. Using that information Eve is able to crack the entire message. These keys are not truly random because the rest of the numbers were predicted with certainty. If Alice tries again using a pseudorandom number generator seeded once at the start, then Eve can do the same thing by guessing the generator and seed (again not truly random). One feature of OTP using truly random keys is that even if the first few letters can be guessed it will tell you nothing about the rest of the message because the rest has no connection at all to the previous numbers. In order for a pseudorandom number generator to meet that requirement it would need a new seed for every number generated, which is to say it would use entropy as-is (stretching the entropy isn't allowed since that would form a small pattern).

Wikipedia says that a cryptographically secure pseudorandom number generator (CSPRNG) needs 2 things. The first is that given the sequence so far it shouldn't be possible to guess the next bit with more than 50% accuracy. The second requirement is that if the entire state of the CSPRNG is revealed or correctly guessed, the rest of the sequence (forward and back) can't be figured out. The first requirement obviously meets my definition of true random and the second does as well because if a pattern is revealed then "true" status is lost. I won't say that all CSPRNG are true random because Wikipedia makes it sound like there's different levels of strength based on what's required and that's technically also true for true random but I just don't know enough about CSPRNG.

It is possible for software to obtain good entropy without special hardware. /dev/random for example looks at timings of low level stuff and as such is truly random (assuming it doesn't stretch the values). Measuring background static, radioactive decay, etc isn't needed (although such hardware might have a higher bandwidth of entropy). Now you might be saying that /dev/random can be fed information and in that case yes it would lose its true random status and if it can lose "true-ness" then it was never true to begin with. However, that's how all "true random" works: they can all lose their status. Rolling dice is considered true random and yet it's possible to roll dice in a way to intentionally feed it specific input values (spin etc) which destroys the entropy and makes it possible for a computer to pre-calculate the result with high certainty. Thus, destroying the entropy causes the process to lose its "true" status. That's universally true: true randomness requires entropy (which is unknown info) and by knowing that info (thus demoting the entropy to regular input data) you also cause the true randomness to be demoted to pseudorandom.

Now you may be thinking that no one can know or control certain quantum stuff and while technically true (for now at least) that isn't useful because the device that reports the value can be hijacked. Assuming that your atomic decay detector hasn't been hijacked is the same as assuming that no one has messed with /dev/random. Now imagine a "change my mind" booth meme and try to think of a reason why pure software entropy is "not as random" as hardware based entropy. That's not to say hardware entropy is useless: it might (or might not) have higher bandwidth (depending on device vs software entropy's source).

Wednesday, August 17, 2022

Smallest TTRPG: Improv with GM

I'm interested in collaborative story telling in the purest sense so I took improv classes but they lack some things I like about TTRPGs. So I made my own system that is as small as possible. It's easiest to start with the entire rules then examples and explanations.


Here is the entire rule set:

1 person is a game master the rest are players. Each player controls their character and the game master sets the scenario, controls the world (NPCs), and decides if players succeed at uncertain tasks. Each person is improvising everything (it need not be comedy). Each player should have equal parts. The GM may talk more or less than a player depending on your style.


That's it. That's the whole thing. But it's a little hard to understand and has some implications that I'll now work through. Starting with some examples:

GM: "Bob: You stand under the window of the house of your girlfriend."

Bob: "I climb up the wall and open the window."

Alice: "Bob? What are you doing here?"

Bob: "I'm sneaking in so we can be together."

Alice: "I can see that but my parents are still home."

Bob: "Not to worry, I brought a door stop."


Does that sound boring? Then you've probably never done improv. This game may not be for you but here's a spicier example that you can't do in improv:

GM: "The dragon breaths fire down on you."

Bob: "I hold up my shield."

GM: "The fire proofing protects you entirely."

Bob: "I counter attack with my sword. Stabbing at the heart."

GM: "The dragon's hide is too thick and you sword only leaves a bruise. He slashes down with his claws."

Bob: "I stab at the hand as it comes towards me."

GM: "Too slow. Your shield is knocked away."


So why not just regular improv?

Most of the system is just improv but having a GM causes some key differences. Failure is impossible in improv (everyone must agree) but a GM's word is law. You can still cause yourself to fail but since the GM is an outside force you can now feel like you are "winning" since you can overcome challenges. Improv is short for improvisational comedy for a reason: comedy makes the most sense. You could also do slice of life and romance but not much else. A GM controlling the outcome of uncertain actions adds conflict which causes suspense and allows for action genre. A GM controlling the world allows for mysteries. A GM controlling any number of NPCs allows for more plot.


What if I don't need failure?

Then you don't need this system. Just do regular improv. Although a GM may still be useful for plot, it might not be a big enough gain.


How much should the GM talk? The 2 examples are opposite in that.

The goal is for everyone to have fun. The GM should talk as much as they like for the genre they are running in order for all players and the GM to have fun. A GM may opt to say as little as possible so that the end result would look like a play: character focused (NPCs are minor characters) with some narration. Or a GM may talk as much as possible so that it ends up looking like a choose your own adventure: lots of text with decisions (but open ended instead of multiple choice).


How is failure determined?

The GM decides based on the situation. Does it make sense? Would it be fun or drive the plot forward? They should not be using randomness like flipping a coin. If the genre is comedy then pick whichever is more funny. If the genre is action then pick whichever is more exciting (not too easy and not hopeless). It is possible for the GM to setup a puzzle where there is only a few ways to succeed and the PCs have to figure it out.


Can there be PC death?

Yes but since there's no character creation process the player can immediately enter the scene as a new character (if the situation and genre allow it).


What's the dividing line between what the GM vs players control?

As with this entire system: it depends on the situation and the group. A player shouldn't have to ask for permission to drink a beer and should be able to control what objects they have on hand. But there needs to be a group consensus on the matter which may adjust on the fly. Once you know each other better it might become obvious when to pause for an answer. PCs might be able to do some very unlikely things just because the genre expects "rule of cool" (or "rule of funny" etc). So there is no specific action that will always need permission. If the GM is tired of saying "yes, please continue" or a player tired of pausing for response then you should have more things be assumed to succeed.


How could there be plot if everything is improvised?

There can't be as much as a book but there can be more than regular improv. More rail roads means more plot but less freedom. That trade off will be determined by the group. But even with lots of freedom the GM controlling all NPCs and major events can direct certain things to build up and pay off. A GM can plan out how NPCs will act in certain situations and knows what the players won't be able to do. "No. As a normal human you aren't able to jump over the castle walls" is less freedom but not considered unreasonable since it's enforcing consistent in-universe physics but even a simple restriction like that allows a GM to plan what's possible (in regular improv you could totally jump it if you wanted).


This sounds really easy/hard.

This system can be easier than regular improv. If you are a very social person without social anxiety then regular improv might be as easy as walking (but that doesn't make it unfun). On the other hand, if you're like me with minor social anxiety but the desire to socialize then regular improv is both easy and hard. It's super easy because I can't be wrong: say anything I think of and everything is fine. It's hard because it's hard to say what I'm thinking. So there's a war in my mind whenever I do this (just like any social interaction). This system can be easier than regular improv because giving more structure makes it easier to make decisions. However a GM can also make a particular encounter within a game hard to win.


Why not just play Fiasco RPG?

Fiasco looks like a fantastic game and I would recommend it. It has more restrictions than this system which is both good and bad. It makes plot easier but only allows certain settings and styles.


Do I have to mime objects and actions?

No. You can if you want but don't have to. I don't like miming stuff, I'd rather describe what I'm doing while sitting at a table. This reason is why I consider this to technically be a TTRPG sorta.


Is this really a TTRPG?

Not really but I don't have a better term for it. Fiasco just says "RPG" but that uses dice and paper so it's easier to claim the "table top" part of TTRPG. As for "roleplaying game": you make a character and act them out so it certainly has as much roleplaying as the group likes. As for game: I technically wouldn't consider any TTRPG to be a game since there are no win/lose conditions but that's semantics.


Thursday, July 7, 2022

Why do we have D&D alignment?

This is a follow up on https://skyspiral7.blogspot.com/2022/07/my-take-on-d-9-alignments.html so read that first.

By now you should be thinking about so many factors that it's hard to keep track of them and you might ask "isn't there a more simple way to accomplish the same thing?". And that is exactly what I wanted you to ask. But to answer it we first need to know: what exactly is alignment trying to accomplish? As the Cheshire cat points out in "Alice's Adventures in Wonderland" by Lewis Carroll if you don't know where you are going then it doesn't matter which path you take.

First it's time to go back to Bob's point 1 which is that character alignment is based on player choices which can change over time. Dan agrees with this as do I. If alignment was fixed at the beginning and never changes no matter what the character/player does then that alignment would represent "the original state of mind of the character" which is useless information. Of course not all characters are static, for ones that are dynamic their alignment needs to also be dynamic.

The 3 of us agree that alignment needs a specific definition if it is to be useful because an ambiguous definition wouldn't have enough support to provide the information desired. Bob and Dan both state that alignment is important but that's something I doubt is true.

First it's important to recognize that alignment is being phased out of D&D. 1e alignment had few options (law, neutrality, chaos) and characters were expected to be lawful. 3e had the 9 options allowing character to be a wider range but certain classes had alignment requirements and characters were still expected to not be evil. There were mechanics that used alignment such as "detect evil" and "protection from good" and all monsters had alignments. In 5e characters are expected to fill in the boxes for personality traits, ideals, bonds, and flaws which together take the place of alignment but there's still an alignment box which is supposed to be the overall picture of those other boxes. Although you are still expected to not be evil, classes no longer restrict alignment and fewer (if any) mechanics use alignment. It seems like Wizards of the Coast recognized that personality/motivation is complex (and started allowing more and more possibilities) and that alignment wasn't doing all that it should be doing (bonds etc fix that issue). In 5e I'm not aware of any reason to actually fill out the alignment box at all (even clerics/paladins can be any alignment with any god). It seems to only exist so that the community didn't freak out because alignment was removed. After all, if alignment didn't exist how could we get into philosophical discussions like this one? There are things that alignment could do that we can do even better without alignment which is to say that we need "something like alignment".

Let me start by stating things that alignment shouldn't do. "this game feature requires that alignment" is bad for role playing: if I have a character concept that makes sense then I should be allowed to play it (even though it doesn't match the usual alignment). In D&D 3.5e monks are required to be lawful and if they stop being lawful they lose their magic kung fu (yes I know magic kung fu doesn't fit medieval European fantasy but it's in the default setting of D&D anyway). A free style martial artist hero who uses a variety of improvised moves and is chaotic is a fine character concept but isn't allowed in this edition for no apparent reason.

Another bad use of alignment is mechanics that interact with it. If a villain is not currently doing anything wrong should detect evil detect him? Is there some sort of naturally forming karma aura that is based on actions that people universally agree are good or evil or do all the gods agree on what counts as good and they watch every single person all the time and judge accordingly? Don't get me wrong moral relativism is BS (look up the trials against post WW2 Nazis) but being able to use magic to enforce morality means you have no need to get to know the person which is bad for roleplaying unless the spells weren't 100% accurate but at that point you'd be better off playing with the idea of "can a demon be good?". If you had spells for "detect demon" that would be fine because that would be telling you facts. There are plenty of ways to play with morality but "detect evil" (and alignment in general for that matter) makes that kind of impossible. If you don't want to play with morality then your villains are going to be obvious so that "detect evil" isn't useful except for surprise villains who are weirdly immune to detect evil to avoid ruining the surprise. The only good use for detect evil I can think of is if something was supposed to be obvious but the players aren't seeing it but in that case there are other clues you could drop.

Another problem is that in D&D 3.5e there's a certain curse that flips a character's alignment. While a ray that makes evil people good or good people evil is a classic trope, it brings up too many roleplaying questions. A person's entire mind is made from a combination of nature and nurture. Your inherent DNA determines some things (drugs and injury are bigger physical factors) but most of it is from your experience. Perhaps you had a childhood trauma or no one has ever treated you like an adult or whatever it is. With that in mind how would a player roleplay their character's alignment flipping? The character hasn't been changed physically and the memories are the same so how am I, as a player, supposed to understand his motivations of this alignment that doesn't fit everything else? Additionally from a gameplay perspective if this wasn't asked for and is permanent (as some of them are) then this is effectively killing the character. That character has that alignment for a reason, switching that alignment is like replacing him with a new character which the player might not like.

Alignment also encourages "my guy syndrome" which is where a player does something consistent with the character but it ruins the game. D&D etc is a game played for fun and socializing. It is better for a character to act in a way that doesn't make sense than it is to ruin the fun or start a player fight. My guy syndrome is possible with any character concept but an alignment makes some people think "what's the most lawful or chaotic thing to do" which is much more dangerous than "how would my character's oaths influence his behavior".

But alignment isn't all bad: there are some good uses for it. I'll talk about how to do these things without alignment. The first thing is "your god/society thinks you are too evil". The thought behind this is accountability for your actions. Actions having consequences is totally valid but it's easy to see that this is possible without alignment. You can keep track of some kind of reputation for people's default attitude toward the character. Likewise a god can threaten "you're straying too far from my teachings, if you don't repent I'll cut off your magic" (you may need to have a conversation with the player too). This is where my alignment definition's actual good vs viewed good comes into play. An evil person can have a good reputation because people aren't aware of everything he is doing. Having an alignment doesn't make this paragraph any easier to do (in fact it's a distraction). For example if a god has a list of rules and the cleric is being very lawful but not following those specific rules then the god can complain even though the alignment is perfectly fine. Likewise reputation isn't as simple as an alignment. Maybe someone has a reputation of being a drunkard, gambler, ladies' man, promise breaker, always late, or being easily angered. Or for something positive like for always having the most interesting stories to tell (although reputation is usually bad instead of good). Reputation can also be used to address the issue of murder hobos. Alignment doesn't cause murder hobo behavior so I won't define what that issue is (it's selfish based but any alignment can be selfish especially if it's killing "bad guys").

Another way that alignment is useful is for character creation brainstorming. Some people like to start with alignment and flesh out the character from there. This can be easily replaced with 2 brainstorming questions: "how does your guy feel about structure and order" and "how does your guy treat others". Another big one is "what motivates your guy". Of course there are tons of possible questions but these 3 are a fine starting place. Your character must have motivation of some kind. Chaotic lazy is not an acceptable character concept.

If you're running a game like D&D 3.5e the alignment restrictions can be removed easily and spells like "detect evil" can be replaced with "detect outsiders that are stereotypically evil" (demons, devils, etc). For character creation (in any game) there are plenty of questions that can be asked (too many to list but you can look up a few). And be sure to keep track of character reputation and consequences of actions taken.

And that's it. Don't stress over trying to label "good" and "lawful". For example the Joker (from DC Comics) is well organized and makes plans that he follows exactly even with backup plans and outsmarting people with traps. Yet he's also seemingly impulsive and seemingly insane and there's very few (if any) things that he won't do. Arguing whether or not he counts as lawful does nothing to help the understanding of the character nor the ability to write Joker stories (or roleplay). Edge cases like this are good examples for why labels are not helpful because character concepts and keeping track of reputation are easily done for the Joker (for extreme versions of the Joker, no one will trust him under any circumstances regardless of if you consider him lawful). There's no doubt he's evil (he enjoys the suffering of others and will take risks to make that happen) but a label that obvious is especially useless.

Another example of useless alignment labels is Kyubey: this paragraph has spoilers for Madoka★Magica. First watch the show (or first 2 movies) then the 3rd movie "Rebellion". Kyubey is obviously Lawful throughout: he's strict with his promises and rules and acts in an orderly manner. World 1 Kyubey has a goal of saving the universe therefore his motivation is good aligned however this method is "the lesser evil" which is not allowed by Christian morality but may be permitted by alignment systems (I didn't cover this in mine because it's more of an edge case and opinion). World 2 Kyubey performed an experiment of trapping someone in suffering in order to see if he could make something, that already had a solution, "better". There's really no excuse for that: it's evil. World 3 Kyubey was trying to save the universe from chaos and did nothing immoral (as of the end of Rebellion). So Kyubey goes from debatably good to definitely evil to definitely good. But this isn't character development: he is exactly the same in all 3 cases however the alignments fail to reflect that and arguing over the alignment will do nothing to help understand his complex character. You could describe him as: seeks the survival of the universe at all costs, lacks compassion, and will allow suffering for the sake of saving the universe in the "most efficient" way possible. Which I guess isn't that complicated but is more than a 9 square alignment system can handle.

That's not to say you can't have any kind of label. You can write down simple notes (like I did for Kyubey above) like: never kills, greedy, or no respect for authority. D&D 5e has a system of bonds etc and Mutants and Masterminds 3e has a system of complications. These are flexible and vague enough to prevent my guy syndrome and allow describing more complicated characters than 9 alignment squares can.

Note that despite all this I still use the phrase "stereotypical lawful good" as an easy way to start describing something because it allows me to start from common ground even though the rest of the description won't follow alignments. So stereotypes can be a useful short hand but most things don't follow them. The alignment definitions I have in my previous post is the best definitions I can come up with but they are still useless.

My take on D&D 9 alignments

Intro

The 9 alignments of D&D have been the source of much internet debate. The reasons for these debates is that people disagree on the definitions of the alignments and judging whether or not someone meets the criteria is subjective.

If you haven't played a game like Dungeons and Dragons (D&D) and don't know what the 9 alignments are then this post is going to be useless and hard to follow. If you want to read it anyway here's a quick and dirty description (better descriptions later) of alignment. Alignment is a category in which your character's morality and personality fit. Alignment is 2 dimensional: lawful vs chaotic and good vs evil. A character's alignment is a 2 word description such as "LE (lawful evil)" or "NG (neutral good)". If a character is in between the 2 extremes the word neutral is used. The same word is used for both dimensions with "neutral neutral" instead being called "true neutral" (which is abbreviated with just N). Typically the 9 alignments are organized in a square with good on top and lawful on the left:

LGNGCG
LNNCN
LENECE

"the extreme corners" refers to LG CG LE CE and "the neutral plus" refers to the rest.

For my take on alignment I'm going to examine 2 YouTube videos which inspired me to write this post, then I'll give my own definitions, then I'll answer the most important question "Why do we have D&D alignment?". To give away the answer I think we shouldn't have alignment at all but pieces of it are useful, therefore I need to first talk about the existing definitions and why they are lacking (including my own). You don't need to watch these videos since my dissection should be detailed enough but feel free to give the videos the views they deserve.

Bob

https://www.youtube.com/watch?v=bfN0xD9cfkw
"How GYGAX Ruined Alignment" by Bob World Builder

Bob explains the D&D 1e alignment was belief based and the subjective nature made it useless until they are tested. However 3e was action based which removed motivation which lead to problems. Therefore he redefined alignment as:

  1. (will be covered in "Why do we have D&D alignment?")
  2. law/chaos: how your character acts. via a code of conduct or not
  3. good/evil: why your character acts. selfless or selfish

Honestly this definition is strong. After my own (obvious bias but will be explained) this is the second best definition of alignment I've seen. It's simple and it just works to the extent that I found it hard to explain the issues with it. If you use his definitions you'll be better off than the majority.

The first problem (and the one that's easier to explain) is that it has neutral be "everything in between" rather than giving criteria for them. This leaves it open to interpretation what counts as neutral. One extreme interpretation is "your character is 99% lawful, since he isn't 100% he's in between and thus neutral". This judgement makes it nearly impossible to be anything except true neutral and makes the 9 alignments pointless since it's basically only 1 alignment. The opposite extreme is "your character is 51% lawful which is mostly lawful hence why I say he's lawful". This judgement makes it nearly impossible to be in the neutral plus instead having characters jump between the corners. While 4 alignments is better than 1 it still isn't the intended 9. Looking at percent makes the problem obvious but when you actually are judging alignment you don't have math. Instead you'll be looking at a list of actions from the character and trying to decide if it falls "in the middle" which is vague. This is why it would be more helpful if there was a clear difference between neutral and the others.

The second problem (or "my second problem with it" since this is more like a philosophical opinion) is "how" vs "why" but the issue is hard to explain. He states that belief is useless until tested. Does he think that his new definition of good vs evil is only useful when tested and the law vs chaos is always useful? I'll cover how/when alignment is useful in "Why do we have D&D alignment?". I assert that alignment should be defined by a person's heart and seen by actions (Luke 6:43-45) therefore law vs chaos should also be defined by "why" since motivation causes actions. If a person swears by a code but doesn't know every rule then does something without knowing that it happens to follow that rule then that person has not behaved in a lawful way (even though an observer may wrongly think that he has). Lawfulness should be defined based on how strongly you intend to follow a principle and not based on how well your action actually meets the criteria.

The third problem is that I disagree with "good" and "selfless" being synonymous. Although being good often requires a degree of selflessness it is more than that. Selfless means to deny yourself but it does not require helping others. Good should be defined as helping others AND being selfless. As opposed to Mormons and Catholics who might help others for personal gain (unlike Christianity which doesn't allow such motivation).

As for Bob's self critique that his definitions would consider self defense to be "evil": morality is big and complex. No matter how well defined your religion or philosophy is there will always be edge cases and confusing scenarios so don't get hung up on "I found 1 example where this doesn't work". It's fine. Although it is fair to point out a known weakness.

Guild Master Dan

https://www.youtube.com/playlist?list=PLYECCocnJ1syH0UDgpnU2wZoTz_z8ssR7
"Dungeons & Dragons: Alignment Done Right" (playlist) by GuildMasterDan

His definition is in the first video but further detail and explanation is provided by the other videos in the playlist.

He defines the alignments as

  • Lawful (renamed to principled): has some kind of code
  • Neutral: has a world view instead of rules
  • Chaotic (renamed to unprincipled): doesn't have any rules

  • Good (renamed to selfless): doesn't seek self interest AND seeks to help others
  • Neutral: doesn't seek self interest OR seeks to help others (but not both)
  • Evil (renamed to selfish): does neither

While he does provide definitions for neutral he makes the same mistake of conflating selfless and good. His definitions appear to be action based but when talking about details and examples they appear more motivation based. So most of my critiques overlap with Bob's alignment definition.

However Dan provides a better example of the issue with conflating selfless and good. This can be seen in his LN video's "expected" example character. He claims that Samara (from Mass Effect) is LN because she's inconsistent about being selfless when in fact she's perfectly selfless but not always to the benefit of others. My above description of his definitions have more detail than his stated definitions because he doesn't realize that selfless doesn't mean good. In this case Samara executing a criminal for the benefit of the many at the expense of an individual is a moral edge case and thus not one that can be easily measured against "helping others". His ending example of the LN "black knight" is a better example of his view since such a person would follow evil orders just because they always follow orders and not because they want to do evil and thus is selfless (since they suppress or lack their own feelings) but aren't being "good". Personally I would consider this black knight to be evil since if they know the acts are evil and continues to allow/support evil then they are evil even if they aren't doing it because they enjoy evil.


My definitions

  • Actual Lawful: likes rules and follows them as much as possible
  • Actual Neutral: views rules more like guidelines and will ignore them sometimes. an impulsive person doesn't think about rules and falls in here as well.
  • Actual Chaotic: hates rules. sometimes rebellious and sometimes ignores them but thinks that rules shouldn't exist

  • Actual Good: selfless benevolent: likes other people
  • Actual Neutral: selfish but not hateful or selfless that isn't for the sake of others
  • Actual Evil: malevolent: hates people (selfish or selfless)

  • Viewed Good: beneficial
  • Viewed Neutral: useless
  • Viewed Evil: harmful

If you've read this far these definitions should be little surprise but I'll need to go into some details. The first thing to address is the 1 thing that may have surprised you: why are there 2 definitions for good vs evil? The reason is that I'm making a distinction between what your alignment actually is vs what people think it is. To be truly good you must be selfless but people can't read your mind (and you may even fool yourself) so people can think of you as good even if you have selfish motivations (as long as you don't make them obvious). This distinction between what you are vs what people think you are will be important for "Why do we have D&D alignment?" (and by now it should be obvious why that I made this post first). You'll notice that the actual law dimension and the actual good dimension are both based on motivation because motivation is what determines your actual alignment.

You may wonder why there's no viewed law dimension. Well there is but I didn't list it above because it wasn't needed to address my concerns and the definition is simple: do people think you fit the actual lawful etc. So technically yes, there's an actual 9 alignments for how your soul is judged (ie who you really are) and a viewed 9 alignments for reputation. However viewed law is more vaguely defined and less useful anyway so meh.

Another difference between actual good and viewed good is that while generally speaking actual good is also viewed as good this isn't always true. If you are trying to help but cause a lot of damage due to incompetence you are actually good but possibly harmful.

A detail about actual good vs evil that's missing above is that of dedication level. Actual good is someone who will be willing to go out of their way, take risk, and sacrifice for someone's good. Actual evil is someone who will be willing to go out of their way, take risk, and sacrifice for someone's harm. Actual neutral may do things that are good/evil but is not too much effort, low risk, and low cost. This means that actual good is a little more heroic and that most people fall into actual neutral (more on that later). This dedication level is part of what it means to be selfless vs selfish: being selfish doesn't mean refusing to do something easy that helps someone.

The actual law dimension is not based on how many rules you have but how strongly you hold them. If a lawful character runs into a situation that his rules don't cover he isn't required to make a rule before he can act (although he is allowed to make a rule if he wants) which is to say that a lawful character can act and make decisions without needing to always depend on rules. However a lawful character has such respect for rules that if a rule is clear he'll want to follow it if possible. A lawful character need not subscribe to all rules (which would be impossible anyway) but he would typically appreciate the idea of the rule even if it's in a code that he doesn't follow. Conversely a chaotic person hates rules perhaps because he feels like rules restrict freedom (which is not always the case). Someone who thinks rules are mostly pointless would be neutral.

Lawful can be applied to all types of advice: philosophy, religion, common sayings, code of conduct, governmental laws, personal advice, plans, blueprints, instructions, or guidelines. Even though guidelines is in my definition of neutral the difference is how you view them not how the rules are written. A book with very general advice can be taken as gospel by a lawful person or a very specific book can be taken not very seriously by a neutral person. I'll use a vacation as an illustration but keep in mind that this is how such people might react and is not always the case since personality is much more complex than an alignment chart (also see "Why do we have D&D alignment?"). Alice prefers to join tour groups because she likes the way everything is planned out and she can look at the schedule to see what's next. Following structure like this makes her feel safe like everything is under control. Her love of rules makes her lawful. Carol likes to get an example itinerary online then quickly notes which items are important and edits in time to explore and do her own thing. If this is how she tends to treat all rules in life she would be neutral because she's using rules as a basis for her own ideas (which are not as rigid). Eve is given an itinerary. This makes her unhappy because the list makes her feel restricted, trapped, and controlled even though she enjoys all of the things on the list. Her hatred for rules makes her chaotic.

If a person thinks rules are good and opposes those rules because they want bad things to happen that would be evil but doesn't affect law/chaos. Although you certainly can respect the rules of others doing so doesn't affect how lawful you are. If a person is trying to overthrow society and makes a complex plan for how to do it then follows that plan exactly then they would be a lawful anarchist. This sounds like an oxymoron but it is because they have such respect for their own plan even though they have no respect for government's law. Recall that lawful only requires a positive view of rules of any kind (but not all kinds) in this case it is for their plan. A chaotic person wouldn't have a plan and a neutral person might make a vague plan but then improvise (without being forced to do so) just because they changed their mind about how some part should be done.

By my definition (ignoring "viewed") the average person would be true neutral. I consider this a strength of my definitions since most people are not heroes or villains. They don't think about morality much and live a normal life sometimes being good but only if it isn't too much too ask. Villains/antagonists would also rarely be evil (since selfish is the most common). I consider this to be a strength as well: most villains aren't evil and don't consider themselves evil. If a selfish villain gets what he wants then he may settle down. Whereas a truly evil villain is never satisfied because hurting people was the whole point (rather than a means to an end).

I feel like this is the best possible definition for alignment because it answers every issue I can think of. But you still shouldn't use alignment (see next post: "Why do we have D&D alignment?").

Saturday, February 6, 2021

Binary Delta CRUD

Update: this spec was moved to https://github.com/SkySpiral7/BinaryDeltaCrud/blob/trunk/docs/spec.md see that for the latest version.

I learned about the format of a (unified) patch file from the Unix command diff -u and was inspired to make a new delta format that is very compact, supports binary (it is not human readable), and is payload type agnostic. Since I don't know anything about this subject area I based this format on CRUD (Create, read, update, and delete) and so am calling this format Binary Delta CRUD. Note that the use of delta here is referring to math where delta is used to show change.

The scope of this doc is only for the delta format and not for describing the algorithm to analyze the data in order to create the delta. Analyzing the data is very important and the most complex step and would need it's own doc. However I don't know anything about how you would do this data analysis, there's no perfect solution to this problem, and you can read existing papers on compression and file comparison therefore I likely won't have a doc for such data analysis.

To describe this format I will use the names inputStream, deltaStream, and outputStream because the payloads might not be files (although files are the main use case I can think of). Note it is not required to know the number of bytes involved in a stream ahead of time as long as you know when it ends. The final operation in deltaStream will always have an operation size of 0 (explained later). Obviously each stream must be finite. It is possible to process the streams without needing to go backward: a buffer isn't needed if you are performing the operations normally (not reversed) or know the size of deltaStream. Note that all numbers in this specification are unsigned big endian where a * in binary means "any bit".

Each operation in the deltaStream starts with a single header byte which indicates which action to take and what to do with the bytes that follow. The outline of the header byte is: the highest 3 bits is the operation, the next bit (the lowest bit in the highest nibble) is an operation size flag, and the lowest nibble is a size (which might be the operation size).

The operations are:

0 (binary 000* ****) "add" operation (C in CRUD)

1 (binary 001* ****) "unchanged" operation (R in CRUD mnemonic)

2 (binary 010* ****) "replace" operation (U in CRUD)

3 (binary 011* ****) "remove" operation (D in CRUD)

4 (binary 100* ****) "reversible replace" operation

5 (binary 101* ****) "reversible remove" operation

6-7 [unused operations] 2 spots

If the operation size flag bit is 0 then the lowest nibble is the operation size (1 to 15 bytes). If the operation size flag bit is 1 then the lowest nibble is the size (1 to 15 bytes) of the operation size and the actual operation size (1 to 256^15 bytes) will follow the header byte. The operation size is the number of bytes that the operation will use. An operation size of 0 is infinite which means the operation will be performed on the remaining bytes then the program will terminate. When the operation size flag bit is 1 the operation size is allowed to have leading 0 bytes (although this is a waste of bytes in the deltaStream).

For example given a header (in binary) of: 0000 0010 means that 2 bytes will be added. A deltaStream that starts with 0011_0010 0000_0001 0000_0001 means that 257 bytes will be unchanged since the header indicated that the next 2 bytes should be used for the operation size.


"add" operation means that a number of bytes should be added to outputStream. The bytes that will be added will follow the operation size. It is invalid if deltaStream does not have enough bytes left.

"add remaining" is an "add" operation with an operation size of 0. It means that all of the bytes remaining in deltaStream should be added to outputStream then terminate. It is invalid for inputStream to contain any remaining bytes. It is invalid for deltaStream to not have any more bytes (since it failed to add anything).

"unchanged" operation means that a number of bytes should remain unchanged (ie read with no-op) simply copy them from inputStream into outputStream. No bytes will follow the operation size. It is invalid if inputStream does not have enough bytes left.

"remaining unchanged" (ie "done" or "no more changes") is an "unchanged" operation with an operation size of 0. It means that the remaining bytes in inputStream should be unchanged (copied to outputStream) then terminate. It is invalid for deltaStream to contain more bytes. It is permitted for inputStream to not have any more bytes (this allows an empty file to remain unchanged for example) since an empty set of bytes being unchanged is logically valid.

"replace" operation means that a number of bytes in deltaStream will replace the same number of bytes in the inputStream (ie add deltaStream bytes to outputStream and ignore bytes from inputStream). The new byte values will follow the operation size. Unlike "reversible replace" this operation is more compact but can't be undone since the previous byte values are unknown. It is invalid if inputStream or deltaStream do not have enough bytes left.

"replace remaining" is a "replace" operation with an operation size of 0. It means that all of the bytes remaining in deltaStream should replace the same number of bytes in inputStream then terminate (ie add rest of deltaStream to outputStream and ignore rest of inputStream). It is invalid if inputStream and deltaStream do not have the same number of remaining bytes. It is invalid if inputStream or deltaStream have no bytes left (since it failed to replace anything).

"remove" operation means that a number of bytes should be removed ie these bytes in inputStream should not go to the outputStream. No bytes will follow the operation size. Unlike "reversible remove" this operation is more compact but can't be undone since the previous byte values are unknown. It is invalid if inputStream does not have enough bytes left.

"remove remaining" (ie "close outputStream" or "write no more bytes") is a "remove" operation with an operation size of 0. It means that the remaining bytes in inputStream should be removed (not sent to outputStream) then terminate effectively making this a "close outputStream" operation since there is no more data to write (only thing left is to validate). It is invalid for deltaStream to contain more bytes. It is invalid for inputStream to not have any more bytes (since it failed to remove anything).

"reversible replace" operation is the same as "replace" except reversible and less compact. After the operation size there will be that number of bytes which are the old values then that number of bytes which are the new values. This exists so that after running through deltaStream normally you can later decide to undo the change by running the opposite of deltaStream (assuming deltaStream is a file or something that can be referenced again). Additionally this has a validity check built in since if the old bytes do not match inputStream then deltaStream is invalid. It is also invalid for inputStream or deltaStream to not have enough bytes left.

"reversible replace remaining" is a "reversible replace" operation with an operation size of 0. It means that the first half of the remaining bytes are the old values and the last half are the new values (see "reversible replace" for details) afterwards terminate. It is invalid for deltaStream to have an odd number of bytes left. It is invalid if deltaStream does not have exactly twice the number of bytes that remains in inputStream. It is invalid for inputStream or deltaStream to not have any more bytes (since it failed to replace anything). While is it possible to execute deltaStream as you get it (counting the bytes but not needing a buffer), trying to do the opposite of deltaStream will require you to read the rest of deltaStream first. As a quick proof: start counting while validating inputStream until it runs out (or fails validation) then count down while writing to outputStream until deltaStream runs out (or fails validation). If doing the opposite of deltaStream you won't know when to stop writing to outputStream unless you already know the number of bytes in deltaStream (in which case you won't need a buffer).

"reversible remove" operation is the same as "remove" except reversible and less compact. After the operation size there will be that number of bytes which are the old values. This exists so that after running through deltaStream normally you can later decide to undo the change by running the opposite of deltaStream (assuming deltaStream is a file or something that can be referenced again). Additionally this has a validity check built in since if the old bytes do not match inputStream then deltaStream is invalid. It is also invalid for inputStream or deltaStream to not have enough bytes left.

"reversible remove remaining" is a "reversible remove" operation with an operation size of 0. It means that all of the remaining bytes are the old values (see "reversible remove" for details) afterwards terminate. It is invalid if inputStream and deltaStream do not have the same number of remaining bytes. It is invalid for inputStream or deltaStream to not have any more bytes (since it failed to remove anything).


For a concrete example given that deltaStream contains (in binary): 0010_0101 0000_0010 0011_1000 0100_1110 0010_0000 translates to: unchanged with operation size 5, add with operation size 2, the first byte added is hex 38, the second byte added is hex 4E, done (keep the rest of inputStream). A shorter description (rather than a byte by byte one) is that the first 5 bytes are unchanged, add the hex bytes 38 and 4E, then the rest of the bytes in inputStream.

For an example of why the reversible operations exist: suppose I have a file named mainFile and a file named deltaFile. I run a program using mainFile as inputStream, mainFile as outputStream (writing to same file), and deltaFile as deltaStream. I examine the new state of mainFile and decide that I want it to return to the previous state (perhaps it failed quality control or checksum). I run a program using mainFile as inputStream, mainFile as outputStream (writing to same file), and deltaFile as deltaStream along with a flag that indicates that I would like a reverse done. If deltaFile does not contain any of replace or remove operations (including operation size of 0) then it is possible to restore mainFile back to the previous state by simply performing the opposite instruction in the deltaStream. This is useful for version control systems so that it can cause a file to go forward or back a version by only looking at a single delta (similar to git). This is likewise useful if you send out an update then later decide you need to rollback the change. For the sake of network compactness: a reversible delta can be created from a non-reversible delta while reading it (this requires a buffer the size of the largest replace operation).

The exact number of bytes for outputStream will be unknown until the deltaStream has been completely processed. The maximum sizeOf(outputStream) = sizeOf(inputStream) + sizeOf(deltaStream) - 2 - sizeOf(sizeOf(inputStream)) unless sizeOf(inputStream) is 15 or less in which case add 1 (counteracting the sizeOf sizeOf). This maximum can be achieved with a deltaStream of: unchanged, size of inputStream, add remaining, entire deltaStream.

Note that 64 bit computers only need 8 bytes to express the maximum file size (16 EiB exbibytes) which is expressible (in binary) ***1_1000 1111_1111 1111_1111 1111_1111 1111_1111 1111_1111 1111_1111 1111_1111 1111_1111. Notice that the maximum number of bytes supported for operation size is 15. 15 bytes for the operation size would mean the total size that can be handled with 1 header is 256^15 which is 1.3e36 bytes or 1.1e12 yobibytes. For any larger sizes you will need to perform the same operation multiple times (this will never be needed).

Warning: make sure you trust the deltaStream and have enough memory/disk space to handle the various operation size 0s. An attacker could send binary 0000 0000 followed by an endless stream of junk bytes in order to fill up the RAM or hard drive. That said it makes little sense to allow public access to change something using a deltaStream in the first place.


Does this format do better with a sparse or dense delta? It handles both very well. If an entire 4 GiB payload is being replaced (every byte changed) the overhead is only 1 byte (replace remaining, entire payload). If only a single byte is replaced in a 4 GiB payload the overhead is a maximum of only 7 bytes (unchanged size 4, 4 bytes op size, replace op size 1, new byte, done) with a minimum overhead of 2 bytes (replace op size 1, new byte, done). For an unchanged payload (of any size) the entire delta is 1 byte (done).

Does this format do better with plain text or binary payloads? The delta is not human readable. It is able to handle binary and text/plain is just a type of binary therefore it is agnostic to payload media type. Contrast a patch file which is designed to be human readable, can't handle binary, and includes info for the file name and date (ie it assumes a file system).

Can this format do everything a patch file can? No: this format doesn't handle file names or last modified timestamp (which are filesystem dependent). You could use this format 3 times for the name, modified timestamp, and file contents. Or you could use this format on a tar etc. For multiple files you can make a delta for each file (a delta can be add all or remove all for adding/removing files) or tar the files together and delta that. Which is to say that this format can do what you need but since it's payload agnostic (doesn't assume files) you'll need to do bookkeeping yourself in order to attach meaning.


I thought of operations for flipping the bits of the bytes or filling a length with a certain specified byte but the later is not in the spirit of a delta (that would be compression) and the former is questionable (there is still enough space for flipping if someone wants it) so I didn't.

I thought of an operation for paste (as in copy/paste) which would require a clipboard index to be setup at the beginning of the deltaStream. While this operation makes sense from a perspective of "how a human would edit something" this format isn't intended for human operations and this is another operation that seems like a compression thing.

Saturday, November 28, 2020

How to do paradox free time travel

TL;DR: copy on write


First of all there's nothing wrong with your story having a time paradox, in fact certain stories require it. Trying to prevent a paradox is a valid motivation for a crisis, timestream changes can be an interesting way to add complications, etc. However for some stories you may want it free of paradox and that's more tricky than it sounds so I thought I would detail how this can be done (option #3 is the only real way).


First I need to explain what the issue is. For a single timeline that can be altered by traveling backwards in time there are 2 paradoxes that arise: a grandfather paradox and a bootstrap paradox. The grandfather paradox is the most commonly talked about paradox (and is normally just called a "time paradox" but that would be confusing). A grandfather paradox is often described as "what happens if I go back in time and kill my grandfather before my father was conceived?" The problem is that if there is a single timeline (by now you may have guessed the solution) on which you go backwards you can contradict it. If you kill your grandfather then you couldn't've been born which means you couldn't've killed him which contradicts the original action and thus the timeline is in an invalid state.


A bootstrap paradox is sort of the opposite. An example would be that you have a necklace that has been passed down from your great grandfather. You hear a story that he got it from a time traveler who turns out to be you. In an attempt to avoid a grandfather paradox you go back in time and give the necklace to your great grandfather. The necklace's place on the timeline is a nice circle which appears to be fixed but who created the necklace? How old is it? This necklace exists because it already exists. This is a causation paradox (which requires backwards time travel).


Notice that if you go back in time and do something then it will either cause a grandfather paradox (because the event wasn't supposed to happen) or a bootstrap paradox (because it was supposed to happen). You may say "I promise not to do anything important" but that's not good enough. Even something as simple as stepping on an ant is an event that happened and thus would cause either paradox but it's more extreme than that: every breath you take, every photon of light you absorb, every air molecule you displace. It's impossible to exist in any tangible way without causing a paradox.


However there are solutions which I will do from least useful to most. The first point (option #0) is to not do time travel at all which works but doesn't meet the criteria of "paradox free time travel" and thus is not considered an option. The first actual option (which isn't much better) is to do forward only time travel. These paradoxes only occur from going backwards, going forward causes no issues as long as the traveler never returns (by going backwards). You could make a story of someone going into the far future and be unable to go back and there would be no paradox (he absolutely can't go back to "his time" since that would cause a paradox with the present he's currently in). In fact this has been demonstrated to be possible in real life (only going forward a few seconds) and thus forward only time travel is an undebatable scientific occurrence that's iron clad against any paradox.


Option #2 is to have the past be "read only" such that it can be seen but nothing can be changed. The man who goes back will be as though he is intangible and absolutely nothing he does makes any difference. For this to work the time travel device would need to duplicate the photons so he can see them (in addition to the past photons which the past objects interacted with) and the same is true for all his senses. You may wonder if this is actually time travel or just watching a movie of something that happened in the past. You can describe it as backwards time travel but it doesn't really feel like it is.


This leaves the only real option #3 which is complicated but can be summed up as "copy on write". The 2 paradoxes hinge on the phrase "a single timeline that can be altered by traveling backwards in time." Option #1 disallowed traveling backwards, option #2 disallowed altering, and option #3 doesn't use a single timeline. Whenever someone travels back in time by any amount the timeline is copied and they are placed in the new one. Traveling forward in time remains in the same timeline. Basically the past of each timeline is unchangeable but a copy can be changed in any way without paradox. This model allows meeting copies of yourself since if you travel back in time to a point you existed the entire past is copied including your body. If you don't like what you've changed you can go back and murder your copy who was about to change it (this doesn't affect the previous timeline you were in) or go back right before he got there and have no copy show up (since only the past is copied). You can get as many copies of yourself as you like and if you'd like to return to normal you can travel back to before you touched anything then forward in that copy to your normal time to get an equivalent to your original assuming your brief tangibility didn't affect much. You could also permit returning to a timeline as long as the point of return is during or after what is considered the present for that timeline (the present being the last point in that timeline that has been visited by anyone).


Option #3 sounds complicated but allows for basically everything and should be easy to use. In fact if you never explain that copies are being made this time travel model will "just work" and still allows things like "we need to stop this event or we are screwed" for the timeline you are in. That said this model (as is) doesn't allow someone to be aware that the timeline has changed (since it's a copy, their own timeline hasn't changed) and again a crisis like "if we don't prevent this time paradox it will be the end of time itself" would require a paradox based model.


Note that being able to predict the future causes no time paradox. It doesn't matter if the prediction is contradicted. Unlike traveling to the future and back which causes issues because it wasn't a prediction, it actually happened and things aren't supposed to un-happen.


Professor Farnsworth: Your grandfather?! Stay away from him, you dim-witted monkey! You mustn't interfere with the past! Don't do anything that affects anything, unless it turns out you were supposed to do it, in which case for the love of God, don't not do it!

Fry: Got it.

Professor Farnsworth: If, for example, you were to kill your grandfather, you would cease to exist.

Fry: But existing is basically all I do!

--Futurama episode "Roswell that Ends Well" (TV 4x1). A joke that only works if you allow paradoxes.