User:Zzo38/Game rules

From Esolang
Jump to navigation Jump to search

This article has a list and descriptions of some games that seem to be known and occasionally discussed by at least two people in the esoteric programming IRC or were in the past. The descriptions are not always complete; sometimes the rules are complicated and it is not worth listing all of them here.

Any program code in this article (in any programming language) is public domain; in most cases I am the author of this code, even if I had not invented the games listed here.

See also: User:B_jonas

Sokoban variants

So Broken

This is a sokoban variant that some people on esoteric programming IRC have played.

I have not played this game but I had made a FOSS implementation of what I know of the rules. (I think it is like sokoban but you can move the boxes back where they were before without also moving the player. However, in this implementation, instead of the player being immune to "Undo" (which is not possible in Free Hero Mesh; "undo" always undoes everything and you cannot override that), you can push S and R to save and restore the positions of the boxes while leaving the player in place, which I think is effectively working the same.) One thing that I have been told, but which the code below does not include (but it is easy to add it; someone who can confirm this can do so if you want to do), is that apparently the player is not supposed to be allowed to move if there is a box in the same cell as the player.

($Player
  (Image "PLAYER")
  Player
  Input
  (Strength 1)
  (Rook Move)
  ('S "t-cg+ce" 1 Sound %n 1 + =%n 0 #Save 0 0 Broadcast .)
  ('R "tec-gc" 1 Sound %n if %n 1 - =%n 0 #Restore 0 0 Broadcast . then)
  (MOVED "zf" 0 Sound)
  (BEGIN_TURN (=P $Box / $Target) lnot if "s-c+cg+c" 1 Sound WinLevel then)
)

($Floor
  (Image "FLOOR")
  (Density 1)
)

($Box
  (Image "BOX")
  Shovable
  (Weight 1)
  (Height 1)
  (#Save $Saved Loc 0 0 Create .)
  (#Restore Destroy .)
)

($Saved
  VisualOnly
  (#Save %n 1 + =%n)
  (#Restore %n if %n 1 - =%n else Destroy . $Box Loc 0 0 Create . then)
)

($Target
  (Image "TARGET")
  (Density -1)
)

Card games

Mahjong

Mahjong is not always classified as a card game, because you will usually use tiles instead; however, I think that its structure is still a card game so it would still count as a card game. There are many variants, although this article will only describe the Japanese "riichi" variant.

There are four players, which are east, south, west, north (in that order), and the east player is the first player; after each hand, usually you shift so that the south player is now east, west will now be south, etc; except if east wins in which case it is repeating. (East player is also called "dealer" or "oya".) Each player draws thirteen tiles, and one dora indicator is shown publicly; the next number in the same suit is called dora; each dora in your hand if you win is worth extra points.

On your turn you will draw a tile, and then discard one tile, unless you have a complete hand and you wish to claim a win ("tsumo").

Once a tile is discarded, any player might claim it, before the next player draws; in that case they put that tile into their hand to make a sequence ("chii"; only the immediately next player after the discarder can do so), triple ("pon"; any player can do), quad ("kan"; any player can do), or win ("ron"; any player can do even if it is a sequence, but not if you are furiten). The claimed tile, and the other two or three tiles in the same set that it is a part of (or the entire hand if you win), must be exposed, and can no longer be discarded. This will interrupt the turn order, and then once they discard (unless they have won) then the player after that player will be next.

There is also a "closed kan" and "added kan", which you do on your own turn after you draw and before you discard. Any kan, whether open, closed, or added, will need to draw an extra tile, since that is one of the sets and you need four sets of three (or four if a quad) and one pair, to win.

If you have not already claimed other's tiles then you can also do "riichi", which costs you 1000 points and prevents you from choosing what to discard (you can only discard the tile you draw), but you may earn more points if you win.

A complete hand has four sets of three or four tiles (either three numbers in the same suit in sequence, three same tiles (they must match both number and suit), or four same tiles), and one pair of two same tiles. There are also irregular hands which do not follow this pattern. However, to win you must also have at least one yaku, in addition to a complete hand.

"Furiten" means you had discarded a tile that would complete your hand if it is in your hand now (even if you do not have any yaku); in this case you cannot win by ron (even if it is a different tile than the one that you had previously discarded), but win by tsumo is still possible.

The scoring involves various yaku and other stuff, so that some kinds of hands will be worth more than others; the scoring is not described in elaborate details in this article but can be found in Wikipedia and others. Win by tsumo means all opponents pay you, but win by ron means the discarder must pay the same amount that everyone would pay in total, and nobody else has to pay. The highest score for one hand is called "yakuman".

(TODO: If known, mention which rule options (e.g. kuitan ari vs kuitan nashi) are commonly used in the places where people in esoteric programming IRC are known to play mahjong.)

Magic: the Gathering

A card game with many possible cards, although usually only some of them will be used. Magic: the Gathering is Turing-complete.

(TODO: Write some more about this; maybe some other people might do)

Some of the current versions and some old versions of the rules, converted into HTML format, can be found at: http://zzo38computer.org/MtGrules/

Others

Pokémon

This is not the same as the pokemon card game; it is an entirely different game.

There are several versions (generations) as well as many variants.

Each player has six pokemons; you will define your team before the game starts (although in some variants they are decided at random).

Each pokemon can be defined as:

  • Species: This determines its types and base stats, as well as which abilities and moves are valid.
  • Level: The level of this pokemon; normally 100 (which is the maximum). This affects stats, as well as affecting damage caused by moves that use the usual damage calculation.
  • Gender: Rarely relevant, although there are some effects that care about gender. The possible genders are: male, female, and no gender; the species may restrict which genders are possible.
  • Ability: These abilities can have various effects, without being selected during the battle. Selected from one of the abilities valid according to its species (there are up to three possibilities, generally).
  • Item: Like abilities, items can have various effects, without being selected during the battle. Any pokemon species can hold any item, although some (e.g. mega-evolution stones) are only meaningful for some species.
  • Stats: There are six stats (described below), which are derived from base stats (according to the species), effort values (each from 0 to 252, but each pokemon cannot have more than 510 effort values in total), individual values (0 to 31), and natures (which is optional; if you set a nature then it increases one of your stats other than max HP by 10% and decreases another other than max HP by 10%).
  • Moves: Up to four moves, selected from the moves valid according to the species. Each move will have "PP" (meaning the maximum number of times it can be used), as well as a category (physical, special, or status), type, power, accuracy, priority, secondary effects, targeting, and other properties.
  • Tera type: In generation IX rules, each pokemon also has a "tera type", which can be any type. (This is not the same thing as its usual type, although it may be the same type.) It can be used to change one of your pokemon's types once per battle.

There are eighteen types and have weaknesses, resistances, and immunities, to other types; pokemons and moves can both have types. A pokemon can have one or two types (although some effects can temporarily change or remove their types or add a third type), and a move has one type.

The stats are:

  • Max HP: How much damage you can receive before fainting. Some effects will damage or heal you by a fraction of max HP, in which case ctz can occasionally be significant. A pokemon with zero current HP is "faint", and can no longer do anything in battle.
  • Physical Attack: Used in the usual damage calculation for most physical moves; the power is multiplied by the ratio of the attacker's attack stat and defender's defense stat. Usually just called "Attack" instead of "Physical Attack".
  • Physical Defense: See above. Usually just called "Defense" instead of "Physical Defense".
  • Special Attack: Like Physical Attack but for special moves instead of physical.
  • Special Defense: Like Physical Defense but special moves instead of physical.
  • Speed: Determines order of execution in case of equal priority. If the speed and priority are both tied then the order is decided at random.

The game is:

  • During the battle, you can see your own current HP (the exact number of HP) and all other details, but the only things you can see of opponent's pokemons are: species, level, gender, percentage of current HP (but not the exact number, nor their max HP), non-volatile status, and which move that pokemon executed. (You cannot normally see such things as: moves which have not been executed, items, stats, etc; but you may be able to guess, or to figure out what they are or aren't due to what else happens during the game.)
  • Each player must select a command, which is either a shift command or an attack command, for each of their active pokemons (there is only one if it is single battle but two if it is a double battle; other pokemons are inactive pokemons). In some versions there is also a add-on command (mega-evolution, Z-moves, dynamax, or terastal) which is selected at the same time as an attack command; these add-on commands are usually limited to only once per battle. The players select commands simuntaneously without knowing what commands are selected by opponent during the selection phase, instead of taking turns. (Selecting a command is mandatory; you cannot choose to pass your turn, although sometimes some commands will have no effect and sometimes execution of the selected command will be prevented.)
  • An attack command must be one of the four moves that your active pokemon has. This will usually damage the target (if it is a physical or special move), or do something else (if it is a status move). In a single battle the target is implied, but in a double battle you must select the target if it is not a move that automatically selects the target (in many cases, these are moves that allow multiple targets, but some target the user); if you can select the target then usually you can select anyone except the user (usually an opponent's pokemon, although it is legal to select your own other active pokemon too). Some moves have additional effects (e.g. recoil damage).
  • A shift command switches out the pokemon that selected that command (which makes it inactive), and you must select one of your inactive pokemons (with positive current HP) to take its place (making it now active). A shift command has higher priority than any attack commands have, which means if you select a shift command and opponent selects an attack command that targeted that pokemon, then the attack will hit the pokemon that is switched in (and it is possible that the pokemon that switched in might be resisted or immune to that attack).
  • Commands are then executed in order from highest to lowest priority; however, if a pokemon faints (or flinches, or other conditions that can prevent it) then its command will not be executed.
  • If a pokemon is fainted then it can do nothing in battle. You must select one of your non-fainted inactive pokemons to take its place before the next turn begins. If an attack that selected a pokemon as its target that is now fainted by the time the attack should be executed, it hits the other pokemon instead if possible.

The goal of the game is all of opponent's pokemons faint before all of your pokemons faint; if you manage that then you win. (Sometimes all of both player's pokemons faint on the same turn; in this case, whoever's pokemons all fainted first is the loser.)

(There are many other details too (e.g. non-volatile status, stat stages, entry hazards, weather, terrain, protection, etc), but they will not be mentioned here.)

(Something I intend to do is to make a FOSS implementation of Pokemon in C, and to include comprehensive documentations of the rules with it. Some FOSS implementations already exist, but are not written in C and lack some features which I consider desirable and/or have some features that I do not consider desirable.)