The T-spin AI bot (MisaMino ver 1.4.5 1111)

Started by misakamm, July 15, 2013, 05:42:05 AM

Previous topic - Next topic

misakamm

Hello everyone, I'm a fan of Tetris, and also a programmer.

Recently I'm making a bot which focuses on playing competitive Tetris games.
But I don't play quite well, it improves so fast and it's almost unbeatable for me now...

Here's the demo program where you can play against it.
full version (include bgm&sfx):
click here (Windows Platfrom) Updated At GMT 2013-11-11  14:30. host by kingofstackers

no bgm&sfx version:
click here
bgm&sfx pack: click here
screenshot:
[!--ImageUrlBegin--][!--ImageUrlEBegin--][img width=\\\"400\\\" class=\\\"attach\\\" src=\\\"http://i.imgur.com/AzV0vhL.png\\\" border=\\\'0\\\' alt=\\\"IPB Image\\\" /][!--ImageUrlEnd--][/a][!--ImageUrlEEnd--]


Update Log:
[a href=\\\"http://kingofstackers.com/misaka/misamino_V1.4.5_sfx.zip]2013-11-11
improved AI; pieces ratio setting in turnbase mode; fix some bugs
2013-10-06 improved AI, new AI style; garbage blocking setting; fix some bugs
2013-09-16 improved AI, new AI style; grid display
2013-09-10 include TOJ AI, more custom AI settings; improved the demo AI project; some other bugs fixed
2013-09-01 new name of this AI; some bugs of AI fixed and parameters adjusted; ai dll interface and sample dll project package; some other bugs fixed
2013-08-22 more sfx settings; TOP BGM support added
2013-08-21 TOP sound effects; more items in statistics; controls configuration key changed to F12; more das settings
2013-08-15 improved AI (max level8); 4-wide combo strategy switch; Tetris Friend combo table support; fix a crash problem (0815); Automatic leveling down (0815)
2013-07-31 improved AI; add 4-wide combo (level 7 AI only); attacks cancel; nobuffer; same sequence control
2013-07-24 improved AI; add level7; 180 rotate; normal game mode
2013-07-20 Add a softdrop option and improved AI
2013-07-17 Add a config file to set AI searching depth and garbage style
2013-07-15 First preview version

★Game rule:
Tetris guideline, with TOJ vs-rule, 1v1.
turn-based game by default, player first.

some exceptions:
no lock-out death, no falling speed, no slide move limit, only lock when hard drop key pushed.

★Default controls:
move left ------------- left arrow
move right ------------ right arrow
soft drop ------------- down arrow
hard drop ------------- space
rotate ccw ------------ Z
rotate 180 ------------ X
rotate cw ------------- C
hold ------------------ V

★Functional keys:
Press F12 to config your own controls (saved automatially). ESC cancel current settings.
Press F2 to restart the game (after finishing a game or before 10 pieces are locked).
Press F3 to toggle garbage buffer height display.
Press F4 to toggle grid display.
Press F5 and F6 to adjust SFX & BGM volume.

Default DAS is 8 frames under 60fps.

★Config:
In file "misamino.ini"
section "AI"
        "delay": AI think delay ( enable when turnbase=0 )
        "move" : AI move delay ( enable when turnbase=0 )
        "4w"   : Enable AI 4-wide combo strategy, but only enable when level>=6 and toj rule (combo table=1 or 2; tspin/tspin+/ren AI; garbage buffer, garbage blocking and garbage cancel on)

section "AI_P1" and "AI_P2"
        "style": The style of AI, P1 default is 0, P2 default is 2, style list:
0, human
1, T-spin+ AI
2, T-spin
3, Ren
4, non-Hold
5, Downstack
-1, Use the dll plugin specified below.

        "level": The level of AI is between 0 to 8. Default value is 4
        "PieceMul": In normal trunbase mode, setting the ratio of pieces (integer only)
        "dllplugin": AI dll plugin file path for player. set style=-1 to enable this plugin

section "Rule"
        "turnbase": Turn-based game, 0 to have real-time game using the delay values above.
        "KOS_turnbase": 7 pieces a turn
        "spin180" : allow 180 degree rotate if set to 1
        "GarbageStyle" : Garbage line style. 0 means TOJ style; 1 means messy style (hole change every 2 lines); 2 means more messy style (hole change every line)
        "GarbageCancel"  : Allow garbage cancelling. Default is 1.
        "GarbageBuffer": Attack applies immediately if set to 0, like in older games / hangame.
        "GarbageBlocking": Clearing lines prevents the garbage from rising.
        "samesequence": P1 and P2 will have different piece sequence if set to 0.
        "combo_table_style": 0 means the combo table is [0,0,1,1,2], 1 is TOJ combo table, 2 means Tetris Friend E+ combo table. default is 1

section "Player"
        "das": The das setting, 8 frames default.
        "softdropdas": softdrop das setting, 3 frames default.
        "softdropdelay": The softdrop delay, 10 is default, means 10 * 0.1 = 1 frame

Note:
when 4-wide combo strategy is enabled, it will NOT stop after receiving garbage until AI wants to attack.

plugins:
dllai.dll ---- baka(9)
jim_ai.dll ---- jim ai
tojai/tojai.dll ---- tojai


Have fun, and any feedback or suggestion is welcomed. My skype name is 'misakamm.com'


[/font]
Try to beat this program with your T-spin
[!--ImageUrlBegin--][a href=\\\"http://i.imgur.com/AzV0vhL.png\\\" target=\\\"_new\\\"][!--ImageUrlEBegin--][img width=\\\"400\\\" class=\\\"attach\\\" src=\\\"http://i.imgur.co

XaeL

#1
Not bad. I won the first two games, but then it beat me when i wasnt thinking too hard.

Could you make it make its move instantly?


Its annoying stopping between each piece.



QuoteLike many setups here, it is useful if your opponent doesn't move and you get 4 Ts in a row.

misakamm

Quote from: XaeL
Not bad. I won the first two games, but then it beat me when i wasnt thinking too hard.

Could you make it make its move instantly?
Its annoying stopping between each piece.

I adjusted some parameter a bit, and now the player is allowed to move freely, and it seems the new one plays a bit better?
Try to beat this program with your T-spin
[!--ImageUrlBegin--][a href=\\\"http://i.imgur.com/AzV0vhL.png\\\" target=\\\"_new\\\"][!--ImageUrlEBegin--][img width=\\\"400\\\" class=\\\"attach\\\" src=\\\"http://i.imgur.co

oofw

is it decision tree based or .. something else ?

Integration

#4
Oh a nice bot (and game) you have there. The bot would have beaten me, if I had tried to play faster.

Can you say some words about the bot? How many moves does it think ahead (previews)? Does it check to use hold several times in a row? Can it switch tactics, e.g. trying more to downstack when it is near the top? Does your playfield influence its decision? For example you send 4 lines and the bot can do a double, but spares to do as to accept clean garbage and send back messy garbage.

my suggestions:
1. Allow the player to tweak the ruleset. Games tend to be long for me (without combos). So I'd like to see an option to disable garbage blocking (delaying insertion of lines by clearing a line). You can beat the bot easily with a 4-wide. So I would add an option to weaken long combos, e.g. increasing your combo sends 3 lines at most.
2. Add additionally softdrop. Having sonic drop is nice, but sonic drop doesn't replace completely softdrop.

misakamm

Quote from: oofw
is it decision tree based or .. something else ?


Quote from: Integration
Oh a nice bot (and game) you have there. The bot would have beaten me, if I had tried to play faster.

Can you say some words about the bot? How many moves does it think ahead (previews)? Does it check to use hold several times in a row? Can it switch tactics, e.g. trying more to downstack when it is near the top? Does your playfield influence its decision? For example you send 4 lines and the bot can do a double, but spares to do as to accept clean garbage and send back messy garbage.


it behaves like AIs for chess games, the actual depth of searching depends on the number of states evaluated, 4 next pieces are used in most cases. the strategy smoothly changes for different height. currently it doesn't see the opponent's playfield
Try to beat this program with your T-spin
[!--ImageUrlBegin--][a href=\\\"http://i.imgur.com/AzV0vhL.png\\\" target=\\\"_new\\\"][!--ImageUrlEBegin--][img width=\\\"400\\\" class=\\\"attach\\\" src=\\\"http://i.imgur.co

caffeine

Quote from: misakamm
the strategy smoothly changes for different height. currently it doesn't see the opponent's playfield
Interesting. Does it do something like optimize for adds/tetromino the lower it is and then garbage cleared/tetromino the higher it is? I was actually thinking of an AI strategy similar to that: always take the route that maximizes (adds + garbage cleared)/tetromino.

misakamm

Quote from: caffeine
Interesting. Does it do something like optimize for adds/tetromino the lower it is and then garbage cleared/tetromino the higher it is? I was actually thinking of an AI strategy similar to that: always take the route that maximizes (adds + garbage cleared)/tetromino.
current way of evaluating a situation is not simply based on the number of attack lines sent and garbage lines digged, or it'll be hard to make various types of t-spins. in fact it evaluates a move by its attack efficiency and the shape of the field, and many other parameters.
the weakest point of it is unable to stack for 4w, i've been trying quite a few ways but no one looks successful.
Try to beat this program with your T-spin
[!--ImageUrlBegin--][a href=\\\"http://i.imgur.com/AzV0vhL.png\\\" target=\\\"_new\\\"][!--ImageUrlEBegin--][img width=\\\"400\\\" class=\\\"attach\\\" src=\\\"http://i.imgur.co

insatiate

#8
Nice work. Question: can [the bot] use twists other than T?

misakamm

#9
Quote from: insatiate
Nice work. Question: can [the bot] use twists other than T?
it can use and sometimes make (if necessary) all types of spin slots
Try to beat this program with your T-spin
[!--ImageUrlBegin--][a href=\\\"http://i.imgur.com/AzV0vhL.png\\\" target=\\\"_new\\\"][!--ImageUrlEBegin--][img width=\\\"400\\\" class=\\\"attach\\\" src=\\\"http://i.imgur.co

Kitaru

Would you consider making the source code available or documenting the bot's strategy? I believe it would be a valuable contribution to the general knowledge of Tetris AI.
<a href=http://backloggery.com/kitaru><img src="http://backloggery.com/kitaru/sig.gif" border='0' alt="My Backloggery" /></a>

oofw

surprisingly strong... somewhere around the 10th straight loss i had a vision of a future where humans have been m ade redundant... i trembled in fear...

also the tetris game is very well made (in my opinion)

insatiate


Integration

#13
I had a few more games. Your bot is really clever. But I don't like that garbage is so clean in TOJ style. When I play, games are nearly endless, and I am not sure if disabling garbage blocking would even change that. Can you make options to make the garbage more messy? For example 100 % change of attack (current attack uses a different garbage hole than your last successful attack). Or changing garbage hole within an attack, e.g. after every 2 lines (that means a Tetris would send garbage like 2 Triples; a B2B Tetris would send garbage like 2 Triples and a Double).

You said your bot tries to have a search depth of 4. Can you also make a version with a maximum search depth of 3? This means the game would work better on slower PCs and the bot would be a better match for beginners.

oofw


i think allowing the user to set a speed for the bot would also be nice , if you plan on developing this game further