Calling this dll from a C# program

#77 · closed · 1 comments

View on GitHub ↗

stevehkwong

Quick question (not sure if appropriate to ask) - I am trying to use this from a C# program (64bit) the output from getBestMove seems to always be -1 i have declared below - [DllImport("2048.dll", CallingConvention = CallingConvention.Cdecl)] private static extern int find_best_move(UInt64 board); I have also simulated your toCBoard function by converting a grid into a ulong public static ulong ToCBoard(Grid m) { ulong board = 0; int i = 0; ulong t = 0; for (int row = 0; row < 4; row++) { for (int col = 0; col < 4; col++) { t = (ulong) m.Cells[col, row]; board |= t << (4 * i); i++; } } return board; } Calling this by: ulong t = ToCBoard(gameBoard); bestMove = find_best_move(t); Any ideas?

Comments

nneonneo

Did you call `init_tables` first?