-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[STEP 4] π£μ§λ’°μ°ΎκΈ°π₯ 리ν©ν°λ§ #492
base: y2gcoder
Are you sure you want to change the base?
Conversation
β¦ μ μ μ΄ μ μλλ‘ μ²λ¦¬
- open() λ©μλ κ°μν: findAllShouldOpen()μΌλ‘ μ± μ μ΄μ - findAllShouldOpen(): BFSλ₯Ό ν΅ν΄ μ΄μ΄μΌ ν Set<Location> κ³μ° - applyOpen(): Set<Location>μ μΈλ±μ€ κΈ°λ° Set μΌλ‘ λ³κ²½ && κ°λ³ 리μ€νΈλ‘ λ³κ²½ν΄μ κ³μ° ν λΆλ³ 리μ€νΈλ‘ λ°νν¨μΌλ‘μ¨ μ±λ₯ ν₯μ
β¦r μ ꡬν체μ μμ
μ무λλ 리ν©ν°λ§ κ³Όμ μ΄λΌμ, ν¬κ² μ½λ©νΈ λ릴λΆλΆμ΄ μμκ±°κ°μμ :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μλ
νμΈμ μκ·Όλ! μν΄λ³΅ λ§μ΄ λ°μΌμΈμ!
κ°μΈμ μΌλ‘ μ°μ΄μ μΌμ μ΄ λ°μλ€ λ³΄λκΉ νΌλλ°±μ΄ λ¦μλ€μ :)
μ§λ’°μ°ΎκΈ° λ§μ§λ§ λ¨κ³ κ³ μλ§μΌμ
¨μ΅λλ€!
μ½λ©νΈ μ°Έκ³ ν΄μ£ΌμΈμ!
@@ -0,0 +1,13 @@ | |||
package tdd.minesweeper.domain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
κ°μΈμ μΌλ‘ κ°λ
μ±μ μν΄ domain ν¨ν€μ§ λ΄μμλ
κΈ°λ₯ λ±μΌλ‘ λ¬Άμ΄μ ν¨ν€μ§λ₯Ό κ΄λ¦¬ν΄λ΄λ μ’μκ±°κ°μμ :)
cellκ΄λ ¨ κ°μ²΄λ₯Ό λͺ¨μ보λ건 μ΄λ¨κΉμ?
val adjacentMines: AdjacentMines? | ||
|
||
fun isOpen(): Boolean | ||
|
||
fun hasMine(): Boolean | ||
|
||
fun open(): Cell | ||
|
||
fun isExpandableToAdjacent(): Boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cellμ μΈν°νμ΄μ€ λ‘ λΆλ¦¬νμ
§λ€μ!
MineCellμμλ adjacentMinesλ null μΌμλ°μ μκ³ ,
open, isExpandableToAdjacent λν ClosedCellμμλ§ νμν ν¨μμ΄κΈ°λν΄μ :)
κ°μ²΄μ§ν₯ μμΉμ€ μΈν°νμ΄μ€ λΆλ¦¬ μμΉμ μ΄κΈλ μλ μλ€λ μκ°μ΄ λ€μ΄μ,
λ μμ λ¨μλ‘ μΈν°νμ΄μ€λ₯Ό λΆλ¦¬ν΄λ³Όμ μμκ±°κ°μμ!
(νμ§λ§ μΈμ λ, trade-off λΉμ©μ΄ λλ건 μ΄μ©μ μμκ±° κ°μμ!
μ€νλ € μ‘°κΈλ 볡μ‘ν΄μ§μ μλ€λ λ¨μ μ΄ μμ΄μ!
볡μ‘νμ§ μκ³ , μΈν°νμ΄μ€λ₯Ό λΆλ¦¬ν μ μλ μ§μ μ μκ·Όλμ κΈ°μ€μΌλ‘ μ‘μ보면 μ΄λ¨κΉμ:) )
import tdd.minesweeper.domain.strategy.DefaultBoardCellsCreator | ||
|
||
@BoardDslMaker | ||
class BoardBuilder(private val boardCellsCreator: BoardCellsCreator = DefaultBoardCellsCreator()) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dsl νμ© π
class DefaultShouldOpenLocationFinder : ShouldOpenLocationFinder { | ||
override fun findAllShouldOpen( | ||
board: Board, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Boardμ openμμ μ°κ΄λ Cell κ΄λ ¨ λΆλΆμ λΆλ¦¬ν΄ μ£Όμ
¨λ€μ π
Boardμμλ ShouldOpenLocationFinderλ₯Ό μμ‘΄νκ³ μκ³ ,
ShouldOpenLocationFinderμμλ Boardλ₯Ό μμ‘΄νκ³ μμ΄μ :)
Boardμ ShouldOpenLocationFinderλ κ²°ν©λκ° λλ€κ³ λ³Όμλ μμκ±° κ°μμ :)
μλ°©ν₯ μμ‘΄μ±μ κ°λ
μ± μΈ‘λ©΄μ΄λ, μ μ§λ³΄μ μΈ‘λ©΄μμ μ΄λ €μΈμ μμ΄μ
boardκ° μλ Cellsλ₯Ό λ°μμ μ²λ¦¬νλλ‘ μμ ν μ μμκ±° κ°μμ
val allLocations = createAllLocations(area) | ||
|
||
// μ§λ’° μμΉ κ΅¬νκΈ° | ||
val mineLocations = calculateMineLocations(allLocations, inputManualMineLocations, countOfMines) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
calculateMineLocationsλ λΆλ¦¬ν΄λ³Όμ μμ§ μμκΉμ?
DefaultBoardCellsCreatorμ κ΄μ¬μ¬λ MineLocations μΌκ±°κ°μμ
MineLocationsμ΄ inputManualμΈμ§, λλ€ locationμΈμ§λ λͺ°λΌλ
Cellsμ λ§λλλ° μν₯μ΄ μμ§λ μμκΉμ?
val closedCells = createMinePlantedCells(allLocations, mineLocations) | ||
|
||
// μ§λ’° μΈμ μμΉ νμ | ||
val updatedCells = markOfAdjacentMines(closedCells, allLocations, mineLocations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μ΄λ―Έ closedCellsμλ allLocations, mineLocationsμ λν μ λ³΄κ° μμ§ μλμ?
μ§λ’° μΈμ μμΉ νμ κΈ°λ₯μ 3κ°μ 리μ€νΈκ° νμν κΉμ? :)
import io.kotest.core.spec.style.BehaviorSpec | ||
import io.kotest.matchers.shouldBe | ||
|
||
class AdjacentMinesTest : BehaviorSpec({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
μλ‘κ² TDDλ‘ λ€μνλ² μμ±νμ λΆλΆμ μ΄λ μ ¨λμ?
μ λ TDDλ₯Ό μ²μ λμ
νλ€λ³΄λ©΄ μ무λλ μ²μ μμ±ν ν
μ€νΈμΌμ΄μ€μλν ν
μ€νΈ μ½λλ₯Ό λ¨Όμ μμ±νκ³ ,
μ΄μ λ§μ‘±νκΈ°μν΄ κ΅¬ννλ€λ³΄λ, μ€κ³κ° μ΄κΈλκ±°λ κΌ¬μ¬μ, μ΄λ €μ λ κΈ°μ΅μ΄ λλ€μ,
μλ‘ νλ² μμ±νκ²λλ κΈ°μ‘΄μ μ΄λμ λ λλ©μΈκ³Ό μ€κ³μ λν κΈ°λ°μ΄ μμ¬μ
μ‘°κΈλ μμ°μ€λ½κ² TDDλ₯Ό ν μ μμλκ±° κ°μμ :)
λ¨μ¬λ μν΄ λ³΅ λ§μ΄ λ°μΌμμΌ :) μμ κΈ°λλ₯Ό μ λ²λ¦¬μ§ μκ³ μμ§μ μ½λ©νΈλ₯Ό λ¨κ²¨μ£Όμ ¨κ΅°μ... κ°μ¬ν©λλ€π λ§μ§λ§ νΌλλ°±μ λ¨Έμ§ν΄μ£Όμλ©΄ ν¬ν¬ν μ λ ν¬μμ κ°μΈμ μΌλ‘ λ°μν΄λ³΄κ² μ΄λ€! λ²μ¨ μ½μ€κ° λλ μ§λ ν λ¬μ΄ λ€ λμ΄ κ°λλ° λ¨μ¬λμ κ³μ λΆμ‘μλλ κ² κ°μ μ£μ‘ν©λλ€π₯Ή κ·Έλμ μ§μ λΆν μ μ½λ λ΄μ£Όμ μ λ무 κ°μ¬νμ΅λλ€! λ¨μ¬λκ» λ°°μ΄ κ² κΉλ¨Ήμ§ μκ³ κ³μ μ¬μ©ν΄μ μ’μ μ½λλ₯Ό μμ±νκΈ° μν΄ λ Έλ ₯νκ² μ΅λλ€ π |
μλ νμΈμ λ¨μ€λ!
μ€λλ§μ μΈμ¬λλ¦¬κ² λμμ΅λλ€π
ν¬λ¦¬μ€λ§μ€λ μ 보λ΄μ ¨λμ§μ?π
λ§μ§λ§ λ¨κ³λ€ 보λ κ·Έλμ λ°°μ λ κ±Έ μ μ©ν΄λ³΄κ³ μ λ Έλ ₯νμ΅λλ€!
νμ μμ§μ νΌλλ°± μ£Όμλ λ¨μ€λκ» κ°μ¬λ립λλ€π
ν¬κΈ°νμ§ μκ³ λ§λ¬΄λ¦¬κΉμ§ μ΄μ¬ν ν΄λ³΄κ² μ΅λλ€!
κ°μ¬ν©λλ€
μμκ·Ό μ¬λ¦Ό