[{"data":1,"prerenderedAt":440},["ShallowReactive",2],{"portfolio-detail-minesweepercli":3},{"id":4,"title":5,"body":6,"dateEnd":424,"dateStart":424,"description":425,"extension":426,"image":427,"meta":428,"navigation":429,"path":430,"repository":431,"seo":432,"stem":433,"tags":434,"type":438,"__hash__":439},"content\u002Fportfolio\u002Fminesweepercli.md","MinesweeperCLI",{"type":7,"value":8,"toc":414},"minimark",[9,14,33,36,39,43,71,73,77,80,91,96,99,113,307,311,314,316,320,393,395,399,410],[10,11,13],"h2",{"id":12},"overview","Overview",[15,16,17,20,21,24,25,28,29,32],"p",{},[18,19,5],"strong",{}," is a terminal recreation of the classic puzzle game ",[18,22,23],{},"Minesweeper",", developed entirely in ",[18,26,27],{},"Java"," without third-party frameworks. In addition to standard player-controlled gameplay, it includes an ",[18,30,31],{},"algorithmic solver bot"," capable of computing probabilistic moves and clearing boards autonomously.",[15,34,35],{},"The goal of the project was to exercise strict object-oriented architecture, algorithmic problem solving (constraint satisfaction), and terminal visualization using ANSI escape sequences.",[37,38],"hr",{},[10,40,42],{"id":41},"game-rules-features","Game Rules & Features",[44,45,46,53,59,65],"ul",{},[47,48,49,52],"li",{},[18,50,51],{},"Grid Customization",": Configurable board dimensions (e.g., 9x9 Beginner, 16x16 Intermediate, 30x16 Expert, and custom dimensions) with user-defined mine quantities.",[47,54,55,58],{},[18,56,57],{},"First-Move Guarantee",": The initial revealed cell is guaranteed to never be a mine; the minefield layout is generated dynamically after the player's first input.",[47,60,61,64],{},[18,62,63],{},"Recursive Zero-Expansion",": Revealing a cell with zero adjacent mines triggers a recursive flood-fill algorithm that automatically uncovers neighboring safe cells.",[47,66,67,70],{},[18,68,69],{},"ANSI Color Output",": Clean, formatted terminal display with color-coded adjacency numbers and status indicators.",[37,72],{},[10,74,76],{"id":75},"the-solver-bot-algorithm","The Solver Bot Algorithm",[15,78,79],{},"The integrated bot operates via a two-tier algorithmic evaluation cycle:",[81,82,87],"pre",{"className":83,"code":85,"language":86},[84],"language-text","Solver Loop\n   │\n   ▼\n[Check Deterministic Moves]\n   ├─ If remaining hidden neighbors == unflagged mines ➔ Flag all\n   └─ If remaining flags == cell number ➔ Reveal all remaining neighbors\n   │\n   ▼ (No deterministic moves found)\n[Probabilistic Analysis]\n   ├─ Build system of linear equations across connected frontier tiles\n   ├─ Calculate exact probability distribution for each candidate tile\n   └─ Choose cell with minimum mine likelihood (safest guess)\n","text",[88,89,85],"code",{"__ignoreMap":90},"",[92,93,95],"h3",{"id":94},"_1-deterministic-rule-matching","1. Deterministic Rule Matching",[15,97,98],{},"The solver continuously scans active frontier cells (uncovered cells adjacent to covered cells) to apply classic logical deductions:",[44,100,101,107],{},[47,102,103,106],{},[18,104,105],{},"All Mines",": If an uncovered number equals the exact count of unflagged hidden neighbors, every neighbor is flagged.",[47,108,109,112],{},[18,110,111],{},"All Safe",": If an uncovered number already has all required flags placed around it, all other neighbors are safely revealed.",[81,114,118],{"className":115,"code":116,"language":117,"meta":90,"style":90},"language-java shiki shiki-themes github-dark github-dark","\u002F\u002F Check deterministic safe moves based on active frontier constraints\npublic List\u003CCell> findDeterministicMoves(Board board) {\n    List\u003CCell> safeMoves = new ArrayList\u003C>();\n    for (Cell cell : board.getFrontierCells()) {\n        if (cell.getRemainingHiddenNeighbors() == cell.getAdjacentMines()) {\n            cell.flagAllHiddenNeighbors();\n        } else if (cell.getPlacedFlags() == cell.getAdjacentMines()) {\n            safeMoves.addAll(cell.getUnflaggedHiddenNeighbors());\n        }\n    }\n    return safeMoves;\n}\n","java",[88,119,120,129,156,176,197,223,235,262,280,286,292,301],{"__ignoreMap":90},[121,122,125],"span",{"class":123,"line":124},"line",1,[121,126,128],{"class":127},"sJ8bj","\u002F\u002F Check deterministic safe moves based on active frontier constraints\n",[121,130,132,136,140,143,146,149,153],{"class":123,"line":131},2,[121,133,135],{"class":134},"sOPea","public",[121,137,139],{"class":138},"suv1-"," List",[121,141,142],{"class":134},"\u003C",[121,144,145],{"class":138},"Cell",[121,147,148],{"class":134},">",[121,150,152],{"class":151},"sFR8T"," findDeterministicMoves",[121,154,155],{"class":138},"(Board board) {\n",[121,157,159,162,164,167,170,173],{"class":123,"line":158},3,[121,160,161],{"class":138},"    List\u003C",[121,163,145],{"class":134},[121,165,166],{"class":138},"> safeMoves ",[121,168,169],{"class":134},"=",[121,171,172],{"class":134}," new",[121,174,175],{"class":138}," ArrayList\u003C>();\n",[121,177,179,182,185,188,191,194],{"class":123,"line":178},4,[121,180,181],{"class":134},"    for",[121,183,184],{"class":138}," (Cell cell ",[121,186,187],{"class":134},":",[121,189,190],{"class":138}," board.",[121,192,193],{"class":151},"getFrontierCells",[121,195,196],{"class":138},"()) {\n",[121,198,200,203,206,209,212,215,218,221],{"class":123,"line":199},5,[121,201,202],{"class":134},"        if",[121,204,205],{"class":138}," (cell.",[121,207,208],{"class":151},"getRemainingHiddenNeighbors",[121,210,211],{"class":138},"() ",[121,213,214],{"class":134},"==",[121,216,217],{"class":138}," cell.",[121,219,220],{"class":151},"getAdjacentMines",[121,222,196],{"class":138},[121,224,226,229,232],{"class":123,"line":225},6,[121,227,228],{"class":138},"            cell.",[121,230,231],{"class":151},"flagAllHiddenNeighbors",[121,233,234],{"class":138},"();\n",[121,236,238,241,244,247,249,252,254,256,258,260],{"class":123,"line":237},7,[121,239,240],{"class":138},"        } ",[121,242,243],{"class":134},"else",[121,245,246],{"class":134}," if",[121,248,205],{"class":138},[121,250,251],{"class":151},"getPlacedFlags",[121,253,211],{"class":138},[121,255,214],{"class":134},[121,257,217],{"class":138},[121,259,220],{"class":151},[121,261,196],{"class":138},[121,263,265,268,271,274,277],{"class":123,"line":264},8,[121,266,267],{"class":138},"            safeMoves.",[121,269,270],{"class":151},"addAll",[121,272,273],{"class":138},"(cell.",[121,275,276],{"class":151},"getUnflaggedHiddenNeighbors",[121,278,279],{"class":138},"());\n",[121,281,283],{"class":123,"line":282},9,[121,284,285],{"class":138},"        }\n",[121,287,289],{"class":123,"line":288},10,[121,290,291],{"class":138},"    }\n",[121,293,295,298],{"class":123,"line":294},11,[121,296,297],{"class":134},"    return",[121,299,300],{"class":138}," safeMoves;\n",[121,302,304],{"class":123,"line":303},12,[121,305,306],{"class":138},"}\n",[92,308,310],{"id":309},"_2-constraint-satisfaction-probabilities","2. Constraint Satisfaction & Probabilities",[15,312,313],{},"When no trivial moves remain, the bot clusters active frontier cells into independent mathematical sub-problems. It enumerates valid mine assignments to compute exact probability percentages for each frontier cell, executing the move with the lowest statistical risk.",[37,315],{},[10,317,319],{"id":318},"system-architecture","System Architecture",[321,322,323,337],"table",{},[324,325,326],"thead",{},[327,328,329,334],"tr",{},[330,331,333],"th",{"align":332},"left","Class",[330,335,336],{"align":332},"Responsibility",[338,339,340,354,363,373,383],"tbody",{},[327,341,342,348],{},[343,344,345],"td",{"align":332},[88,346,347],{},"Board",[343,349,350,351,353],{"align":332},"Maintains the 2D matrix of ",[88,352,145],{}," objects and validates coordinate boundaries.",[327,355,356,360],{},[343,357,358],{"align":332},[88,359,145],{},[343,361,362],{"align":332},"Encapsulates state (hidden, flagged, revealed), mine presence, and adjacent mine counts.",[327,364,365,370],{},[343,366,367],{"align":332},[88,368,369],{},"GameEngine",[343,371,372],{"align":332},"Controls game loop, input parsing, timer tracking, and victory\u002Fdefeat conditions.",[327,374,375,380],{},[343,376,377],{"align":332},[88,378,379],{},"MinesweeperBot",[343,381,382],{"align":332},"Analyzes frontier states, constructs constraint models, and issues optimal moves.",[327,384,385,390],{},[343,386,387],{"align":332},[88,388,389],{},"TerminalRenderer",[343,391,392],{"align":332},"Renders the game board with ANSI colors and formatted column\u002Frow coordinates.",[37,394],{},[10,396,398],{"id":397},"key-takeaways","Key Takeaways",[44,400,401,404,407],{},[47,402,403],{},"In-depth practical implementation of recursive flood-fill and graph traversal algorithms.",[47,405,406],{},"Applied constraint satisfaction problem (CSP) modeling to turn-based game solving.",[47,408,409],{},"Zero external library dependencies, compiling and running natively in any modern terminal.",[411,412,413],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .sOPea, html code.shiki .sOPea{--shiki-default:#F97583;--shiki-dark:#F97583}html pre.shiki code .suv1-, html code.shiki .suv1-{--shiki-default:#E1E4E8;--shiki-dark:#E1E4E8}html pre.shiki code .sFR8T, html code.shiki .sFR8T{--shiki-default:#B392F0;--shiki-dark:#B392F0}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":90,"searchDepth":131,"depth":131,"links":415},[416,417,418,422,423],{"id":12,"depth":131,"text":13},{"id":41,"depth":131,"text":42},{"id":75,"depth":131,"text":76,"children":419},[420,421],{"id":94,"depth":158,"text":95},{"id":309,"depth":158,"text":310},{"id":318,"depth":131,"text":319},{"id":397,"depth":131,"text":398},"09\u002F2025","Terminal-based Minesweeper game and automated probability solver bot implemented in Java.","md","minesweeper.png",{},true,"\u002Fportfolio\u002Fminesweepercli","https:\u002F\u002Fgithub.com\u002FRaskieL\u002FMinesweeperCLI",{"title":5,"description":425},"portfolio\u002Fminesweepercli",[117,435,436,437],"bot","cli","algorithms","Personal","FA7J0whO9RyAHYtsZRDYIoX1bKyv40XsnZc2g8SqzOo",1791735800752]