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:

GraphicConverter 10.5.4 - \$39.95
GraphicConverter is an all-purpose image-editing program that can import 200 different graphic-based formats, edit the image, and export it to any of 80 available file formats. The high-end editing... Read more
Dash 4.1.3 - Instant search and offline...
Dash is an API documentation browser and code snippet manager. Dash helps you store snippets of code, as well as instantly search and browse documentation for almost any API you might use (for a full... Read more
Microsoft OneNote 16.9 - Free digital no...
OneNote is your very own digital notebook. With OneNote, you can capture that flash of genius, that moment of inspiration, or that list of errands that's too important to forget. Whether you're at... Read more
DEVONthink Pro 2.9.17 - Knowledge base,...
Save 10% with our exclusive coupon code: MACUPDATE10 DEVONthink Pro is your essential assistant for today's world, where almost everything is digital. From shopping receipts to important research... Read more
OmniGraffle 7.6 - Create diagrams, flow...
OmniGraffle helps you draw beautiful diagrams, family trees, flow charts, org charts, layouts, and (mathematically speaking) any other directed or non-directed graphs. We've had people use Graffle to... Read more
iFinance 4.3.7 - Comprehensively manage...
iFinance allows you to keep track of your income and spending -- from your lunchbreak coffee to your new car -- in the most convenient and fastest way. Clearly arranged transaction lists of all your... Read more
Opera 50.0.2762.58 - High-performance We...
Opera is a fast and secure browser trusted by millions of users. With the intuitive interface, Speed Dial and visual bookmarks for organizing favorite sites, news feature with fresh, relevant content... Read more
Microsoft Office 2016 16.9 - Popular pro...
Microsoft Office 2016 - Unmistakably Office, designed for Mac. The new versions of Word, Excel, PowerPoint, Outlook and OneNote provide the best of both worlds for Mac users - the familiar Office... Read more
SoftRAID 5.6.4 - High-quality RAID manag...
SoftRAID allows you to create and manage disk arrays to increase performance and reliability. SoftRAID allows the user to create and manage RAID 4 and 5 volumes, RAID 1+0, and RAID 1 (Mirror) and... Read more
OmniGraffle Pro 7.6 - Create diagrams, f...
OmniGraffle Pro helps you draw beautiful diagrams, family trees, flow charts, org charts, layouts, and (mathematically speaking) any other directed or non-directed graphs. We've had people use... Read more

## Latest Forum Discussions

Around the Empire: What have you missed...
Around this time every week we're going to have a look at the comings and goings on the other sites in Steel Media's pocket-gaming empire. We'll round up the very best content you might have missed, so you're always going to be up to date with the... | Read more »
The 7 best games that came out for iPhon...
Well, it's that time of the week. You know what I mean. You know exactly what I mean. It's the time of the week when we take a look at the best games that have landed on the App Store over the past seven days. And there are some real doozies here... | Read more »
Popular MMO Strategy game Lords Mobile i...
Delve into the crowded halls of the Play Store and you’ll find mobile fantasy strategy MMOs-a-plenty. One that’s kicking off the new year in style however is IGG’s Lords Mobile, which has beaten out the fierce competition to receive Google Play’s... | Read more »
Blocky Racing is a funky and fresh new k...
Blocky Racing has zoomed onto the App Store and Google Play this week, bringing with it plenty of classic kart racing shenanigans that will take you straight back to your childhood. If you’ve found yourself hooked on games like Mario Kart or Crash... | Read more »
Cytus II (Games)
Cytus II 1.0.1 Device: iOS Universal Category: Games Price: \$1.99, Version: 1.0.1 (iTunes) Description: "Cytus II" is a music rhythm game created by Rayark Games. It's our fourth rhythm game title, following the footsteps of three... | Read more »
JYDGE (Games)
JYDGE 1.0.0 Device: iOS Universal Category: Games Price: \$4.99, Version: 1.0.0 (iTunes) Description: Build your JYDGE. Enter Edenbyrg. Get out alive. JYDGE is a lawful but awful roguehate top-down shooter where you get to build your... | Read more »
Tako Bubble guide - Tips and Tricks to S...
Tako Bubble is a pretty simple and fun puzzler, but the game can get downright devious with its puzzle design. If you insist on not paying for the game and want to manage your lives appropriately, check out these tips so you can avoid getting... | Read more »
It's fair to say we've spent a good deal of time on Hero Academy 2. So much so, that we think we're probably in a really good place to give you some advice about how to get the most out of the game. And in this guide, that's exactly what you're... | Read more »
In the third part of our Hero Academy 2 guide we're going to take a look at the different modes you can play in the game. We'll explain what you need to do in each of them, and tell you why it's important that you do. [Read more] | Read more »
In this second part of our guide to Hero Academy 2, we're going to have a look at the different card types that you're going to be using in the game. We'll split them up into different sections too, to make sure you're getting the most information... | Read more »

## Price Scanner via MacPrices.net

Deals on clearance 15″ Apple MacBook Pros wit...
B&H Photo has clearance 2016 15″ MacBook Pros available for up to \$800 off original MSRP. Shipping is free, and B&H charges NY & NJ sales tax only: – 15″ 2.7GHz Touch Bar MacBook Pro... Read more
Apple restocked Certified Refurbished 13″ Mac...
Apple has restocked a full line of Certified Refurbished 2017 13″ MacBook Airs starting at \$849. An Apple one-year warranty is included with each MacBook, and shipping is free: – 13″ 1.8GHz/8GB/128GB... Read more
How to find the lowest prices on 2017 Apple M...
Apple has Certified Refurbished 13″ and 15″ 2017 MacBook Pros available for \$200 to \$420 off the cost of new models. Apple’s refurbished prices are the lowest available for each model from any... Read more
The lowest prices anywhere on Apple 12″ MacBo...
Apple has Certified Refurbished 2017 12″ Retina MacBooks available for \$200-\$240 off the cost of new models. Apple will include a standard one-year warranty with each MacBook, and shipping is free.... Read more
Apple now offering a full line of Certified R...
Apple is now offering Certified Refurbished 2017 10″ and 12″ iPad Pros for \$100-\$190 off MSRP, depending on the model. An Apple one-year warranty is included with each model, and shipping is free: –... Read more
27″ iMacs on sale for \$100-\$130 off MSRP, pay...
B&H Photo has 27″ iMacs on sale for \$100-\$130 off MSRP. Shipping is free, and B&H charges sales tax for NY & NJ residents only: – 27″ 3.8GHz iMac (MNED2LL/A): \$2199 \$100 off MSRP – 27″ 3.... Read more
2.8GHz Mac mini on sale for \$899, \$100 off MS...
B&H Photo has the 2.8GHz Mac mini (model number MGEQ2LL/A) on sale for \$899 including free shipping plus NY & NJ sales tax only. Their price is \$100 off MSRP. Read more
Apple offers Certified Refurbished iPad minis...
Apple has Certified Refurbished 128GB iPad minis available today for \$339 including free shipping. Apple’s standard one-year warranty is included. Their price is \$60 off MSRP. Read more
Amazon offers 13″ 256GB MacBook Air for \$1049...
Amazon has the 13″ 1.8GHz/256B #Apple #MacBook Air on sale today for \$150 off MSRP including free shipping: – 13″ 1.8GHz/256GB MacBook Air (MQD42LL/A): \$1049.99, \$150 off MSRP Read more
9.7-inch 2017 WiFi iPads on sale starting at...
B&H Photo has 9.7″ 2017 WiFi #Apple #iPads on sale for \$30 off MSRP for a limited time. Shipping is free, and pay sales tax in NY & NJ only: – 32GB iPad WiFi: \$299, \$30 off – 128GB iPad WiFi... Read more

## Jobs Board

Firmware Engineer - *Apple* Accessories - A...
# Firmware Engineer - Apple Accessories Job Number: 113422485 Santa Clara Valley, California, United States Posted: 18-Jan-2018 Weekly Hours: 40.00 **Job Summary** Read more
*Apple* Retail - Multiple Positions - Apple,...
Job Description: Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
*Apple* Store Leader - Retail District Manag...
Job Description:Job SummaryAs more and more people discover Apple , they visit our retail stores seeking ways to incorporate our products into their lives. It's your Read more
*Apple* Retail - Multiple Positions - Apple,...
Job Description:SalesSpecialist - Retail Customer Service and SalesTransform Apple Store visitors into loyal Apple customers. When customers enter the store, Read more
*Apple* Store Leader - Retail District Manag...
Job Description: Job Summary As more and more people discover Apple , they visit our retail stores seeking ways to incorporate our products into their lives. It's Read more