Differenze tra le versioni di "Utente:SDoc94/Sandbox4"

→‎Calcoli: Boooooh questa roba è talmente incasinata che anche spiegarla è macello
m
(→‎Calcoli: Boooooh questa roba è talmente incasinata che anche spiegarla è macello)
 
====Calcoli====
Una operazione {{wp en|Bitwise operation#Rotate through carry|rrcoperazione bit a bit di rotazione con resto}} (rrc, dall'ingelese ''rotate through carry'') viene eseguita sugli 8 bit che compongono i DV di {{stat|Attacco}} e {{stat|Difesa}} (<math>DV_{AD}</math> nella formula), sugli 8 bit che compongono i DV di {{stat|Velocità}} e {{stat|Speciali}} (<math>DV_{VS}</math> nella formula) e sui 16 bit che compongono l'ID Allenatore (<math>ID</math> nella formula). I risultati vengono poi combinati per formare un singolo numero a 16 bit secondo la seguente formula:
<!--
Una operazione {{wp en|Bitwise operation#Rotate through carry|rrc}} viene eseguita sugli 8 bit che compongono i DV di {{stat|Attacco}} e {{stat|Difesa}}, sugli 8 bit che compongono i DV di {{stat|Velocità}} e {{stat|Speciali}} e sui 16 bit che compongono l'ID Allenatore.
 
<math display="block">y = (256 \cdot \operatorname{rrc}(IV_1DV_{AD}) + \operatorname{rrc}(IV_2DV_{VS})) \oplus \operatorname{rrc}(ID)</math>
A {{wp|Bitwise operation#Rotate through carry|rotate through carry}} (rrc) operation is performed on the 8 bits comprising the Attack and Defense IVs, the 8 bits comprising the Speed and Special IVs, and the 16 bits comprising the Trainer ID. After this, the two 8-bit values are concatenated to form a single 16-bit number, which is then {{wp|Exclusive or|XOR}}'d with the Trainer ID, as follows.
 
Come caso particolare, se il valore di ''y'' così calcolato è minore 10, la lunghezza di Magikarp diventa <math display="inline">190 + y</math>. Altrimenti, quando ''y'' ≥ 10, il valore viene utilizzato per calcolare ''x<sub>0</sub>'', ''y<sub>0</sub>'' e ''m'' come indicato nella seguente tabella, che a loro volta vengono usati per calcolare le dimensioni del Pokémon.
<math display="block">y = (256 \cdot \operatorname{rrc}(IV_1) + \operatorname{rrc}(IV_2)) \oplus \operatorname{rrc}(ID)</math>
 
{| class="std-table" style="padding: 0.5ex; {{#invoke: css | horizGrad | type = johto}}"
As a special case, if ''y'' < 10, then the Magikarp's length is equal to <math display="inline">190 + y</math>. Otherwise, the value ''y'' is used to find the corresponding values of ''x<sub>0</sub>'', ''y<sub>0</sub>'', and ''m'' in the following table, which defines a {{wp|Piecewise linear function|piecewise linear}} approximation of the {{wp|Quantile function|inverse}} of a {{wp|Normal distribution|normal}} {{wp|cumulative distribution function}} with mean 800 and standard deviation 179. Due to an off-by-one error, the values of ''x<sub>0</sub>'' are calculated as 2 plus the zero-based index of the column (giving a mean of 800), rather than 3 plus the zero-based index of the column (giving a mean of 900). The column selected was intended to be the first column where ''y'' is less than the ''y<sub>0</sub>'' value of that same column. Due to a programming error, only the high bytes of ''y'' and ''y<sub>0</sub>'' are compared; this causes values to be looked up incorrectly from the table (including rendering the first and last columns inaccessible).
 
{| class="roundtable" style="text-align:center; background:#{{johto color}}; border:3px solid #{{johto color dark}}; margin:auto"
|-
! style="padding: 0 1ex;" | y (minore di):
! y (less than): || 0 || 256 || 512 || 2560 || 7680 || 17664 || 32512 || 47616 || 57600 || 62464 || 64512 || 65024 || 65280 || 65280
! style="padding: 0 1ex;" | 0
|-
! style="backgroundpadding:#{{johto color0 light}}1ex;" | x<sub>0</sub>256
! style="padding: 0 1ex;" | 512
! style="padding: 0 1ex;" | 2560
! style="padding: 0 1ex;" | 7680
! style="padding: 0 1ex;" | 17664
! style="padding: 0 1ex;" | 32512
! style="padding: 0 1ex;" | 47616
! style="padding: 0 1ex;" | 57600
! style="padding: 0 1ex;" | 62464
! style="padding: 0 1ex;" | 64512
! style="padding: 0 1ex;" | 65024
! style="padding: 0 1ex;" | 65280
! style="padding: 0 1ex;" | 65280
|-
! x<sub>0</sub>
| 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || 10 || 11 || 12 || 13 || 14 || 15
|-
! style="background:#{{johto color light}}" | y<sub>0</sub>
| 110 || 310 || 710 || 2710 || 7710 || 17710 || 32710 || 47710 || 57710 || 62710 || 64710 || 65210 || 65410 || 65510
|-
! m
! style="background:#{{johto color light}}" | m
| 1 || 2 || 4 || 20 || 50 || 100 || 150 || 150 || 100 || 50 || 20 || 5 || 2 || 1
|}
 
I valori in questa tabella definiscono una {{wp en|Piecewise linear function|approsimazione lineare a segmenti}} della funzione inversa della {{wp|funzione di ripartizione}} di una {{wp|distribuzione normale}} con media 800 e deviazione standard 179.
If one of the entries in the table matches, the final length of the Magikarp in millimeters is then calculated as follows. Due to a programming error, the function does not output <math display="inline">100 \cdot x_0 + \left\lfloor \frac{y - y_0}{m} \right\rfloor</math> as intended. The division routine expects the dividend to be an unsigned 16-bit value, but the subtraction always results in a negative value because ''y'' is always less than ''y<sub>0</sub>''. Additionally, only the low byte of the quotient is read, as the quotient was intended to only range from -1 to -100. These result in the sizes not correctly following a normal distribution as intended.
In teoria, questo dovrebbe produrre una distribuzione di probabilità normale sulle lunghezze di Magikarp. Tuttavia, il valore di ''x<sub>0</sub>'' viene calcolato come 2 più l'indice della colonna invece che 3 più l'indice della colonna, causando un errore off-by-one che cambia la media a 900.
Inoltre, la colonna selezionata sarebbe dovuta essere la prima in cui ''y'' è minore di ''y<sub>0</sub>'', ma a causa di un errore di programmazione vengono confrontati solo i byte più significativi delle due variabili, rendendo di fatto sbagliata la ricerca (questo, tra le altre cose, rende la prima e l'ultima colonna irraggiungibili).
 
Una volta calcolati ''x<sub>0</sub>'', ''y<sub>0</sub>'' e ''m'', la lunghezza di Magikarp in millimetri dovrebbe essere calcolata secondo la formula <math display="inline">100 \cdot x_0 + \left\lfloor (y - y_0) / m \right\rfloor</math>. Tuttavia, a causa di alcuni errori di programmazione, il calcolo non procede come previsto.
Per prima cosa, la procedura che calcola la divisione della formula assume che dividendo e divisore siano entrambi numeri a 16 bit senza segno (e quindi automaticamente positivi). In realtà però ''y'' è sempre minore di ''y<sub>0</sub>'', e che la differenza ''y - y<sub>0</sub>'' è negativa, rendendo la procedura scorretta.
Inoltre, viene letto solo il byte meno significativo del quoziente dato che chi l'ha programmato si aspettava dovesse variare solo nell'intervallo tra -1 e -100, mentre può assumere anche valori al di fuori di questo.
A causa di questi errori, la dimensione di Magikarp non segue la distribuzione normale intesa, ma calcola il valore secondo la formula:
 
<math display="block">\textit{SizeLunghezza} = 100 \cdot x_0 + \left( \left\lfloor \frac{65536 + y - y_0}{m} \right\rfloor \mathrm{mod}\ 256 \right)</math>
 
IfInoltre, nonea ofcausa thedell'errore entriesdi inricerca thenella tabletabella, matchnessuna (becausecolonna corrisponde ai valori di ''y'' ≥ 65280). In questo caso, thela Magikarp'slunghezza lengthdi isMagikarp insteadviene equalcalcolata tocome <math display="inline">1600 + (y - y_0)</math>, wheredove ''y<sub>0</sub>'' isè 65510, theovvero last entry for ''y<sub>0</sub>'l'ultimo invalore thenella tabletabella.
 
Nelle versioni in cui la lunghezza viene convertita in piedi e pollici, il risultato finale viene arrotondato per difetto al pollice più vicino.
If the game converts this number to feet and inches, the final result will be rounded down to the nearest inch.-->
 
===Terza e quarta generazione===