PDA

View Full Version : PSP Tetris Engine


Ferrero
08-22-2007, 01:47 PM
Hello everybody,


I'm writing a Tetris Engine for the PSP and TetrisConcept is really a good knowledge base.


For the fisrt mode of this Engine, I'm trying to replicate the TGM1, but there is something I'don't understand about the scoring.


In the wiki I've found this about TGM1 :


TGM shares the same scoring gimmicks of many other Tetris games, though they are not quite implemented the same way:

* You receive more points for clearing more lines at once.
* Lines are worth more with each passing level. (The nature of "level" in TGM, however, means the amount of points a line is worth is constantly changing.)
* You receive points for forcing a piece down. (Though only when this results in cleared lines!)

There are a few scoring gimmicks unique to TGM:

* You receive a combo bonus for clearing lines with consecutive pieces.
* You receive a bravo bonus for clearing the entire screen.

Incidentally, for all players good enough to attain the rank of S9 score becomes irrelevant and the focus changes to a time attack rather than a score attack. Nevertheless, here is a more technical description of the scoring formula:

Score = ((Level + Lines)/4 + Drop) x Lines x Combo x Bravo

Where:

* Level is the current level you are on.
* Lines is the number of lines you just cleared.
* (Level + Lines)/4 is rounded up.
* Drop is the number of spaces you manually dropped the piece. The last space your piece falls does not contribute to this, however locking the piece once it has landed will add 1 to the Drop.
* Combo returns to 1 by default every time a piece does not clear lines. Otherwise, it is :

Combo = Combo - 1 + (2 x Lines - 1)

* Bravo is equal to 4 if this piece has cleared the screen, and otherwise is 1.

So by this formula you only score point when at least a line is cleared, am I correct ?
And the second point I don't understand is about Combo : Combo = Combo - 1 + (2 x Lines - 1)

What the initial value of combo in this formula ?
The wiki says "You receive a combo bonus for clearing lines with consecutive pieces." but I can't see that in this formula.

Another thing that touble me, is the leveling.

On the wiki I see this : does not increase uniformly, unlike many other tetris games. It rises and falls, depending on the level, as follows:
Level Speed
0 to 199 -> 1/64G to 1/1.8G
200 to 299 -> 1/64G to 1G
300 to 399 -> 2G to 4G
400 to 499 -> 5G to 3G
500 to 999 -> 20G[/quote]


So between 0 and 199 I've made this formula to compute the gravity :


Gravity : (138/199) * Level + 4, I store the gravity like in TGM 2 (It's 256/Gravity frames per rows).

This function is linear, is it correct to do a linear interpolation ?


Thanks for your great Job

Rosti LFC
08-22-2007, 02:28 PM
What the initial value of combo in this formula ?


From wiki:
* Combo returns to 1 by default every time a piece does not clear lines.

So the initial value is 1.

The wiki says "You receive a combo bonus for clearing lines with consecutive pieces." but I can't see that in this formula.



Say you clear 2 lines.

The combo is 1 - 1 + (2 x 2 - 1) = 3 (Or 2 if you don't follow mathematics convention. I'm not sure which)


That means if you clear lines with the consecutive piece, the score for those cleared lines will be multiplied by 3 (or 2). It'll also increase the combo further.

Ferrero
08-22-2007, 02:32 PM
Thanks a lot, I've understand the combo now.


But about the leveling, is it correct to do a linear interpolation between each limit (0->199, 200->299, ...) ?

colour_thief
08-22-2007, 02:33 PM
Yes you only score points with lines. As for how combos work, you need to re-read this particular line:


"Combo returns to 1 by default every time a piece does not clear lines."


So if you score a double, then use the combo formula:


Combo = Combo - 1 + (2 x Lines - 1)

Combo = 1 - 1 + (2 x 2 - 1)

Combo = 3


And for the next piece, the combo value is 3 instead of 1.



As for your question about gravity, linear interpolation would be incorrect. This is how it works in TAP, I think it's the same in TGM1:


G-Speed for Level 000: 1/64.0 (dw: 0x400)
...
G-Speed for Level 029: 1/64.0 (dw: 0x400)
G-Speed for Level 030: 1/42.7 (dw: 0x600)
...
G-Speed for Level 034: 1/42.7 (dw: 0x600)
G-Speed for Level 035: 1/32.0 (dw: 0x800)
...
G-Speed for Level 039: 1/32.0 (dw: 0x800)
G-Speed for Level 040: 1/25.6 (dw: 0xA00)
...
G-Speed for Level 049: 1/25.6 (dw: 0xA00)
G-Speed for Level 050: 1/21.3 (dw: 0xC00)
...
G-Speed for Level 059: 1/21.3 (dw: 0xC00)
G-Speed for Level 060: 1/16.0 (dw: 0x1000)
...
G-Speed for Level 069: 1/16.0 (dw: 0x1000)
G-Speed for Level 070: 1/8.0 (dw: 0x2000)
...
G-Speed for Level 079: 1/8.0 (dw: 0x2000)
G-Speed for Level 080: 1/5.3 (dw: 0x3000)
...
G-Speed for Level 089: 1/5.3 (dw: 0x3000)
G-Speed for Level 090: 1/4.0 (dw: 0x4000)
...
G-Speed for Level 099: 1/4.0 (dw: 0x4000)
G-Speed for Level 100: 1/3.2 (dw: 0x5000)
...
G-Speed for Level 119: 1/3.2 (dw: 0x5000)
G-Speed for Level 120: 1/2.7 (dw: 0x6000)
...
G-Speed for Level 139: 1/2.7 (dw: 0x6000)
G-Speed for Level 140: 1/2.3 (dw: 0x7000)
...
G-Speed for Level 159: 1/2.3 (dw: 0x7000)
G-Speed for Level 160: 1/2.0 (dw: 0x8000)
...
G-Speed for Level 169: 1/2.0 (dw: 0x8000)
G-Speed for Level 170: 1/1.8 (dw: 0x9000)
...
G-Speed for Level 199: 1/1.8 (dw: 0x9000)
G-Speed for Level 200: 1/64.0 (dw: 0x400)
...
G-Speed for Level 219: 1/64.0 (dw: 0x400)
G-Speed for Level 220: 1/8.0 (dw: 0x2000)
...
G-Speed for Level 229: 1/8.0 (dw: 0x2000)
G-Speed for Level 230: 1/4.0 (dw: 0x4000)
...
G-Speed for Level 232: 1/4.0 (dw: 0x4000)
G-Speed for Level 233: 1/2.7 (dw: 0x6000)
...
G-Speed for Level 235: 1/2.7 (dw: 0x6000)
G-Speed for Level 236: 1/2.0 (dw: 0x8000)
...
G-Speed for Level 238: 1/2.0 (dw: 0x8000)
G-Speed for Level 239: 1/1.6 (dw: 0xA000)
...
G-Speed for Level 242: 1/1.6 (dw: 0xA000)
G-Speed for Level 243: 1/1.3 (dw: 0xC000)
...
G-Speed for Level 246: 1/1.3 (dw: 0xC000)
G-Speed for Level 247: 1/1.1 (dw: 0xE000)
...
G-Speed for Level 250: 1/1.1 (dw: 0xE000)
G-Speed for Level 251: 1.0 (dw: 0x10000)
...
G-Speed for Level 299: 1.0 (dw: 0x10000)
G-Speed for Level 300: 2.0 (dw: 0x20000)
...
G-Speed for Level 329: 2.0 (dw: 0x20000)
G-Speed for Level 330: 3.0 (dw: 0x30000)
...
G-Speed for Level 359: 3.0 (dw: 0x30000)
G-Speed for Level 360: 4.0 (dw: 0x40000)
...
G-Speed for Level 399: 4.0 (dw: 0x40000)
G-Speed for Level 400: 5.0 (dw: 0x50000)
...
G-Speed for Level 419: 5.0 (dw: 0x50000)
G-Speed for Level 420: 4.0 (dw: 0x40000)
...
G-Speed for Level 449: 4.0 (dw: 0x40000)
G-Speed for Level 450: 3.0 (dw: 0x30000)
...
G-Speed for Level 499: 3.0 (dw: 0x30000)


There's a reason it's not completely written out in the wiki. Blech.


EDIT: lol Rosti did the exact same example

Ferrero
08-22-2007, 06:11 PM
Thanks a lot color_thief (your gravity table is not the same as the one on the Wiki page for TAP), but I've applied the gravity table you said.


I've another question,

During the a Line Clear, can the player move the Next Piece like in A.R.E (so in the case, the A.R.E time is expended by 40 frames) or is it just a "wait time"


PS : I've taken the Line Clear Delay of TAP for TGM1 Game Mode

tepples
08-22-2007, 07:27 PM
The player cannot move the tetromino during ARE. (Lumines has a separate "fall delay" phase between ARE and gravity phases in which the player can move and freely rotate the tetromino, which TGM does not.) But the player can charge DAS during ARE and line clear, and holding down a rotation or hold button will apply the rotation or hold (but not DAS) on the tetromino's first active frame.

colour_thief
08-22-2007, 09:35 PM
I think that's all he means, tepples. And yes, line clears essentially increase ARE time. So IRS will work as well.

tepples
08-22-2007, 11:19 PM
In the formula ((Level + Lines)/4 + Drop) x Lines x Combo x Bravo, does Level refer to the level displayed while the piece was falling, 1 more, Lines more, or Lines + 1 more?

colour_thief
08-22-2007, 11:38 PM
Displayed level...

K
08-23-2007, 03:05 PM
http://www.tetrisconcept.net/forum/images/smilies/icon_lol.gif