Page 1 of 1

How to modify TOJ AIs

PostPosted: Fri Jul 15, 2011 11:16 am
by Spirale
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.

Re: How to modify TOJ AIs

PostPosted: Fri Jul 15, 2011 12:35 pm
by Wojtek
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.

Re: How to modify TOJ AIs

PostPosted: Mon Jul 18, 2011 4:09 pm
by Spirale
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.

Re: How to modify TOJ AIs

PostPosted: Mon Jul 18, 2011 7:59 pm
by Wojtek
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?