PROGRAMMER's CHALLENGE

Volume Number: 18 (2002)
Issue Number: 8
Column Tag: PROGRAMMER's CHALLENGE

# PROGRAMMER's CHALLENGE

by Bob Boonstra

### Endgame

The Chess players among you have another opportunity to excel this month. Back in 1995 (have I really been writing this column for that long?), we had a Challenge that required readers to identify all possible chess positions from a given board position. Gary Beith won that Challenge, and you might want to refer back to his solution when thinking about this month's problem, which invites you to solve the chess end game.

This month's problem is formulated as a C++ class. The prototype for the code you should write is:

```typedef enum {
kEmpty=0, kPawn, kKnight, kBishop, kRook, kQueen, kKing
} ChessPiece;
typedef enum {
kNone=0,kWhite=1, kBlack
} Player;
typedef struct Square {
ChessPiece piece;
Player player;
} Square;
typedef struct PieceLocation {
char row;
char col;
} PieceLocation;
typedef Square Board[8][8];
/* indexed as [row][col] */
/* white start row is 0 */
/* columns numbered left to right viewed from row 0 */
typedef struct Move {
Board board;
/* board before move is made */
Player playerMoving;
/* which player is making this move */
PieceLocation pieceBeingMoved;
/* which piece is being moved */
PieceLocation destination;
/* where is pieceBeingMoved being moved to */
Move *alternativeMove;
/* list pointer for alternative moves by playerMoving;
NULL if no more alternatives */
Move *subsequentMove;
/* subsequent move in this move tree, made by opponent to playerMoving,
NULL if no subsequent move is possible */
bool moveIsCapture;
/* true if this move is a capture */
bool moveIsCheck;
/* true if this move places the opponent in check (but not mate) */
bool moveIsMate;
/* true if this move mates the opponent */
bool moveIsPromotion;
/* true if this move promotes a pawn at the 8th rank */
ChessPiece pieceAfterPromotion;
/* valid only if moveIsPromotion is true, set to value of new piece */
} Move;
class EndGame {
Board board;
Move *initialMove;
/* add other private members as you see fit */
~EndGame(void) {
/* your destructor code goes here */
}
public:
EndGame(Board initialBoard, Player playerToMove) {
/* your constructor code goes here */
}
Move *Solve() {
/* your code goes here */
return moveTree;
}
};```

The constructor for your EndGame class is provided with the initial board configuration (board) and the identity of the player who moves first (playerToMove). When your Solve method is called, your job is to choose an initial move that leads to checkmate in the minimum number of moves possible. You also need to compute the possible opposing moves with which the other player might respond, and your response to each of those moves, and so on, until each branch of the tree results in checkmate.

Either your constructor or the Solve routine should allocate storage for your first move (moveTree). The Move structure contains the board configuration prior to making the move, the identity of the player making the move, the location and destination of the piece being moved, and some boolean values indicating the results of the move. It also contains a pointer to the next ply of the move tree (subsequentMove), and a pointer to alternative moves in the current ply (alternativeMove). The former contains moves made by the opposing player in response to this move, while the latter contains other moves that could be made by the current player instead of this move. Together, they allow you to describe the entire move tree.

Your destructor needs to free any memory allocated for the Move data structure.

In calculating moves, you can assume that any castling that might take place has already done so. You can also ignore the possibility of en passant pawn moves. You do need to consider the possibility of promoting a pawn by moving it to the 8th rank of the board. The Move data structure makes provision for specifying the type of the promoted piece.

The winner of this Challenge will be the entry that correctly solves all test cases in the least amount of execution time. Correctness means identifying all moves in the move tree, and guaranteeing checkmate in the minimum number of moves. Timing will include the constructor, a call to your solve routine, and a call to your destructor for a sequence of boards. I am eliminating the subjective evaluation factor for this Challenge because of questions about fairness, but both readers and I appreciate code that is clear and well commented.

This will be a native PowerPC Carbon C++ Challenge, using the Metrowerks CodeWarrior Pro 7.0 development environment. Please be certain that your code is carbonized, as I may evaluate this Challenge using Mac OS X.

### Winner of the May, 2002 Challenge

The May Challenge asked users to assemble a Jigsaw puzzle. The puzzle was presented as a color bitmap, with each piece of the puzzle consisting of contiguous pixels of a unique color. The pieces were disassembled and rotated by some multiple of 90 degrees. All of them were "face up". The puzzle was guaranteed to be rectangular in shape, and the pieces were guaranteed to fit together in only one way. The top left corner of the puzzle was in the correct position, which removed any ambiguity about orientation. Congratulations to Tom Saxton for submitting the winning entry for this Challenge.

Generating test data for the Challenge is often, well, a challenge, and this was particularly the case this month. I needed to ensure that the puzzle pieces I generated fit together without ambiguity. And while I could have generated puzzle pieces using "cuts" based on straight line segments, I wanted pieces that resembled real jigsaw puzzles. After struggling with this for some time, I nearly despaired of this objective, but eventually I found something that seems quite pleasing.

The first step in puzzle generation was to divide the puzzle into a roughly rectangular grid. For this, I decided to superimpose several cosine waves with random amplitudes, wavelengths, and offsets. I settled on summing four cosine functions for each horizontal or vertical "cut" in the puzzle, with amplitudes between 5% and 10% of the average piece size and wavelengths between 33% and ~300% of the average piece size. I repeatedly divided the puzzle into different colors for each of these horizontal and vertical cuts. This created a rectangular grid of uniquely shaped pieces with pleasantly curved edges.

I could have stopped there, but I really wanted to have pieces that had the protuberances or "ears" commonly found in real jigsaw puzzles. Being uncertain about how to create these using mathematics, I thought about creating ears manually and "stamping" them onto each edge, modifying them slightly to make them unique. That idea lasted all of about fifteen minutes, as tedium drove this thought from my mind. Eventually, I decided to experiment with one of my favorite programs, Graphing Calculator. An early version of GC came bundled with MacOS for some time, but <plug> the commercial version http://www.pacifict.com offers significantly more functionality </plug>. Anyway, GC has helped me out in the past, so I started experimenting, and ran across this sample equation:

Looking at the part of this equation that is above the x axis with -1<x<0.5, it seemed pretty close to what I was looking for. And randomly varying the amplitude of the sin functions caused the ear to take different shapes. The coefficients in the sin functions needed to be constrained to between about 1.5 and 5.5 in order to prevent the ear from being pinched off and disconnected from the base. In my first few puzzles, a few of these disconnected pieces bypassed detection by me, but not by contestants, so I eventually settled on a more restricted range of parameters that generated slightly less interesting, but still acceptable, ear shapes. For each edge, I selected a location somewhere in the middle of the piece, randomized the direction of the ear (with a small probability of having no ear at all), superimposed the x axis above onto the curved line described above, and adjusted the piece boundary according to the portion of a shape like the one above located above the x-axis (or, for vertical lines, the portion right of the y-axis. This turned out to be less trivial than I had hoped, especially being careful to avoid creating those pesky disconnected pieces. Preventing one ear from intersecting with another ear and cutting a piece in two proved to be an additional complication, but the end result looked like this:

Tom locates the individual pieces of the puzzle in his _FFindPieces routine, and creates four bitmaps per piece, one for each possible rotation, in _FBuildPceBitmap. He detects edge pieces in the _GetEdgeInfo routine, marking them as such for future use. After placing the upper left piece in its guaranteed-correct position, the heavy lifting is done by the _FSolvePce routine, which solves the puzzle from top to bottom, left to right. Tom checks each possible rotation of each piece against the current piece location using two passes, the first trying to look at only pieces with the correct "innie/outie" (Tom's term) match, and the second to pick up pieces to weirdly shaped to be missed in the first pass. The logic for matching two pieces is rather intricate, and can be found in the _FTestPce routine.

Ernst solves the puzzles by first creating a vector array for each piece that described a clockwise path around the piece. He assembles the pieces by inserting them into a Shell data structure, first placing the edge pieces, and spiralling inward toward the center. While his solution is very fast, it became confused on the largest of my test cases, a problem that Ernst attributed to a lack of backtracking logic.

I evaluated the entries using 6 test cases that ranged in size from 24 pieces to 3750 pieces. Both Ernst and Tom were credited for including an optional feature to display the solved puzzle. Tom also displayed the puzzle in its disassembled state, and included options to display PICT and Jigsaw files, for which he earned a feature point reduction bonus. Ernst earned a larger point reduction for code clarity and commentary.

The table below lists, for each of the solutions submitted, the total execution time in seconds, the bonuses for clarity and for displaying the solved puzzle, and the total score. It also lists the programming language used for each entry. As usual, the number in parentheses after the entrant's name is the total number of Challenge points earned in all Challenges prior to this one.

```
Time     Cases     Clarity   Features   Score   Language
(secs)   Correct   Bonus     Bonus
Tom Saxton (210)     597.1      6       0.10       0.25      388.1   C++
Ernst Munter (872)   89.9       5       0.25       0.20       49.5   C++```

### Top Contestants ...

Listed here are the Top Contestants for the Programmer's Challenge, including everyone who has accumulated 20 or more points during the past two years. The numbers below include points awarded over the 24 most recent contests, including points earned by this month's entrants.

```
Rank  Name              Points    Wins       Total
(24 mo)           (24 mo)   Points
1.   Munter, Ernst       243       8         872
2.   Saxton, Tom          65       2         230
3.   Taylor, Jonathan     57       2          83
4.   Stenger, Allen       53       1         118
5.   Rieken, Willeke      42       2         134
6.   Wihlborg, Claes      40       2          49
8.   Gregg, Xan           20       1         140
9.   Mallett, Jeff        20       1         114
10.   Cooper, Tony         20       1          20
11.   Truskier, Peter      20       1          20   ```

Here is Tom's winning Jigsaw solution. The code had been abridged for publication because of page constraints; see http://www.mactech.com for the full version.

Jigsaw.cp

Tom Saxton

```/*
*  Jigsaw
*
*  Created by Tom Saxton on Thu Apr 18 2002.
*/
#include <Carbon/Carbon.h>
#include "jigsaw.h"
// make sure we aren't using printf in the non-console builds
#ifndef UI_CONSOLE
#define printf error
#endif
typedef struct PT PT; // a point
struct PT
{
int x, y;
};
#define zNil 0x7FFF
typedef struct EDGE EDGE; // info about an edge
struct EDGE
{
char fEdge;
};
typedef enum
{
btEdge
} BT;
typedef struct ROT ROT;
struct ROT // info for a rotation of a piece
{
int mruReject;
EDGE aedge[4];
BitMap bitmapEdge;
};
typedef struct PCE PCE;
struct PCE // a single piece, including its four rotations
{
long cpixel;
ushort clr;
char cEdgeSide;
char irotUsed;
ROT arot[4];
};
typedef struct PUZ PUZ;
struct PUZ // the puzzle solving state
{
// challenge state maintained by host
CS *pcs;
// the image data, (first the input file, then the output file after extracting the pieces)
BITS bits;
int fChangedSize;
// bitmap mask for the puzzle as we decompose then solve it

// the array of pieces
int cpce;
PCE *papce;

// memory block from which we allocate the bitmaps of the individual pieces
char *pabBuffer;
long cbBufferAlloc;
long cbBufferUsed;

// the current solution state
int ipceNext;
Rect rectPrev;
int xRightEdge, yBottomEdge;
int cpceRow;
int yTopUnsolved;
long cpixelImage;
long cpixelPuzzle;
long cpixelSolved;
AbsoluteTime ticksTotal;
AbsoluteTime tickStart;
};
typedef struct DIR DIR;
struct DIR // a direction to move to an adjacent pixel
{
int dx, dy;
};
// directions to look when checking the left edge of a piece
{
{  0,  1 },
{ -1,  1 },
{ -1,  0 },
{ -1, -1 },
{  0, -1 },
};
// directions to look when checking the top edge of a piece
{
{  1,  0 },
{  1, -1 },
{  0, -1 },
{ -1, -1 },
{ -1,  0 },
};
enum
{
iedgeTop = 0,
iedgeLeft,
iedgeBottom,
iedgeRight,
cedge
};
// directions to look when finding the boundary of a piece
{
{  1,  0 },
{  0,  1 },
{ -1,  0 },
{  0, -1 },
};
// function prototypes deleted for brevity
SolveJigsaw
// the public entry point to the puzzle solver
void SolveJigsaw(CS *pcs, const char pszFile[])
{

OSStatus ec;
int cSolved = 0;
FN fnOut = fnNil;
double musecTotal = 0.0;

// init the puzzle structure
PUZ puz;
memset(&puz, 0, sizeof(PUZ));
puz.pcs = pcs;

// open and read the challenge file (omitted for brevity)
// create and open the output file (omitted for brevity)

// process the cases
for (; iCase <= cCase; ++iCase)
{
// note the starting time
puz.ticksTotal = s_tickZero;
puz.tickStart = UpTime();
#ifdef UI_CONSOLE
printf("process case %d of %d:\n", iCase, cCase);
#endif

break;
#ifdef UI_GUI
// put the starting image into the output window
SubAbsoluteFromAbsolute(UpTime(), puz.tickStart));
DrawBits(puz.pcs, puz.bits, puz.xRightEdge, puz.yBottomEdge);
puz.tickStart = UpTime();
#endif

// let's find all of the pieces
if (!_FFindPieces(&puz))
{
_FreePuz(&puz);
continue;
}

// place the first piece into the output buffer
_PlacePce(&puz, 0, 0, 0, 0);
#ifdef UI_GUI
SubAbsoluteFromAbsolute(UpTime(), puz.tickStart));
DrawBits(puz.pcs, puz.bits, puz.xRightEdge, puz.yBottomEdge);
puz.tickStart = UpTime();
#endif
while (puz.ipceNext < puz.cpce && _FSolvePce(&puz))
{
#ifdef UI_GUI
SubAbsoluteFromAbsolute(UpTime(), puz.tickStart));
if (puz.fChangedSize)
{
DrawBits(puz.pcs, puz.bits, puz.xRightEdge,
puz.yBottomEdge);
puz.fChangedSize = fFalse;
}
else
{
UpdateBits(puz.pcs, puz.bits, puz.rectPrev);
}
puz.tickStart = UpTime();
#endif
}

// if we completely solved the puzzle, write out the solution
if (puz.ipceNext == puz.cpce)
{
#ifdef UI_CONSOLE
printf("\tpuzzle %d solved\n", iCase);
#endif
// write out our solution
if (!_FWriteResult(&puz, iCase))
break;
++cSolved;
}
if (puz.ipceNext < puz.cpce)
{
#ifdef UI_CONSOLE
printf("ERROR: Solve failed after %d pieces\n", puz.ipceNext);
#endif
}
// free the memory used by this puzzle
_FreePuz(&puz);

// get the ending time and subtract the starting time to get elapsed time
// write the time, in microseconds, to the file
//      (omitted for brevity)
}
#ifdef UI_CONSOLE
printf("%d of %d puzzles solved, total time = %g\n", cSolved, cCase, musecTotal);
#endif
LRet:
_FreePuz(&puz); // harmless if the puz was freed through normal process
if (fnOut != 0)
CloseFn(fnOut);
}
// load in the data for a puzzle (omitted for brevity)
static int _FLoadData(PUZ *ppuz, int iCase)
//    (omitted for brevity)
_FFindPieces
// locate the pieces in the input file, build bitmaps for them
static int _FFindPieces(PUZ *ppuz)
{
int fSuccess = fFalse;
ppuz->cpixelPuzzle = 0;
ppuz->yTopUnsolved = 0;

ushort *psw;
{
const ushort *pswLim =
&ppuz->bits.pasw[ppuz->bits.dx * ppuz->bits.dy];
for (psw = ppuz->bits.pasw; psw < pswLim; ++psw)
if (*psw > ppuz->cpce)
ppuz->cpce = *psw;
}
// allocate and init the piece array
ppuz->papce = new PCE[ppuz->cpce];
if (ppuz->papce == NULL)
{
#ifdef UI_CONSOLE
printf("ERROR: oom allocating piece array with %d entries\n",
ppuz->cpce);
#endif
goto LExit;
}
memset(ppuz->papce, 0, sizeof(PCE)*ppuz->cpce);
psw = ppuz->bits.pasw;
for (int y = 0; y < ppuz->bits.dy; ++y)
{
for (int x = 0; x < ppuz->bits.dx; )
{
int xStart = x++;
ushort clr = *psw++;
if (clr == 0)
continue;
while (x < ppuz->bits.dx && *psw == clr)
++x, ++psw;
PCE *ppce = &ppuz->papce[clr-1];
if (ppce->clr == 0)
{
ppce->clr = clr;
y, x, y+1);
}
else
{
y, xStart, x);
}
}
}
// figure out an upper bound on how much bitmap data we'll need
{
int dzMost = 0;
for (int ipce = 0; ipce < ppuz->cpce; ++ipce)
{
int dx = prect->right - prect->left;
if (dx > dzMost)
dzMost = dx;
int dy = prect->bottom - prect->top;
if (dy > dzMost)
dzMost = dy;
}
long cbBitmapMost = dzMost * ((dzMost + 15) >> 4) << 1;
ppuz->cbBufferAlloc = cbBitmapMost * ppuz->cpce * 8;
ppuz->pabBuffer = new char[ppuz->cbBufferAlloc];
}

for (int ipce = 0; ipce < ppuz->cpce; ++ipce)
{
if (!_FBuildPceBitmaps(ppuz, ipce))
goto LExit;
#ifdef UI_GUI
SubAbsoluteFromAbsolute(UpTime(), ppuz->tickStart));
ppuz->tickStart = UpTime();
#endif
}

fSuccess = fTrue;
#ifdef UI_CONSOLE
printf("\tfound %d pieces comprising %ld pixels\n", ppuz->cpce, ppuz->cpixelPuzzle);
#endif
LExit:
return fSuccess;
}
_FBuildPceBitmap
// build the required bitmaps for a puzzle piece in all four rotations
static int _FBuildPceBitmaps(PUZ *ppuz, int ipce)
{
int fSuccess = fFalse;
PCE *ppce = &ppuz->papce[ipce];

rectBounds.left, rectBounds.top, rectBounds.right,
rectBounds.bottom))
goto LExit;
if (!_FCreateBitmap(ppuz, &ppce->arot[0].bitmapEdge,
rectBounds.left, rectBounds.top, rectBounds.right,
rectBounds.bottom))
goto LExit;
ppuz->cpixelPuzzle += ppce->cpixel = _ColorFill(&ppuz->bits,
&ppce->arot[0].bitmapEdge);
_GetEdgeInfo(ppuz, ppce);

for (int irot = 1; irot < DIM(ppce->arot); ++irot)
if (!_FRotateBitmap(ppuz, ppce->arot[0].bitmapEdge, irot,
&ppce->arot[irot].bitmapEdge))
goto LExit;

fSuccess = fTrue;
LExit:
return fTrue;
}
_FSolvePce
// solve for one piece of the puzzle
static int _FSolvePce(PUZ *ppuz)
{
// find the first unplaced pixel
int xTarget, yTarget;
// start x out just to the right of the most recent piece we placed,
// unless that piece hit the right edge of the puzzle
xTarget = ppuz->rectPrev.right;
if (xTarget == ppuz->xRightEdge)
xTarget = 0;
else
++xTarget;
// starting at the top of the unsolved area of the puzzle, march down
// the chosen x column until we find an unset pixel
for (yTarget = ppuz->yTopUnsolved; yTarget < ppuz->yBottomEdge;
++yTarget)
break;
// now, try to move as far up and to the left as possible since
// we'd really like to have the upper left corner pixel of the next
// piece as our target
while (fTrue)
{
if (xTarget > 0 && !_FGetBit(ppuz->bitmapMask, xTarget-1,
yTarget))
--xTarget;
else if (yTarget > 0 && !_FGetBit(ppuz->bitmapMask, xTarget,
yTarget-1))
--yTarget;
else
break;
}

// finally, make sure the target point in the leftmost unset pixel in yTarget's row
// so that we only have to check the leftmost set pixel of each scan line in each
// candidate piece
for (int xT = xTarget - 1; xT >= ppuz->rectPrev.left; --xT)
{
xTarget = xT;
}
PT aptCheck[4];
int cptCheck = 0;
if (ppuz->rectPrev.right < ppuz->xRightEdge)
{
PCE *ppcePrev = &ppuz->papce[ppuz->ipceNext-1];
ROT *prot = &ppcePrev->arot[ppcePrev->irotUsed];
for (int ipt = 0; ipt < cptIn; ++ipt)
{
PT pt = aptCheck[ipt];
_OffsetPt(&pt,
ppuz->rectPrev.left - prot->bitmapEdge.bounds.left,
ppuz->rectPrev.top  - prot->bitmapEdge.bounds.top
);
pt.x += 1;
aptCheck[cptCheck++] = pt;
}
}
if (ppuz->yTopUnsolved > 0)
{
const PCE *ppceAbove =
&ppuz->papce[ppuz->ipceNext - ppuz->cpceRow];
const ROT *protAbove = &ppceAbove->arot[ppceAbove->irotUsed];
PT ptTop;
for (ptTop.y = ppuz->yTopUnsolved;
ptTop.y < ppuz->yBottomEdge; ++ptTop.y)
{
{
aptCheck[cptCheck++] = ptTop;
break;
}
}
}
for (int pass = 1; pass <= 2; ++pass)
{
for (int irot = 0; irot < DIM(ppuz->papce[0].arot); ++irot)
{
for (int ipce = ppuz->ipceNext; ipce < ppuz->cpce; ++ipce)
{
PCE *ppce = &ppuz->papce[ipce];
ROT *prot = &ppce->arot[irot];

// if we're looking for an edge piece, consider only edge pieces
if (yTarget == 0 || xTarget == 0)
{
if (ppce->cEdgeSide == 0)
continue;
if (yTarget == 0 && !prot->aedge[iedgeTop].fEdge)
continue;
if (xTarget == 0 && !prot->aedge[iedgeLeft].fEdge)
continue;
}

if (pass == 2 && prot->mruReject != ppuz->ipceNext)
{
// some pieces are too wierd to work with the innie/outie testing (below),
// let all the configurations that got rejected previously run through
// this time, but don't test any piece twice!
continue;
}

Rect bounds = prot->bitmapEdge.bounds;
for (int y = WMin(bounds.bottom-1,
bounds.top + (yTarget - ppuz->yTopUnsolved));
y >= bounds.top; --y)
{
for (int x = bounds.left; x < bounds.right; ++x)
{
if (!_FGetBit(prot->bitmapEdge, x, y))
continue;

int dx = xTarget - x;
int dy = yTarget - y;
// make sure the proposed bounding box fits inside the puzzle
if (bounds.left + dx < 0
|| bounds.right + dx > ppuz->xRightEdge
|| bounds.top + dy < 0
|| bounds.bottom + dy > ppuz->yBottomEdge)
{
continue;
}
if (pass == 1)
{
// make sure we have edge bits to join with check points on the
// previous piece
int ipt;
for (ipt = 0; ipt < cptCheck; ++ipt)
if (!_FGetBitSafe(prot->bitmapEdge,
aptCheck[ipt].x - dx, aptCheck[ipt].y - dy))
break;
if (ipt < cptCheck)
{
prot->mruReject = ppuz->ipceNext;
break;
}
}
if (_FTestPce(ppuz, ipce, irot, dx, dy))
{
_PlacePce(ppuz, ipce, irot, dx, dy);
return fTrue;
}
break;
}
}
}
}
}
return fFalse;
}
_FTestPce
// test whether or not the indicated piece fits into the puzzle at
// the specified offset from it starting position.
static int _FTestPce(PUZ *ppuz, int ipce, int irot,
int dx, int dy)
{
int fPassed = fFalse;
// check that no edge pixel invades the completed portion of the puzzle
PCE *ppce = &ppuz->papce[ipce];
ROT *prot = &ppce->arot[irot];
BitMap *pbitmapEdge = &prot->bitmapEdge;
Rect bounds = pbitmapEdge->bounds;
for (int y = bounds.top; y < bounds.bottom; ++y)
{
int x = bounds.left;
for ( ; x < bounds.right; )
{
char b = *pb++;
if (b == 0)
{
x += 8;
continue;
}
{
{
{
goto LRet;
}
}
}
}
}
// make sure the mask bitmap has been built
{
{
#ifdef UI_CONSOLE
printf("ERROR: oom building rotated mask bitmap for piece %d\n", ppuz->ipceNext);
#endif
goto LRet;
}
}
// now scan left edge pixels looking for pixels that are interior to the proposed
// assembled pieces in order to pass, there have to be interior edge pixels from the
// top of the piece down "most"  the piece, with no gaps.
{
int xMid = (bounds.left + bounds.right)/2;
int yInteriorLim = bounds.top;
int yInteriorReqd = (bounds.top + bounds.bottom)/2;
for (int y = bounds.top; y < bounds.bottom; ++y)
{
int x = bounds.left;
for ( ; x < xMid; )
{
char b = *pb++;
if (b == 0x00)
{
x += 8;
continue;
}
{
{
if (x >= xMid)
break;
int idir;
for (idir = 0; idir < DIM(s_adirLeft); ++idir)
{
y+dy+dir.dy)
y+dy+dir.dy)
)
{
break;
}
}
{
// this pixel is an interior pixel
if (yInteriorLim < y)
{
goto LRet; // we lose, there was a gap in the interior
//edge pixels
}
yInteriorLim = y+1;
x = bounds.right; // force the "x" loop to terminate
break;
}
else
{
// this pixel is not an interior pixel
if (y < yInteriorReqd)
goto LRet; // we didn't find enough contiguous interior
//edge pixels

// we don't mind that this edge pixel isn't an interior pixel,
// and we can stop looking at this scan line
goto LPassedLeft;
}
}
}
}

Assert (x >= xMid);
// any pixels on the left half of this scan line are interior pixels
if (yInteriorLim < y)
goto LRet; // we lose, there was a gap in the interior edge pixels
yInteriorLim = y+1;
}
}
LPassedLeft:
// now scan top edge pixels looking for pixels that are interior to the proposed
// assembled pieces in order to pass, there have to be interior edge pixels from the
// top of the piece down "most" of the piece, with no gaps.
{
int yMid = (bounds.top + bounds.bottom)/2;
int xInteriorLim = bounds.left;
int xInteriorReqd = (bounds.left + bounds.right)/2;
for (int x = bounds.left; x < bounds.right; ++x)
{
int y = bounds.top;
for ( ; y < yMid; ++y, pb += pbitmapEdge->rowBytes)
{
{
int idir;
for (idir = 0; idir < DIM(s_adirAbove); ++idir)
{
y+dy+dir.dy)
y+dy+dir.dy)
)
{
break;
}
}
{
// this pixel is an interior pixel
if (xInteriorLim < x)
goto LRet; // we lose, there was a gap in the interior edge
//pixels
xInteriorLim = x+1;
y = bounds.bottom; // force the "y" loop to terminate
break;
}
else
{
// this pixel is not an interior pixel
if (x < xInteriorReqd)
goto LRet; // we didn't find enough contiguous interior
//edge pixels

// we don't mind that this edge pixel isn't an interior pixel,
// and we can stop looking at this scan line
goto LPassedTop;
}
}
}

Assert (y >= yMid);
// any pixels on the top half of this scan line are interior pixels
if (xInteriorLim < x)
goto LRet; // we lose, there was a gap in the interior edge pixels
xInteriorLim = x+1;
}
}
LPassedTop:
fPassed = fTrue;
LRet:
return fPassed;
}
// write out the solved puzzle state
static int _FWriteResult(PUZ *ppuz, int iCase)
// omitted for brevity
_PlacePce
// place the indicated piece into the puzzle at the specified offset
// from its current position
static void _PlacePce(PUZ *ppuz, int ipce, int irot, int dxOffset, int dyOffset)
{
PCE *ppce = &ppuz->papce[ipce];
ROT *prot = &ppce->arot[irot];
Rect boundsDst = boundsSrc;
_OffsetRect(&boundsDst, dxOffset, dyOffset);
// record the bounds of where we placed the most current piece
ppuz->rectPrev = boundsDst;
ppce->irotUsed = irot;

// copy the piece to the output image
dxOffset, dyOffset);
// check to see if we've found the right edge yet
if (ppuz->xRightEdge == ppuz->bits.dx &&
prot->aedge[iedgeRight].fEdge)
{
// test to see if the piece we just put in is an edge piece,
// we require a more strict "edge" test for this purpose
int y;
int x = boundsSrc.right - 1;
for (y = boundsSrc.top; y < boundsSrc.bottom; ++y)
break;
if (y > (boundsSrc.top + 2*boundsSrc.bottom)/3)
{
for ( ; y < boundsSrc.bottom; ++y)
break;
if (y == boundsSrc.bottom)
{
if ((ppuz->cpixelPuzzle % boundsDst.right) == 0
&& (ppuz->cpce % (ppuz->ipceNext+1)) == 0)
{
ppuz->xRightEdge = boundsDst.right;
ppuz->yBottomEdge = ppuz->cpixelPuzzle/ppuz->xRightEdge;
ppuz->cpceRow = ppuz->ipceNext+1;
ppuz->fChangedSize = fTrue;
}
}
}
}
// if we hit the right edge or hit a pixel in the first unsolved scan line,
// update ppuz->yTopUnsolved
if (ppuz->rectPrev.right == ppuz->xRightEdge ||
boundsSrc.top+dyOffset == ppuz->yTopUnsolved)
{
for ( ; ; ++ppuz->yTopUnsolved)
{
int x;
for (x = 0; x < ppuz->xRightEdge; x += 8, ++pb)
{
if (*pb == 0xFF)
continue;
if ((*pb & mask) == 0)
break;
break;
}
if (x < ppuz->xRightEdge)
break;
}
}

// update stats
ppuz->cpixelSolved += ppce->cpixel;

// move the rotation we used to its correct location for use later
_OffsetRect(&prot->bitmapEdge.bounds, dxOffset, dyOffset);
// update the piece array
if (ipce != ppuz->ipceNext)
{
PCE pceT = ppuz->papce[ipce];
ppuz->papce[ipce] = ppuz->papce[ppuz->ipceNext];
ppuz->papce[ppuz->ipceNext] = pceT;
}
++ppuz->ipceNext;

}
// set the mask bitmap and color in the solved puzzle with the new piece
static void _TransferBitmapToImage(PUZ *ppuz, const ROT *prot,
BT bt, ushort clr, int dxOffset, int dyOffset)
// omitted for brevity
_FreePuz
// free the puzzle state and everything it allocated
static void _FreePuz(PUZ *ppuz)
{
_FreeBits(&ppuz->bits);
if (ppuz->papce != NULL)
{
delete [] ppuz->pabBuffer;
ppuz->pabBuffer = NULL;
ppuz->cbBufferUsed = ppuz->cbBufferAlloc = 0;

delete [] ppuz->papce;
ppuz->papce = NULL;
ppuz->cpce = ppuz->ipceNext = 0;
}

}
_FreeBits
// free the buffer that holds the bitmap image data
static void _FreeBits(BITS *pbits)
{
if (pbits->pasw != NULL)
{
delete [] pbits->pasw;
pbits->pasw = NULL;
}
}
_FCreateBitmap
// allocate a new bitmap with the specified bounding rect
// if ppuz != NULL, use the preallocted buffer, otherwise use new
static int _FCreateBitmap(PUZ *ppuz, BitMap *pbitmap, int xLeft, int yTop, int xRight, int yBottom)
{
_SetRect(&pbitmap->bounds, xLeft, yTop, xRight, yBottom);
pbitmap->rowBytes = (((xRight - xLeft) + 15) >> 4) << 1;
long cbBitmap = _CbBitmap(*pbitmap);

if (ppuz != NULL)
{
// grab the chunk we need
ppuz->cbBufferUsed += cbBitmap;
}
else
{
}

}
_FreeBitmap
// free a bitmap whose bits were individually allocated
// be careful: most bit maps get allocated from the preallocated buffer
static void _FreeBitmap(BitMap *pbitmap)
{
{
}
}
_FGetBit
// return the state of the specified bit
static int _FGetBit(const BitMap &bitmap, int x, int y)
{
int fSet = ((*pb) & mask) != 0;
return fSet;
}
_FGetBitSafe
// return the value of the specified bit if it's withing the bitmap,
// otherwise return 0
static int _FGetBitSafe(const BitMap &bitmap, int x, int y)
{
int fSet = _FPtInRect(bitmap.bounds, x, y) ?
_FGetBit(bitmap, x, y) : 0;
return fSet;
}
_SetBit
// makes sure the indicated bit is set, returns non-zero if the bit needed to be set
static void _SetBit(BitMap *pbitmap, int x, int y)
{
}
// set a bit in the specified bitmap
static void _SetBit(BitMap *pbitmap, int x, int y, int fSet)
{
if (fSet)
else
}
_CbBitmap
// return size needed for the specified bitmap's bitmap data
static long _CbBitmap(const BitMap &bitmap)
{
return (bitmap.bounds.bottom - bitmap.bounds.top) * bitmap.rowBytes;
}
// for the specified pixel location within the bitmap, return the pointer
// to the correct byte in the bitmap data and the mask for the specified bit
// note - this is done incrementally in time critical routines
{
y -= pbitmap->bounds.top;
x -= pbitmap->bounds.left;
*pmask = 0x80 >> (x & 0x7);
return (uchar *)&pbitmap->baseAddr[y * pbitmap->rowBytes +
(x>>3)];
}
_OffsetPt
// offset the point by the specified amounts
static void _OffsetPt(PT *ppt, int dx, int dy)
{
ppt->x += dx;
ppt->y += dy;
}
_FPtInRect
// is the specified point in the specified rect?
static int _FPtInRect(const Rect &rect, int x, int y)
{
return rect.left <= x && x < rect.right &&
rect.top <= y && y < rect.bottom;
}
_SetRect
// like QD routine, but thread safe
static void _SetRect(Rect *prect, short left, short top, short right, short bottom)
{
prect->left = left;
prect->top = top;
prect->right = right;
prect->bottom = bottom;
}
_OffsetRect
// like QD routine, but thread safe
static void _OffsetRect(Rect *prect, short dx, short dy)
{
prect->left += dx;
prect->right += dx;
prect->top += dy;
prect->bottom += dy;
}
_ExpandRect
// expand the specified rect to include the specified scan line
static void _ExpandRect(Rect *prect, int y, int xFirst, int xLim)
{
prect->bottom = y + 1;
if (prect->left > xFirst)
prect->left = xFirst;
if (prect->right < xLim)
prect->right = xLim;
}
// find all of the pixels in the original puzzle image data which match the
// specified "color", constraining the search to the specified rectangle
static long _ColorFill(BITS *pbits, const Rect &rectBounds, ushort clrMatch, BitMap *pbitmapMask)
{
ushort *psw = &pbits->pasw[rectBounds.top * pbits->dx +
rectBounds.left];
int cswSkip = pbits->dx - (rectBounds.right - rectBounds.left);
long cpixelMatch = 0;
for (int y = rectBounds.top; y < rectBounds.bottom; ++y)
{
for (int x = rectBounds.left; x < rectBounds.right;
++x, ++psw)
{
if (*psw == clrMatch)
{
*psw = 0;
++cpixelMatch;
}
}
psw += cswSkip;
}

return cpixelMatch;
}
_BuildEdgeBitmap
// find the boundary of a piece and construct a bitmap with those bits set
static void _BuildEdgeBitmap(const BitMap &bitmapMask, BitMap *pbitmapEdge)
{
{
{
{
for (int idir = 0; idir < DIM(s_adirEdge); ++idir)
{
const struct DIR *pdir = &s_adirEdge[idir];
{
_SetBit(pbitmapEdge, x, y);
break;
}
}
}
}
}
}
_FRotateBitmap
// rotate the given bitmap by the specified number of quarter turns and put
// the result in a newly allocated bitmap
static int _FRotateBitmap(PUZ *ppuz, const BitMap &bitmapSrc,
int irot, BitMap *pbitmapDst)
{
Rect rectBounds = bitmapSrc.bounds;
switch (irot)
{
case 1:
if (!_FCreateBitmap(ppuz, pbitmapDst, rectBounds.top,
rectBounds.left, rectBounds.bottom, rectBounds.right))
return fFalse;
_RotateBitmap90(bitmapSrc, pbitmapDst);
break;
case 2:
if (!_FCreateBitmap(ppuz, pbitmapDst, rectBounds.left,
rectBounds.top, rectBounds.right, rectBounds.bottom))
return fFalse;
_RotateBitmap180(bitmapSrc, pbitmapDst);
break;
case 3:
if (!_FCreateBitmap(ppuz, pbitmapDst, rectBounds.top,
rectBounds.left, rectBounds.bottom, rectBounds.right))
return fFalse;
_RotateBitmap270(bitmapSrc, pbitmapDst);
break;
}

return fTrue;
}
_RotateBitmap180
// rotate the source bitmap by 180 degrees into the destination bitmap
static void _RotateBitmap180(const BitMap &bitmapSrc,
BitMap *pbitmapDst)
{
for (int ySrc = bitmapSrc.bounds.top,
yDst = pbitmapDst->bounds.bottom-1;
ySrc < bitmapSrc.bounds.bottom; ++ySrc, --yDst)
for (int xSrc = bitmapSrc.bounds.left,
xDst = pbitmapDst->bounds.right-1;
xSrc < bitmapSrc.bounds.right; ++xSrc, --xDst)
_SetBit(pbitmapDst, xDst, yDst, _FGetBit(bitmapSrc, xSrc, ySrc));
}
// _RotateBitmap90 and _RotateBitmap270 omitted for brevity
_GetEdgeInfo
// get info about the edges of the specified piece
static void _GetEdgeInfo(PUZ *ppuz, PCE *ppce)
{
ROT *prot = &ppce->arot[0];
BitMap *pbitmap = &prot->bitmapEdge;
Rect bounds = pbitmap->bounds;
ppce->cEdgeSide = 0;
for (int idir = 0; idir < DIM(s_adirEdge); ++idir)
{

int x, y;
int zFirst, zLim, *pz;
if (dir.dx != 0)
{
pz = &x;
zFirst = bounds.left;
zLim = bounds.right;
y = dir.dx > 0 ? bounds.top : bounds.bottom - 1;
}
else
{
pz = &y;
zFirst = bounds.top;
zLim = bounds.bottom;
x = dir.dy > 0 ? bounds.left : bounds.right - 1;
}

// scan to see if this side looks like an edge piece
EDGE *pedge = &prot->aedge[idir];
pedge->fEdge = fFalse;
int dzEdge = zLim - zFirst;
if (dzEdge < 0)
dzEdge = -dzEdge;

int cpixEdge = 0;
for (*pz = zFirst ; *pz != zLim; *pz += 1)
{
if (!_FGetBit(*pbitmap, x, y))
{
cpixEdge = 0;
continue;
}
if (cpixEdge++ > 0)
{
if (cpixEdge == dzEdge/2)
prot->aedge[idir].fEdge = fTrue;
}
else if (prot->aedge[idir].fEdge)
{
prot->aedge[idir].fEdge = fFalse;
break;
}
}
if (prot->aedge[idir].fEdge)
++ppce->cEdgeSide;
}
// copy the edge information to the other rotations
for (int irot = 1; irot < DIM(ppce->arot); ++irot)
for (int iedge = 0; iedge < 4; ++iedge)
ppce->arot[irot].aedge[iedge] =
prot->aedge[(iedge + irot) % 4];
}
_FindCorners
// find a reasonable guess for the corners of the piece stored in the bitmap
static void _FindCorners(const BitMap &bitmap,
PT *pptTop, PT *pptBottom)
{
Rect rectBounds = bitmap.bounds;

pptTop->x = -1;
for (int d = 0; pptTop->x == -1; ++d)
{
PT pt;
for (pt.x = rectBounds.right-1, pt.y = rectBounds.top+d;
pt.y < rectBounds.bottom && pt.x >= rectBounds.left;
--pt.x, ++pt.y)
{
if (_FGetBit(bitmap, pt.x, pt.y))
{
pptTop->x = _XFirstBit(bitmap, pptTop->y = ++pt.y);
break;
}
}
}

pptBottom->x = -1;
for (int d = 0; pptBottom->x == -1;++d)
{
PT pt;
for (pt.x = rectBounds.right-1, pt.y = rectBounds.bottom-1-d;
pt.y >= rectBounds.top && pt.x >= rectBounds.left;
--pt.x, --pt.y)
{
if (_FGetBit(bitmap, pt.x, pt.y))
{
pptBottom->x = _XFirstBit(bitmap, pptBottom->y = --pt.y);
break;
}
}
}
}
_CptGetEdgeShape
// return up to three "interesting" points along the right edge of the piece
// stored in bitmap
static int _CptGetEdgeShape(const BitMap &bitmap,
PT paptCheck[3])
{
// first, find the corners, more or less
PT ptCornerTop, ptCornerBottom;
_FindCorners(bitmap, &ptCornerTop, &ptCornerBottom);
int dyQuarterEdge = (ptCornerBottom.y - ptCornerTop.y)/4;

int cptCheck = 0;
Rect rectBounds = bitmap.bounds;
PT ptIn = {zNil, zNil}, ptOut = {zNil, zNil};
int iptIn = -1, iptOut = -1;
int xIn = rectBounds.right, xOut = rectBounds.left-1;
int fOutPrev = fFalse, fInPrev = fFalse;
int yMidMin = ptCornerTop.y+1;
int yMidLim = ptCornerBottom.y;

PT aptJump[255];
int cptJump = 0;
PT ptPrev;
ptPrev.x = _XFirstBit(bitmap, ptPrev.y = yMidMin);
aptJump[cptJump++] = ptPrev;
for (PT ptCur = ptPrev; ++ptCur.y < yMidLim; )
{
ptCur.x = _XFirstBit(bitmap, ptCur.y);

if (ptCur.x == ptPrev.x)
continue;

int dx = ptCur.x - ptPrev.x;
int fIn = dx < 0;
int fOut = !fIn;

int yPeak;
if (fOut && fInPrev)
{
// we have local min!
if (ptPrev.x < xIn
&& _FMiddleish(ptPrev.y, ptCur.y, yMidMin, yMidLim, &yPeak)
)
{
ptIn.x = ptPrev.x;
ptIn.y = yPeak;
xIn = ptPrev.x;
iptIn = cptJump-1;
}
}
else if (fIn && fOutPrev)
{
// we have a local max!
if (ptPrev.x > xOut
&& _FMiddleish(ptPrev.y, ptCur.y, yMidMin, yMidLim, &yPeak)
)
{
ptOut.x = ptPrev.x;
ptOut.y = yPeak;
xOut = ptPrev.x;
iptOut = cptJump-1;
}
}

aptJump[cptJump++] = ptCur;
ptPrev = ptCur;
fInPrev = fIn;
fOutPrev = fOut;
}
if (ptIn.x != zNil)
{
int iptPrev, iptNext, dx;

for (iptPrev = iptIn; ; )
{
if (--iptPrev < 0)
goto LCheckOut;
dx = aptJump[iptPrev+1].x - aptJump[iptPrev].x;
if (dx < -1)
break;
if (dx > 0)
if (dx > 1 || aptJump[iptPrev+1].x > ptIn.x+1)
goto LCheckOut;
}
for (iptNext = iptIn; ; )
{
if (++iptNext >= cptJump)
goto LCheckOut;
dx = aptJump[iptNext].x - aptJump[iptNext-1].x;
if (dx > 1)
break;
if (dx < 0)
if (dx < -1 || aptJump[iptNext].x < ptIn.x-1)
goto LCheckOut;
}

// there has to be some bump to qualify as an innie
if (aptJump[iptNext].y - (aptJump[iptPrev+1].y-1) >
dyQuarterEdge*2)
goto LSmooth;
paptCheck[cptCheck].x = aptJump[iptPrev].x;
paptCheck[cptCheck++].y = aptJump[iptPrev+1].y-1;
paptCheck[cptCheck++] = ptIn;
paptCheck[cptCheck++] = aptJump[iptNext];
goto LRet;
}
LCheckOut:
if (ptOut.x != zNil && (ptIn.x == zNil ||
ptOut.x == rectBounds.right-1))
{
int iptPrev, iptNext, dx;

for (iptPrev = iptOut; ; )
{
if (--iptPrev < 0)
goto LSmooth;
dx = aptJump[iptPrev+1].x - aptJump[iptPrev].x;
if (dx > 1)
break;
if (dx < 0)
if (dx < -1 || aptJump[iptPrev+1].x < ptOut.x-1)
goto LSmooth;
}
for (iptNext = iptOut; ; )
{
if (++iptNext >= cptJump)
goto LSmooth;
dx = aptJump[iptNext].x - aptJump[iptNext-1].x;
if (dx < -1)
break;
if (dx > 0)
if (dx > 1 || aptJump[iptNext].x > ptOut.x+1)
goto LSmooth;
}

// there has to be some bump to qualify as an outie
if (aptJump[iptNext].y - (aptJump[iptPrev+1].y-1) >
dyQuarterEdge*2)
goto LSmooth;
paptCheck[cptCheck].x = aptJump[iptPrev].x;
paptCheck[cptCheck++].y = aptJump[iptPrev+1].y-1;
paptCheck[cptCheck++] = ptOut;
paptCheck[cptCheck++] = aptJump[iptNext];
goto LRet;
}
LSmooth:
if (ptIn.x == zNil && ptOut.x == zNil)
{
int yWant = ptCornerTop.y + dyQuarterEdge;
int ipt = 1;
while (ipt < cptJump && aptJump[ipt].y <= yWant)
++ipt;
paptCheck[cptCheck].y = yWant;
paptCheck[cptCheck++].x = aptJump[ipt-1].x;
yWant = ptCornerBottom.y - dyQuarterEdge;
ipt = cptJump-1;
while (aptJump[ipt].y > yWant)
--ipt;
paptCheck[cptCheck].y = yWant;
paptCheck[cptCheck++].x = aptJump[ipt].x;
}
else
{
if (ptIn.x != zNil)
paptCheck[cptCheck++] = ptIn;
if (ptOut.x != zNil)
paptCheck[cptCheck++] = ptOut;
}
LRet:
return cptCheck;
}
// determine if any element of the segment [x1, x2) is within the
// the range [xFirst, xLim). If not, return fFalse. If so,
// set *pxMid to a pixel inside the both ranges, as near the midpoint of
// [xFirst, xLim) as possible
static int _FMiddleish(int x1, int x2, int xFirst, int xLim, int *pxMid)
{
// calculate the midpoint and then the limits of the center segment
int xMid = (xFirst + xLim)/2;
if (x2 <= xFirst || xLim <= x1)
return fFalse;
if (x1 <= xMid && xMid < x2)
*pxMid = xMid;
else if (x1 > xMid)
*pxMid = x1;
else
*pxMid = x2-1;
return fTrue;
}
// find the rightmost set bit in the specified row of the bitmap
static int _XFirstBit(const BitMap &bitmap, int y)
{
int x;
for (x = bitmap.bounds.right-1; x >= bitmap.bounds.left; --x)
if (_FGetBit(bitmap, x, y))
break;
return x;
}
// MusecFromTime omitted for brevity```

Community Search:
MacTech Search:

Spotify 1.2.0.1165 - Stream music, creat...
Spotify is a streaming music service that gives you on-demand access to millions of songs. Whether you like driving rock, silky R&B, or grandiose classical music, Spotify's massive catalogue puts... Read more
Thunderbird 102.5.1 - Email client from...
As of July 2012, Thunderbird has transitioned to a new governance model, with new features being developed by the broader free software and open source community, and security fixes and improvements... Read more
Pinegrow 7.03 - Mockup and design web pa...
Pinegrow (was Pinegrow Web Designer) is desktop app that lets you mockup and design webpages faster with multi-page editing, CSS and LESS styling, and smart components for Bootstrap, Foundation,... Read more
Adobe After Effects 2022 23.1 - Create p...
The new, more connected Adobe After Effects can make the impossible possible. Get powerful new features like a Live 3D Pipeline that brings CINEMA 4D scenes in as layers - without intermediate... Read more
SteerMouse 5.6.7 - Powerful third-party...
SteerMouse is an advanced driver for USB and Bluetooth mice. SteerMouse can assign various functions to buttons that Apple's software does not allow, including double-clicks, modifier clicks,... Read more
Wireshark 4.0.2 - Network protocol analy...
Wireshark is one of the world's foremost network protocol analyzers, and is the standard in many parts of the industry. It is the continuation of a project that started in 1998. Hundreds of... Read more
Adobe Premiere Pro 2022 23.1 - Digital v...
Adobe Premiere Pro is available as part of Adobe Creative Cloud for as little as \$54.99/month. The price on display is a price for annual by-monthly plan for Adobe Premiere Pro only. Adobe Premiere... Read more
1Password is a password manager that uniquely brings you both security and convenience. It is the only program that provides anti-phishing protection and goes beyond password management by adding Web... Read more
FotoMagico 6.3 - Powerful slideshow crea...
FotoMagico lets you create professional slideshows from your photos and music with just a few, simple mouse clicks. It sports a very clean and intuitive yet powerful user interface. High image... Read more
Affinity Photo 1.10.6 - Digital editing...
Affinity Photo - redefines the boundaries for professional photo editing software for the Mac. With a meticulous focus on workflow it offers sophisticated tools for enhancing, editing and retouching... Read more

## Latest Forum Discussions

‘Awaken Legends: Idle RPG’ Celebrates th...
Awaken Legends: Idle RPG is adding its first update since the game was soft-launched in November, letting players get their hands on a new hero “Hera Valen". Players can also look forward to the Covenant of the Dark Knight event and the Wishing Well... | Read more »
‘Horizon Chase 2’ Japan World Tour Expan...
Horizon Chase 2 () from Aquiris is getting a major expansion today on Apple Arcade. The Japan World Tour expansion brings in 11 new races across 9 cities and it should be rolling out now as of this writing. I expect it to be available worldwide... | Read more »
Dark Fantasy Visual Novel ‘The 13th Mont...
Originally announced for release in August, The 13th Month from Japanese developer Kobayashimaru and publisher Kodansha released on PC via Steam worldwide this month. The dark fantasy visual novel that reimagines the classic Sleeping Beauty tale, is... | Read more »
Tom Clancey’s The Divison Resurgence ann...
Ubisoft has announced the latest Live Test dates for Tom Clancy’s The Division Resurgence, the hotly anticipated mobile entry in the Divison series. Starting December 8th and ending on the 22nd, the test will offer a huge amount of content for the... | Read more »
‘Easy Come Easy Golf’ New Update Adds St...
Easy Come Easy Golf () from Clap Hanz is one of my favorite games on Apple Arcade. It has been updated quite a bit since launch bringing in new modes and improvements. It recently launched on Nintendo Switch as well. | Read more »
Out Now: ‘Magic vs Metal’, ‘Suzerain’, ‘...
Each and every day new mobile games are hitting the App Store, and so each week we put together a big old list of all the best new releases of the past seven days. Back in the day the App Store would showcase the same games for a week, and then... | Read more »
Hello gentle readers, and welcome to the SwitchArcade Round-Up for December 7th, 2022. Today can be accurately described as Mikhail Madness, with a whopping four reviews from our pal-est of pals. Football Manager 2023 Touch, Wobbledogs, Soccer Story... | Read more »
Alchemy Stars celebrates 1 and a half ye...
It has been one and a half years since Alchemy Stars launched, and Level Infinite is celebrating in style with a host of new content. There will be a new story mission and even a store to explore, and a whole new mode for those budding idol... | Read more »
Fighting Game ‘Art of Fighting 2’ ACA Ne...
Last week, side-scrolling shooter Pulstar hit mobile platforms as the newest ACA NeoGeo series release from Hamster and SNK. Read Shaun’s review of it here. Today, fighting game Art of Fighting 2 has launched on iOS and Android. Art of Fighting 2... | Read more »
‘Genshin Impact’ Version 3.3 Update Now...
HoYoverse recently revealed the next major update for Genshin Impact (Free) in the form of version 3.3 ‘All Senses Clear, All Existence Void’. | Read more »

## Price Scanner via MacPrices.net

New! Details on Verizon’s Christmas/Holiday p...
Verizon is offering discounts on iPhones, Apple Watch models, and iPads with specific promo codes as part of their Christmas/Holiday 2022 offerings. Codes are valid when adding a new line of service... Read more
Apple MagSafe accessories are back on Holiday...
Amazon has Apple MagSafe Chargers and Apple’s MagSafe Battery on sale for up to 24% off MSRP again as part of their Christmas/Holiday sale. Shipping is free, and all models are in stock: – MagSafe... Read more
13″ M2 MacBook Airs on sale again for the low...
Amazon has 13″ MacBook Airs with M2 CPUs in stock today and on sale for \$150 off MSRP as part of their Christmas/Holiday Sale, prices start at \$1049. Shipping is free. They are the lowest prices... Read more
Get an Apple 16″ MacBook Pro for \$400 off MSR...
16″ MacBook Pros with Apple’s M1 Pro CPUs are in stock and on sale today at B&H Photo for \$300-\$400 off Apple’s MSRP for a limited time. Prices start at \$2099 for M1 Pro models with 512GB or 1TB... Read more
Holiday clearance sale! Previous-generation A...
Amazon has 2nd generation 32GB and 64GB 4K Apple TVs with Siri remotes and 32GB Apple TV HDs on clearance sale for \$80-\$90 off original MSRP. Shipping is free, and delivery is available in time for... Read more
Christmas sale at Verizon: Apple AirPods Pro...
Verizon has first-generation Apple AirPods Pro on sale for \$159.99 on their online store as part of their continuing Christmas/Holiday sale. Their price is \$90 off Apple’s original MSRP, and it’s the... Read more
New Christmas/New Years promo at Xfinity Mobi...
Switch to Xfinity Mobile and open a new line of service, and take \$400 off the price of a new iPhone, no trade-in required, through January 10, 2023. The \$400 is applied to your account as credits... Read more
Apple iPad Smart Keyboard Folio prices drop u...
Apple iPad Smart Keyboard Folio prices have dropped up to \$60 off MSRP at Amazon and Walmart as part of their Christmas/Holiday sales. These are the cheapest prices currently available for these iPad... Read more
Today is the final day for Xfinity Mobile’s \$...
If you switch to Xfinity Mobile and open a new line of service, they will take \$500 off the price of a new iPhone, no trade-in required. This is the best no trade-in Cyber Monday Apple iPhone 14 deal... Read more
Amazon restocks 10.2″ 64GB 9th-generation iPa...
Amazon has Apple’s 9th generation 10.2″ 64GB WiFi iPads (Silver) in stock and on sale for \$269.99 shipped as part of their Christmas/Holiday Sale. Their price is \$60 off Apple’s MSRP. Free delivery... Read more

## Jobs Board

*Apple* Systems Administrator - JAMF - Activ...
…Administration **Duties and Responsibilities** + Configure and maintain the client's Apple Device Management (ADM) solution. The current solution is JAMF supporting Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Sephora Beauty Advisor - *Apple* Blossom Ma...
Sephora Beauty Advisor - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more