This is a love2d/lua wrapper for cold clear, in order use it in tetris games made by love2d game engine.
In the code of cold clear, the pieces are represented as integer thus:
typedef enum CCPiece {
CC_I, CC_O, CC_T, CC_L, CC_J, CC_S, CC_Z
} CCPiece;
However, for technical reasons (pun intended!), the wrapper uses a reversed order,
i.e. Z S J L T O I
.
The whole API segfaults on any type errors. To see sensible error messages and stack traces, uncomment the #define DEBUG_CC
macro in cold_clear_wrapper.c
.
git clone https://github.com/26F-Studio/cold_clear_ai_love2d_wrapper --recursive
mingw32-make
sudo apt install gcc make cargo rustc love
make CCloader.so
chmod +x MacReleaseIOS.sh
MacReleaseIOS.sh
ndk-build NDK_PROJECT_PATH=. NDK_APPLICATION_MK=Application.mk APP_BUILD_SCRIPT=Android.mk LOVE2D_LIB=path/to/love2d/lib
Note: To use it on android, you need to put libcold_clear.so in /lib
and copy libccloader.so
to save directory.
-- Hint, but not the only way to load it
package.cpath="/data/data/org.love2d.android.embed/files/save/archive/lib?.so;"..package.cpath
love.filesystem.write("libCCloader.so", love.filesystem.read("libCCloader.so"))
require "CCloader"
See cc.lua
Some important information from coldclear.h
typedef enum CCBotPollStatus {
CC_MOVE_PROVIDED,
CC_WAITING,
CC_BOT_DEAD
} CCBotPollStatus;
typedef enum CCMovement {
CC_LEFT, CC_RIGHT,
CC_CW, CC_CCW,
/* Soft drop all the way down */
CC_DROP
} CCMovement;