Created
March 16, 2020 09:57
-
-
Save zzzz465/fd7aad117c17c3c63bab5edbbadd5ada to your computer and use it in GitHub Desktop.
Updated Test code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Runtime.InteropServices; | |
using System.Linq; | |
using ColdClear; | |
namespace TetrisOverlay | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// in pre-release version max_node's value is uint64 type, however in C API, it was uint32 | |
var options = new CCOptions() { mode = CCMovementMode.CC_0G, use_hold = true, speculate = true, min_nodes = 0, max_nodes = 999999, threads = 1 }; | |
var weights = new CCWeights() { back_to_back = 52, bumpiness = -24, bumpiness_sq = -7, | |
height = -39, top_half = -150, top_quarter = -511, | |
jeopardy = -5, cavity_cells = -158, cavity_cells_sq = -7, | |
overhang_cells = -48, overhang_cells_sq = 1, covered_cells = -17, | |
covered_cells_sq = -1, tslot = new int[] { 8, 148, 192, 407 }, well_depth = 57, | |
max_well_depth = 17, well_column = new int[] { 20, 23, 20, | |
50, 59, 21, | |
59, 10, -10, | |
24 }, | |
b2b_clear = 104, clear1 = -143, clear2 = -100, clear3 = -58, clear4 = 390, | |
tspin1 = 121, tspin2 = 410, tspin3 = 602, mini_tspin1 = -158, | |
mini_tspin2 = -93, perfect_clear = 999, combo_garbage = 150, move_time = -3, | |
wasted_t = -152, use_bag = true }; | |
/* | |
IntPtr optionPtr = Marshal.AllocHGlobal(Marshal.SizeOf(options)); | |
IntPtr weightPtr = Marshal.AllocHGlobal(Marshal.SizeOf(weights)); | |
Marshal.StructureToPtr(options, optionPtr, true); | |
Marshal.StructureToPtr(weights, weightPtr, true); | |
*/ | |
// using marshaled IntPtr or passing struct with ref parameter doesn't make any difference. bot still dies immediately. | |
Console.WriteLine("launching cold clear"); | |
var ccBot = ColdClearAPI.cc_launch_async(ref options, ref weights); | |
//IntPtr cc_Pointer = ColdClearAPI.cc_launch_async(optionPtr, weightPtr); | |
Console.WriteLine("launching complete"); | |
var isDead = ColdClearAPI.cc_is_dead_async(ccBot); | |
//already died after launching, (no matter how much the time spents, immediately or delayed) | |
ColdClearAPI.cc_add_next_piece_async(ccBot, CCPiece.CC_I); | |
ColdClearAPI.cc_add_next_piece_async(ccBot, CCPiece.CC_J); | |
ColdClearAPI.cc_add_next_piece_async(ccBot, CCPiece.CC_L); | |
ColdClearAPI.cc_add_next_piece_async(ccBot, CCPiece.CC_O); | |
ColdClearAPI.cc_add_next_piece_async(ccBot, CCPiece.CC_S); | |
ColdClearAPI.cc_add_next_piece_async(ccBot, CCPiece.CC_T); | |
ColdClearAPI.cc_add_next_piece_async(ccBot, CCPiece.CC_Z); | |
ColdClearAPI.cc_request_next_move(ccBot, 0); | |
CCMove move = new CCMove(); | |
var result = ColdClearAPI.cc_poll_next_move(ccBot, ref move); | |
ColdClearAPI.cc_destroy_async(ccBot); | |
Console.WriteLine("End test"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment