Module:Sports table/Chess/doc

This style for Lua-based Module:Sports table is meant to build group and league tables for chess round-robin competitions with a crosstable. Unlike the WDL style, in this style wins and total points are calculated from match data that is provided. Therefore, if you want to use this style without a crosstable, you still need to provide all of the information that would appear in a crosstable, so you might want to explore other options, such as the WDL style. This documentation explains how to use this module with the Chess style in an article or template; check the table of contents for specific items.

Basic usage
In its simplest form only several parameters need to be used to build a table. The main command is the statement which calls the module with the Chess style and enables you to set everything up. Then you list the positions of the teams as team1, team2, etc for however many teams you need in the table. You can use full team names there without spaces as the team codes if you want, but using short codes (as in the example) can make it easier. For each team, you now define the name_TTT parameters (with TTT replaced by the team code) which determine what name is shown in the table; you can use wiki markup and templates in here as well, as shown in the example. The points and wins will default to 0 if no match data is provided. See to see how to provide this data. See and  to see how to change the source and update date.

Points
Points are calculated using match data. The match data that is used to calculate points is given by match_XXX_YYY where XXX and YYY are different team codes. This parameter takes a value of W+B, where W is the result as white and B is the result as black. The results use the character 1 for a win, ½ for a draw, and 0 for a loss. Note that incomplete information such as ½+ is allowed, and still calculates correctly. As a default, a win is worth 1 point, a draw 0.5 points and a loss 0 points, these values can be overwritten to what you need by winpoints, drawpoints and losspoints, if such parameters are provided. Head-to-head values are not calculated automatically, and are given by the parameter hth_XXX. The parameter disp_fractions determines whether the calculated points and head-to-head values (if any are given) are displayed as fractions or decimals. Note that this parameter should only be set to yes if winpoints, drawpoints and losspoints are a multiple of $1/2$. Otherwise, an incorrect fraction will be displayed.

Crosstable
Because the match data already needs to be provided for use with this style, very little additional data is needed to create the crosstables. The show_matches parameter determines whether the crosstable is shown, and defaults to no. In the crosstable, the values given by match_XXX_YYY are shown. The headers for the columns are given by short_XXX. If no value for short_XXX is given, then one is created automatically from the team code, with appropriate wikilinks and data included. It is recommended to set the value of short_XXX using the undefined template with a short abbreviation (possibly the player's initials) to appear in header of the columns of the crosstable.

Customizing the crosstable
There are a few parameters that can be used to customize crosstables.

As shown in this example, no parameter is needed to determine the number of games per match. This is calculated automatically from the largest number of plus signs in the match data. If the use_pos_short parameter is set to "yes", then the automatically generated short name is generated from the position in the table rather than the team code. In the previous example, when no short_XXX parameter was given for a team whose name_XXX contained a template, a short column header was created containing the appropriate flag. However, when short_style is set to "noflag", then no flag is displayed in the automatically created header. If instead short_style is set to "nocountry", then no country code is displayed in the automatically created header as well as no flag. Column headers explicitly defined by short_XXX are not affected by use_pos_short or short_style. If the parameter crosstable_fractions is set to yes, then draws in the crosstable will be displayed as $1/2$ instead of using the unicode character ½. While the games in a match typically show the white background first, and the black background second, this behavior can be changed using the bgcol_XXX_YYY parameter. When no bgcol_XXX_YYY data is present, the background alternates between white and black for each successive game. If the colorbg parameter is set to no, then no cells in the crosstable will be colored black, even if there is bgcol_XXX_YYY data present. The solid_cell parameter determines the color of the cells of the crosstable's main diagonal. Currently, solid_cell may take on the values "gray", "grey", "lightgray", "lightgrey", or "silver", as well as "#xxx" or "#xxxxxx" where the x indicates a valid hexadecimal digit. If no value or an invalid value is given, then the entries on the main diagonal will display an Em dash in a cell with the table background color.

Customizing columns
Several columns can be customized in these tables.

Altering default columns
You may choose not to display some of the default columns. The column for the number of games played can be hidden with the hide_played parameter. Whether or not that column is hidden, score can be displayed as score / games played by using the score_over_played parameter. This parameter should be set to yes only when hide_played is set to yes, in order to avoid duplicated information. To hide the H2H and Wins columns, just set show_hth and show_win, respectively, to no. Similar behavior may be obtained by using the only_pld_pts parameter to only show the games played and score columns to the right of the player name. For more information on only_pld_pts, or on the postitle parameter used in this table, see. The leftmost column, which specifies the position of each player, may be hidden using the show_positions parameter. The player_header parameter may be used to give the player column a custom header, instead of the default value of Player seen in other examples on this page.

Wins, Draws, and Losses
For backwards compatibility with the WDL style, it is possible to choose whether to display the Wins, Draws, and Losses columns. We saw the show_win parameter in the previous example, but there are also show_draw and show_loss parameters, which similarly determine whether the Draws and Losses columns, respectively, will be shown. The default value of show_win is yes, while the default values of show_draw and show_loss are no. As seen in previous tables, the H2H column usually appears before the Wins column. If you wish the H2H column to show up immediately after whichever of the Wins, Draws, and Losses columns are present, you may set the hth_before_w parameter to no. If the parameter wdl_iff_hth is set to yes, then any wins, draws, or losses will only be displayed if head to head data has been defined for a given player.

Sonneborn–Berger score
In addition to other automatic calculations done by this module, there is also the possibility to calculate the Sonneborn–Berger score. The show_sb parameter shows a column containing the Sonneborn–Berger score of each player calculated from their match results. The Sonneborn–Berger score is calculated by taking the number of points gained against a given opponent multiplied by the total number of points that opponent scored, and then summing this product over all of the players. If the parameter sb_before_w is set to yes, then the column containing the Sonneborn–Berger score of each player appears immediately before the win column. If hth_before_w is also set to yes, the column containing the Sonneborn–Berger score of each player comes after the HTH column. If the parameter sb_before_w is set to the default value of no, then this column comes after both the H2H column as well as whichever of the Wins, Draws, and Losses columns are present. The values in this column are always given as decimals regardless of disp_fractions. If the parameter sb_iff_hth is set to yes, then a calculated Sonneborn–Berger score will only be displayed if head to head data has been defined for a given player. Additionally, you may set the nosb_XXX parameter to yes for any given player with team code XXX in order to prevent that particular player's Sonneborn–Berger score from being displayed.

Other additional columns
The data for this table comes from the 3rd Sinquefield Cup, which was a single round-robin event held in 2015. If the show_rating parameter is set to yes, then a column is shown immediately after the player names with values defined by rating_XXX for each team code XXX. Similarly, if the extra_cols parameter is set to some number N, then N columns are shown just before the crosstable, if one is present, with values defined by extraN_XXX for each column N and each team code XXX. The header of any extra column may be set using extra_headerN for each N. The header of the rating column also includes some information that may be chosen by a parameter. The contents of the rate_date parameter will be displayed in small text below the word "Rating" in the header. Note that it is possible to include the template inside any of these custom headers. Because all other notes in this module use the "lower-alpha" group, it is recommended that any use of in a parameter in this module also use the "lower-alpha" group. If any notes are generated by the module, then a template will also be generated at the end of the module. However, if no notes are generated by the module, then you will have to call this yourself as shown at the end of the example. There is no detriment to calling this twice, so it is a good idea to include this template yourself whenever you call in a parameter. For more information on notes in this module, see. For information on using matchrow_XXX instead of match_XXX_YYY see. For information on source, class_rules, and update used in this table, see.

Special case for only two players
When there are only two players, the module enters a special case. The data for the following table comes from the 2014 World Chess Championship. As can be seen from this example, the crosstable now displays a column header for each game in the match, instead of the normally displayed column header for each player. As such, there is no longer a main diagonal of NULL matches. Also, if short_XXX were defined, its value would never be used. Instead, headers in the match table are determined by the gameN_header parameter for each number N corresponding to a game. The default value for this parameter is the number specified by N. It is highly recommended to use bgcol_XXX_YYY in two player tables, so that each column can represent a distinct game, in the order that they are played. It is also recommended that the H2H, Wins, and played columns be hidden in a two player table, because this information is easily discerned from the points. For information on the source and update parameters used in this table, see.

Matchrow
There are occasions in which it may be preferable to enter all match data corresponding to one row using one parameter. Using the matchrow_XXX parameter, only one parameter is needed for the match data per row, rather than a number of parameters equal to the number of players per row. Note that matchrow_XXX data is comma separated, with each value between commas equal to the previously discussed match_XXX_YYY data, with the addition of data for the main diagonal. This value for the main diagonal is a dummy value which is never used and only exists to line matches up so that parameter inputs are easier to read. The dummy value is needed even for the two player special case, when no main diagonal is displayed in the crosstable. For this reason, it is advised that matchrow_XXX not be used in competitions with only 2 players. Additionally, if you use matchrow_XXX, then all match data needs to be changed each time you change the rank of any player. With match_XXX_YYY, no data needs to be changed when re-ordering players. For this reason, it is advised that matchrow_XXX only be used in already completed tournaments, where there is no possibility of changing the order of players. The parameter bgcolrow_XXX works similarly to matchrow_XXX in that the data is comma separated, except that each value between commas equal to the previously discussed bgcol_XXX_YYY data.

Tiebreak matches
In many tournaments, if there is a tiebreak between the top players, additional tiebreak games are played. This module is able to handle these tiebreak games. The data for the following table comes from the 2018 World Chess Championship. The data for the following table comes from the Tata Steel Chess India Blitz tournament in 2018.

If tb_numplayers is a number greater than 1, then a second crosstable will be displayed which may be used for tiebreak match data. The tb_numplayers parameter determines how many players are involved in the tiebreak matches. Note that tiebreak matches only apply to the players at the top of the table. For tiebreak match data, the parameters tbmatch_XXX_YYY, tbbgcol_XXX_YYY, tbmatchrow_XXX, and tbbgcolrow_XXX are used in place of match_XXX_YYY, bgcol_XXX_YYY, matchrow_XXX, and bgcolrow_XXX, respectively. The second crosstable is then displayed following the same rules as the first crosstable. Note that no information on wins or points is automatically calculated from tiebreak match data. For information on the source, class_rules, and update parameters used in these tables, see.

Generic Customization
There are many customization options that are available regardless of which style is used in Module:Sports table. These are presented below.

Note that match notes do not show up properly at this time when the number of games per match is not 1.