private int NegaMax(int p) { int End = GameOver(); if (End != 0) return End; int best_value = (p == 1) ? 512 : 2048; for (int b = 1; b <= 256; b = b << 1) { int move = (~(X | O) & b); if (move != 0) { put(p * move); int s = NegaMax(-p); best_value = p * (s & 0xfffffe00) > p * (best_value & 0xfffffe00) ? ((s & 0xfffffe00) | move) : best_value; clear(move); } } return best_value; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)