How to modify TOJ AIs

Miscellaneous Tetris discussion

How to modify TOJ AIs

Postby Spirale » Fri Jul 15, 2011 11:16 am

Did you nkow you can modify TOJ AIs ?
You can use SJEHHTool to decode the sje.hh file in the ai folder.
You will obtain Lua scripts.

Lua scripting language is very easy to understand. I think how the AIs work is that

1) when the game starts the Start function of the Lua script is called.
2) After every new dropped piece, the function PrepareThink of the Lua script is called.
3) TOJ then tries every possible move to a "virtual fields" and evaluate each field by calling the EvalField function of the Lua script passing as parameter the depth in the search tree of the best move (it seems the depth is set to 0 on every script)
4) when the game ends the End function is called.

By neutralizing the EvalField function I found out that :
- test_tetris.lua is the AI used when playing vs a bot in multiplayer.
- test_dropchecker.lua is used when using the anti missdrop item. (it probably compares the result of the EvalField function upon executing the move the user ordered, with some threshold and prevents the move is under this threshold.

The other scripts are probably for the training mode with each script corresponding to different levels.

There doesn't seem to be any instruction limiting the speed so I think the fact that test_tetris.lua is so slow may be due to performance issue? Unless the speed is controlled outside of LUA script.
Spirale
 
Posts: 14
Joined: Tue Jul 12, 2011 9:17 am

Re: How to modify TOJ AIs

Postby Wojtek » Fri Jul 15, 2011 12:35 pm

i have not played with ai yet, so thanks for the info. i t hink speed is controlled in file initbotailist.txt or initailist.txt (i don't know which one is actually used). both are in config\jpn folder.
User avatar
Wojtek
Site Admin
 
Posts: 233
Joined: Sat Jun 18, 2011 4:09 am

Re: How to modify TOJ AIs

Postby Spirale » Mon Jul 18, 2011 4:09 pm

initailist.txt is used in training mode for initializing the delays for each level. I tried putting the delays to zero for level 1 and the bot went crazy fast.
I dont know for what initbotailist.txt is used but im guessing it's just an older version of initailist.txt that they forgot to remove.
I couldn't find a file where the delays for the ffa bot are stored.
also the Lua script used for ffa bot must be a parameter somewhere, but I tried modifying some values in config.jpn and it wasnt conclusive so I don't know. Maybe it is hardcoded in tetris.exe.
Spirale
 
Posts: 14
Joined: Tue Jul 12, 2011 9:17 am

Re: How to modify TOJ AIs

Postby Wojtek » Mon Jul 18, 2011 7:59 pm

actually orgianal TOJ server adjust ffa bot to player level (i think it's based on avarage apm or something similiar), on TOP bot level is always 15 for now. anyway I would excpect ffa bot paramenters are be controlled by one of those files. could it be initbotailist.txt?
User avatar
Wojtek
Site Admin
 
Posts: 233
Joined: Sat Jun 18, 2011 4:09 am


Return to Tetris

Who is online

Users browsing this forum: No registered users and 3 guests

cron