Skip to content

Commit

Permalink
'Quarto!' ver 0.10
Browse files Browse the repository at this point in the history
👍 Final tuning
👍 Print multiplication sign
💚 Tune log output
  • Loading branch information
obono committed Oct 4, 2019
1 parent 10f029d commit 7946925
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 16 deletions.
Binary file added docs/img/quarto1.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img/quarto2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion quarto/MyArduboy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ PROGMEM static const uint32_t imgFont[] = {
0x0018E300, 0x1F24929C, 0x0D5D555F, 0x1145149C, 0x0725145F, 0x1155555F, 0x0114515F, 0x1D55545E,
0x1F10411F, 0x0045F440, 0x07210410, 0x1D18411F, 0x1041041F, 0x1F04F05E, 0x1F04109C, 0x0F45545E,
0x0314925F, 0x1F45D45E, 0x1B34925F, 0x0D555556, 0x0105F041, 0x0721041F, 0x0108421F, 0x0F41E41F,
0x1D184317, 0x0109C107, 0x114D5651, 0x0045F000, 0x0001F000, 0x0001F440, 0x000C1080, 0x10410410,
0x1D184317, 0x0109C107, 0x114D5651, 0x0045F000, 0x0001F000, 0x0001F440, 0x00284280, 0x10410410,
// 0x000C1080
};

#ifdef USE_ARDUBOY2_LIB
Expand Down
2 changes: 1 addition & 1 deletion quarto/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define FPS 60
#define APP_TITLE "QUARTO!"
#define APP_CODE "OBN-Y08"
#define APP_VERSION "0.03"
#define APP_VERSION "0.10"
#define APP_RELEASED "OCTOBER 2019"

enum MODE_T {
Expand Down
2 changes: 1 addition & 1 deletion quarto/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ PROGMEM static const uint8_t imgPlayer[2][22] = { // 11x11 x2
#define IMG_HINT_WIN_W 5
#define IMG_HINT_WIN_H 5

PROGMEM static const uint8_t imgHintWin[5] = { 0x11, 0x0A, 0x04, 0x0A, 0x11 }; // 5x5
PROGMEM static const uint8_t imgHintWin[5] = { 0x04, 0x0A, 0x11, 0x0A, 0x04 }; // 5x5

/*---------------------------------------------------------------------------*/
/* Sound Data */
Expand Down
24 changes: 19 additions & 5 deletions quarto/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ static void newGame(void)
game.restPieces = ~(1 << cursorPiece);
isCancelable = false;
hintWinMoves = 0;
dprint(F("New game: piece = "));
dprint(F("New game: piece="));
dprintln(cursorPiece);

/* Start animation */
Expand Down Expand Up @@ -424,7 +424,7 @@ static void choosePiece(void)
game.currentPiece = cursorPiece;
game.restPieces &= ~(1 << cursorPiece);
countWinMoves(&game, false, true);
dprint(F("Next piece = "));
dprint(F("Next piece="));
dprintln(cursorPiece);

/* Start animation */
Expand Down Expand Up @@ -779,17 +779,31 @@ static void drawCursor(int16_t x, int16_t y)
static bool cpuThinking(void)
{
GAME_T work = game;
int8_t depth = min(record.cpuLevel, game.turn / 2 + 1);
int8_t depth = record.cpuLevel;
unsigned long startCpuTime = millis();
if (game.turn < 2) {
depth = 1;
} else if (game.turn < 5) {
depth = min(depth, 2);
} else {
depth = min(depth, game.turn - 2);
}
dprintln(F("CPU thinking..."));
dprint(F(" Depth="));
dprintln(depth);
nextCpuInterval = millis() + CPU_INTERVAL_MILLIS;
isCpuInterrupted = false;
isLastAPressed = arduboy.pressed(A_BUTTON);
int eval = -alphabeta(&work, depth, -EVAL_INF, EVAL_INF);
arduboy.setRGBled(0, 0, 0);
if (isCpuInterrupted) {
dprintln(F("CPU was interrupted"));
dprintln(F(" Interrupted!"));
return false;
} else {
dprint(F("CPU's evaluation="));
dprint(F(" Time="));
dprint((millis() - startCpuTime) / 1000);
dprintln(F("secs"));
dprint(F(" Evaluation="));
dprintln(eval);
return true;
}
Expand Down
6 changes: 6 additions & 0 deletions quarto/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"title" : "Quarto!",
"description" : "A board game played on a 4x4 board with 16 unique pieces.",
"genre": "Board game",
"url": "https://community.arduboy.com/t/quarto-an-abstract-strategy-board-game/8226"
}
16 changes: 8 additions & 8 deletions quarto/title.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ PROGMEM static const uint8_t imgLargePiece[2][52] = { // 13x32 x2
};

PROGMEM static const char instText1[] = \
"\"QUARTO!\" IS MADE OF\0A 4X4 SQUARE BOARD\0AND OF 16 DIFFERENT\0" \
"\"QUARTO!\" IS MADE OF\0A 4^4 SQUARE BOARD\0AND OF 16 DIFFERENT\0" \
"PIECES, EACH OF WHICH\0HAS 4 ATTRIBUTES.\0\e";

PROGMEM static const char instText2[] = \
Expand All @@ -95,7 +95,7 @@ PROGMEM static const char instText3[] = \

PROGMEM static const char instText4[] = \
"A VARIANT RULE:\0A PLAYER ALSO CAN WIN\0BY PLACING 4 MATCHING\0" \
"PIECES IN 2X2 SQUARE.\0\0THIS IS CONFIGURABLE.\0CURRENT SETTING: \0\e";
"PIECES IN 2^2 SQUARE.\0\0THIS IS CONFIGURABLE.\0CURRENT SETTING: \0\e";

PROGMEM static const char * const instList[] = { instText1, instText2, instText3, instText4 };

Expand All @@ -105,7 +105,7 @@ PROGMEM static const char instAttrLabels[] = \
PROGMEM static const char creditText[] = \
"- " APP_TITLE " -\0\0\0" APP_RELEASED "\0PROGREMMED BY OBONO\0\0" \
"THIS PROGRAM IS\0RELEASED UNDER\0THE MIT LICENSE.\0\0\0" \
"ORIGINAL CONCEPT BY\0BLAISE MULLER, FRANCE\0\e";
"ORIGINAL CONCEPT BY\0BLAISE MULLER, SWISS\0\e";

static STATE_T state = STATE_INIT;
static uint8_t counter, instPage, instAttr, instPieces[BOARD_SIZE];
Expand Down Expand Up @@ -248,7 +248,7 @@ static void onSettings(void)
{
playSoundClick();
clearMenuItems();
addMenuItem(F("APPROVE 2X2"), onSettingChange);
addMenuItem(F("APPROVE 2^2"), onSettingChange);
addMenuItem(F("THINKING LED"), onSettingChange);
addMenuItem(F("INVERT SCREEN"), onSettingChange);
addMenuItem(F("HINT (VS CPU)"), onSettingChange);
Expand Down Expand Up @@ -302,7 +302,7 @@ static void handleInst(void)
playSoundTick();
instPage += vp;
isInvalid = true;
dprint(F("instPage = "));
dprint(F("instPage="));
dprintln(instPage);
} else if (arduboy.buttonDown(A_BUTTON)
|| arduboy.buttonDown(B_BUTTON) && instPage == INST_PAGE_MAX - 1) {
Expand Down Expand Up @@ -364,12 +364,12 @@ static void handleAnyButton(void)

static void drawTitleImage(void)
{
#ifdef DEBUG
arduboy.printEx(0, 0, F("DEBUG"));
#endif
arduboy.drawBitmap(0, 2, imgTitle, 128, 24, WHITE);
arduboy.drawBitmap(4, 24, imgLargePiece[0], 13, 32, WHITE);
arduboy.drawBitmap(111, 24, imgLargePiece[1], 13, 32, WHITE);
#ifdef DEBUG
arduboy.printEx(0, 0, F("DEBUG"));
#endif
}

static void drawRecord(void)
Expand Down

0 comments on commit 7946925

Please sign in to comment.