Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
Change-Id: Ifcbff5b7554aba0cd2b921d07f9b157ac85c7e3a
  • Loading branch information
calcitem committed Dec 31, 2023
1 parent 72dc672 commit 3da72c5
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 29 deletions.
5 changes: 1 addition & 4 deletions src/movegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ struct MoveList
return std::find(begin(), end(), move) != end();
}

ExtMove getMove(int index)
{
return moveList[index];
}
ExtMove getMove(int index) { return moveList[index]; }

static void create();
static void shuffle();
Expand Down
9 changes: 5 additions & 4 deletions src/perfect/perfect_adaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ int to_perfect_sq(Square sq)
{
constexpr int map[] = {
-1, -1, -1, -1, -1, -1, -1, -1,
18, 19, 20, 21, 22, 23, 16, 17, /* 8 - 15 */
10, 11, 12, 13, 14, 15, 8, 9, /* 16 - 23 */
2, 3, 4, 5, 6, 7, 0, 1, /* 24 - 31 */
18, 19, 20, 21, 22, 23, 16, 17, /* 8 - 15 */
10, 11, 12, 13, 14, 15, 8, 9, /* 16 - 23 */
2, 3, 4, 5, 6, 7, 0, 1, /* 24 - 31 */
-1, -1, -1, -1, -1, -1, -1, -1,
};

Expand Down Expand Up @@ -303,7 +303,8 @@ Value perfect_search(const Position *pos, Move &move)
try {
int moveBitboard = GetBestMove(whiteBitboard, blackBitboard,
whiteStonesToPlace, blackStonesToPlace,
playerToMove, onlyStoneTaking, value, move);
playerToMove, onlyStoneTaking, value,
move);
moves = convertBitboardMove(whiteBitboard, blackBitboard, playerToMove,
moveBitboard);

Expand Down
4 changes: 2 additions & 2 deletions src/perfect/perfect_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class MalomSolutionAccess
public:
static int getBestMove(int whiteBitboard, int blackBitboard,
int whiteStonesToPlace, int blackStonesToPlace,
int playerToMove, bool onlyStoneTaking,
Value &value, const Move &refMove);
int playerToMove, bool onlyStoneTaking, Value &value,
const Move &refMove);

static int getBestMoveNoException(int whiteBitboard, int blackBitboard,
int whiteStonesToPlace,
Expand Down
11 changes: 6 additions & 5 deletions src/perfect/perfect_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ class PerfectPlayer : public Player
auto m = refMove;
const Square from = from_sq(m);
const Square to = to_sq(m);
auto it = l.end();

auto it = l.end();

if (refMove == MOVE_NONE) {
goto out;
Expand All @@ -206,7 +206,7 @@ class PerfectPlayer : public Player
advMoveRef.to = to_perfect_sq(to);
}

it = std::find_if(l.begin(), l.end(),
it = std::find_if(l.begin(), l.end(),
[&advMoveRef, m](const auto &elem) {
if (m < 0) {
return advMoveRef.takeHon == elem.takeHon;
Expand All @@ -225,9 +225,10 @@ class PerfectPlayer : public Player
return *it;
}

out:
out:
if (gameOptions.getShufflingEnabled()) {
std::uniform_int_distribution<> dis(0, static_cast<int>(l.size() - 1));
std::uniform_int_distribution<> dis(0,
static_cast<int>(l.size() - 1));
return l[dis(gen)];
}

Expand Down
8 changes: 4 additions & 4 deletions src/perfect/perfect_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ int perfect_test(int argc, char *argv[])
}

// int res = MalomSolutionAccess::getBestMove(0, 0, 9, 9, 0, false, move);
int res = MalomSolutionAccess::getBestMove(1, 2, 8, 8, 0, false,
value, move); // Correct
// output:
// 16384
int res = MalomSolutionAccess::getBestMove(1, 2, 8, 8, 0, false, value,
move); // Correct
// output:
// 16384
// int res = MalomSolutionAccess::getBestMove(1 + 2 + 4, 8 + 16 + 32, 100,
// 0, 0, false, value, move); // tests exception
// int res = MalomSolutionAccess::getBestMove(1 + 2 + 4, 1 + 8 + 16 + 32,
Expand Down
3 changes: 1 addition & 2 deletions src/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ void Thread::emitCommand()
bestvalue = -bestvalue;
}

switch (aiMoveType)
{
switch (aiMoveType) {
case AiMoveType::traditional:
aiMoveTypeStr = "";
break;
Expand Down
11 changes: 7 additions & 4 deletions src/ui/flutter_app/lib/game_page/services/engine/engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ class Engine {
logger.v("$_logTag response: $response");

if (response.contains("bestmove")) {
final RegExp regex = RegExp(r"info score (-?\d+)(?: aimovetype (\w+))? bestmove (.*)");
final RegExp regex =
RegExp(r"info score (-?\d+)(?: aimovetype (\w+))? bestmove (.*)");
final Match? match = regex.firstMatch(response);
String value = "";
String aiMoveTypeStr = "";
Expand Down Expand Up @@ -359,7 +360,7 @@ enum GameMode {
testViaLAN,
}

Map<AiMoveType, IconData> aiMoveTypeIcons = {
Map<AiMoveType, IconData> aiMoveTypeIcons = <AiMoveType, IconData>{
AiMoveType.traditional: FluentIcons.bot_24_filled,
AiMoveType.perfect: FluentIcons.database_24_filled,
AiMoveType.consensus: FluentIcons.bot_add_24_filled,
Expand All @@ -368,7 +369,8 @@ Map<AiMoveType, IconData> aiMoveTypeIcons = {

extension GameModeExtension on GameMode {
IconData get leftHeaderIcon {
final IconData botIcon = aiMoveTypeIcons[GameController().aiMoveType] ?? FluentIcons.bot_24_filled;
final IconData botIcon = aiMoveTypeIcons[GameController().aiMoveType] ??
FluentIcons.bot_24_filled;

switch (this) {
case GameMode.humanVsAi:
Expand Down Expand Up @@ -397,7 +399,8 @@ extension GameModeExtension on GameMode {
}

IconData get rightHeaderIcon {
final IconData botIcon = aiMoveTypeIcons[GameController().aiMoveType] ?? FluentIcons.bot_24_filled;
final IconData botIcon = aiMoveTypeIcons[GameController().aiMoveType] ??
FluentIcons.bot_24_filled;

switch (this) {
case GameMode.humanVsAi:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ class GeneralSettingsPage extends StatelessWidget {
break;
// TODO: Add whatIsRandom
case SearchAlgorithm.random:
rootScaffoldMessengerKey.currentState!
.showSnackBarClear("Random");
rootScaffoldMessengerKey.currentState!.showSnackBarClear("Random");
break;
case null:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ class RuleSettingsPage extends StatelessWidget {

logger.v("[config] piecesCount = $piecesCount");

if (DB().generalSettings.usePerfectDatabase &&
piecesCount != 9) {
if (DB().generalSettings.usePerfectDatabase && piecesCount != 9) {
rootScaffoldMessengerKey.currentState!
.showSnackBarClear(S.of(context).reopenToTakeEffect);
}
Expand Down

0 comments on commit 3da72c5

Please sign in to comment.