[๐ ์ฌ์ดํด2 - ๋ฏธ์ (๋ธ๋์ญ ๋ฒ ํ )] ์ด์ ๋ฏธ์ ์ ์ถํฉ๋๋ค.#1096
[๐ ์ฌ์ดํด2 - ๋ฏธ์
(๋ธ๋์ญ ๋ฒ ํ
)] ์ด์ ๋ฏธ์
์ ์ถํฉ๋๋ค.#1096Eian1106 wants to merge 20 commits intowoowacourse:eian1106from
Conversation
Chocochip101
left a comment
There was a problem hiding this comment.
์๋
ํ์ธ์, ์ด์! ๋ฆฌ๋ทฐ์ด ์ด์ฝ์นฉ์
๋๋ค ๐ช
ํผ๋๋ฐฑ๊ณผ ๋ณ๊ฒฝ์ ์ด ๋ง์์ ธ์ ๋๋ ์ ๋ฆฌ๋ทฐํ๊ฒ ์ต๋๋ค.
์ปค๋งจํธ๋ก ๋ฆฌ๋ทฐ ๋จ๊ฒผ์ผ๋ ํ์ธ ํ ์ฌ์์ฒญ์ฃผ์ธ์~
๊ทธ๋ฆฌ๊ณ ์ฌ์ดํด1 ๋ง๋ฌด๋ฆฌ์ ๋จ๊ธด ๋ฆฌ๋ทฐ๋ ๋ฐ์ํด์ฃผ์ธ์!
|
|
||
| for (Map.Entry<String, WinStatus> playerWinStatus : playerGroups.getGameResult().entrySet()) { | ||
| String userName = playerWinStatus.getKey(); | ||
| int userCost = (int) (userBetInfo.get(userName) * playerWinStatus.getValue().getEarningsRate()); |
There was a problem hiding this comment.
int๋ก ํ๋ณํํ๋ฉด ์์์ ์ ์ ๋ถ ์๋ฆฌ๊ฒ ๊ตฐ์.
|
|
||
| private Map<String, Integer> bettingRound() { | ||
| List<Player> players = gameService.getPlayers(); | ||
| Map<String, Integer> userBetCost = new HashMap<>(); |
There was a problem hiding this comment.
์๋ฃํ๋ณด๋ค๋ ๊ฐ์ฒด๋ก ํํํ๋ ๊ฒ์ ์ด๋ค๊ฐ์?
| public void run() { | ||
| startGame(); | ||
|
|
||
| Map<String, Integer> userBetInfo = bettingRound(); |
There was a problem hiding this comment.
๊ธ์ก์ด ์์๋ ๊ฐ๋ฅํ๋ค์. ๋ฐฐํ ๊ธ์ก์๋ ํ์ํ ๊ฒ์ฆ ๋ก์ง์ด ํ์ํด๋ณด์ด๋ค์.
There was a problem hiding this comment.
๋ฐฐํ ๊ธ์ก๋ ์์ ํ์ ์ด ์๋ ๊ฐ์ฒด๋ก ๊ด๋ฆฌํ ์ ์์๊น์?
| return playerGroups.getGameResult(); | ||
| } | ||
|
|
||
| public List<ParticipantBetResult> bettingResult(Map<String, Integer> userBetInfo) { |
There was a problem hiding this comment.
๋ฐฐํ ๊ด๋ จ ํ ์คํธ๊ฐ ์์ด์. ๋ธ๋์ญ์ผ ๋์ ๊ธ์ก ๋ก์ง, ๋๋ฌ๊ฐ ์ก์ ๋ ๋์ ์๋์ง ๋ฑ๋ฑ์ด์. ๋ง์ ํ ์คํธ ์ผ์ด์ค๊ฐ ์์ ๊ฒ ๊ฐ์์.
๋ชจ๋ ์ ์ฆ ์ผ์ด์ค ํ ์คํธ๋ก ๊ฒ์ฆ๋๋๋ก ์ถ๊ฐํด์ฃผ์ธ์.
|
|
||
| public List<ParticipantBetResult> bettingResult(Map<String, Integer> userBetInfo) { | ||
| List<ParticipantBetResult> profitResults = new ArrayList<>(); | ||
| int dealerCost = 0; |
There was a problem hiding this comment.
dealerCost๋ ์๋น์ค๊ฐ ๊ด๋ฆฌํ๊ณ ์๋ค์. dealer๋ ๊ธ์ก์ด ์๊ณ , participant๋ ๊ธ์ก์ด ์๋๋ฐ ๊ตณ์ด ์๋น์ค๊ฐ ๊ด๋ฆฌํ ํ์๊ฐ ์์๊น์?
ํญ์ ์ข์ ํผ๋๋ฐฑ ๊ฐ์ฌํฉ๋๋ค ์ด์ฝ์นฉ! ๐ |
Chocochip101
left a comment
There was a problem hiding this comment.
์๋
ํ์ธ์, ์ด์!
์ฌ์ดํด 1์ ํผ๋๋ฐฑ์ ์ ์์ ํด์ฃผ์
จ๋ค์ ๐๐ป
๋ณ๊ฒฝํด์ฃผ์ ์ ๋ค์ ๋ํด ์ปค๋งจํธ๋ก ํผ๋๋ฐฑ ๋จ๊ฒผ์ผ๋ ํ์ธํด์ฃผ์ธ์!
|
|
||
| import java.util.List; | ||
|
|
||
| public class NoShuffleStrategy implements ShuffleStrategy { |
There was a problem hiding this comment.
ํ ์คํธ์์๋ง ์ฐ์ด๋๋ฐ, ํ ์คํธ ํจํค์ง๋ก ์ฎ๊ฒจ๋ณด๋๊ฑด ์ด๋จ๊น์?
| public class RandomShuffleStrategy implements ShuffleStrategy { | ||
|
|
||
| @Override | ||
| public void shuffle(List<Card> cards) { |
There was a problem hiding this comment.
์ธ์๋ก ๋ค์ด์จ cards๊ฐ immutableํ ์๋ฃํ์ด๋ผ๋ฉด ์ด๋ค ์ผ์ด ๋ฐ์ํ ๊น์? ๋ํ ์๋ณธ cards๊ฐ ์์ด๊ณ ๋ ํ์ ๋ณ๊ฒฝ์ด ์กด์ฌํ ๊น์? ๊ทธ๋ ์ง ์๋ค๋ฉด ๋ฐฉ์ด์ ๋ณต์ฌ๋ก void๊ฐ ์๋ immutableํ ๋๋ค List<Card>๋ฅผ ๋ฐํํด๋ ๋์ง ์์๊น์?
| return value.getFirst(); | ||
| } | ||
|
|
||
| public int getUpgradeValue() { |
There was a problem hiding this comment.
์์๋ก ACE์ ๊ฐ์ 1 ๋๋ 11 ์ฌ๋ถ๋ฅผ ๊ฒฐ์ ํ๋ค์. ๋ง์ฝ ๋๊ตฐ๊ฐ๊ฐ ACE("A", List.of(11, 1)),๋ก ๋ฐ๊ฟ์ ๋ฐฐํฌํ๋ฉด ๋ฐ๋ก ์๋น์ค์ ์ฅ์ ๊ฐ ๋ ์๋ ์๊ฒ ๋ค์ ๐จ
There was a problem hiding this comment.
'Upgrade'๋ณด๋ค๋ isConvertibleTo ๊ฐ์ ๋ฉ์๋ ๋ช
์ ์ด๋ ์ ์ง์ ใ
ใ
|
|
||
| private boolean canPlusBonusScore(int sum) { | ||
| return containsAce() && sum + ACE_BONUS_SCORE <= MAX_SCORE; | ||
| public int quantity() { |
There was a problem hiding this comment.
๋ฉ์๋๋ ๋์ฌํ์ผ๋ก ๋ฐ๊พธ๋๊ฑด ์ด๋จ๊น์?
| for (TrumpSuit suit : TrumpSuit.values()) { | ||
| for (TrumpNumber number : TrumpNumber.values()) { | ||
| cards.add(new Card(suit, number)); | ||
| } | ||
| } |
There was a problem hiding this comment.
์ธ๋ดํธ๊ฐ 2๋ค์. ๋ถ๋ฆฌํด๋ณผ๊น์?
| } | ||
|
|
||
| private void validateRange(int cost) { | ||
| if (cost > MAX_COST || cost < MIN_COST) { |
There was a problem hiding this comment.
์ ๋ Bigdecimal์ด๋ double๋ก ์์์ ์ ์ฑ๊ธฐ๋ ๋ฐฉ์์ผ๋ก ์ ๊ทผํ๋๋ฐ, ๋๋ฉ์ธ ์ ์ฝ์ผ๋ก ํด๊ฒฐํ๋ ๊ฒ๋ ํ๋ฅญํ๋ค์ ๐๐ป ์์ธ ์ฒ๋ฆฌ๋ ์ข์ต๋๋ค!
| for (Map.Entry<String, WinStatus> playerWinStatus : playerGroups.getGameResult().entrySet()) { | ||
| String userName = playerWinStatus.getKey(); | ||
| int userCost = (int) (userBetInfo.get(userName) * playerWinStatus.getValue().getEarningsRate()); | ||
| int userCost = (int) (userBetInfo.get(userName).getCost() * playerWinStatus.getValue().getEarningsRate()); |
There was a problem hiding this comment.
int ํ๋ณํ ๋๋ฌธ์ 100๋จ์๋ก ๋ฐ๋๋ค๋ ๊ฒ์ ๋ชจ๋ฅด๋ ๋๊ตฐ๊ฐ๋ ์ด ์ฝ๋๋ง์ ๋ณด๊ณ ์คํดํ ์๋ ์์ ๊ฒ ๊ฐ์์.
ํด๋น ๋ก์ง์ ์๋น์ค๊ฐ ์๋ ๋๋ฉ์ธ์ผ๋ก ์ฎ๊ธธ ์ ์์๊น์? (int๋ก 100๋จ์๋ก ๋ค๋ฃจ๊ธฐํ๊ฒ ์ ํฌ ๋๋ฉ์ธ ๊ท์น์ด ๋์์ผ๋๊น์) ๊ธฐ์กด ๋๋ฉ์ธ์ ์ฎ๊ธฐ๊ธฐ ํ๋ค๋ค๋ฉด ์๋ก์ด ์ผ๊ธ ์ปฌ๋ ์ ๋ง๋ค์ด๋ ๋๊ฒ ๋ค์.
| @@ -7,6 +7,7 @@ | |||
|
|
|||
| public class Participant { | |||
There was a problem hiding this comment.
ํ๋ก๊ทธ๋๋ฐ ์๊ตฌ ์ฌํญ์ธ 3๊ฐ ์ด์์ ์ธ์คํด์ค ๋ณ์๋ฅผ ๊ฐ์ง ํด๋์ค๋ฅผ ์ฐ์ง ์๋๋ค. ๊ฐ ์๋์๋ค๋ฉด participant๊ฐ ๊ด๋ฆฌํ๋๋ก ํ ๊ฒ ๊ฐ์ต๋๋ค
๋ง์ต๋๋ค. name, handCards, cost๋ฅผ ๋ชจ๋ ๋ฃ์ผ๋ฉด 3๊ฐ๊ฐ ๋์ด ์ ์ฝ์ ์ด๊ธฐ๊ฒ ๋๋ค์! ํ์ง๋ง ์ด ์ ์ฝ์ ํต์ฌ ์๋๋ '๋ก์ง์ ์๋น์ค๋ก ๋ฐ์ด๋ด๋ผ'๋ ๊ฒ์ด ์๋๋ผ, '๊ฐ์ฒด๋ฅผ ๋ ์๊ณ ์๋ฏธ์๋ ๋จ์๋ก ์ชผ๊ฐ๋ผ'๋ ๊ฒ์ผ๋ก ์ดํดํ๊ณ ์์ด์.
์ ํฌ๋ ์๊ตฌ์ฌํญ์ ๋ง์กฑํด์ผํ๋, HandCards์ Cost๋ฅผ ๋ฌถ๋ ์๋ก์ด ๊ฐ์ฒด(์: PlayerStatus)๋ฅผ ๋์
ํ๋ค๋ฉด, ๊ฐ ๊ฐ์ฒด๋ ๋ณ์๋ฅผ 2๊ฐ ์ดํ๋ก ์ ์งํ๋ฉด์๋ '์์ ์ ์์ต์ ์ค์ค๋ก ๊ณ์ฐํ๋ ๋ก์ง'์ ๊ฐ์ง ์ ์๊ฒ ๋๊ฒ ๋ค์!
์๋น์ค๋ ๊ทธ์ ์ด ๊ฐ์ฒด๋ค์๊ฒ ๋ฉ์์ง๋ง ๋์ง๋ฉด ๋๊ณ ์. ์ด๋ ๊ฒ ๋ฆฌํฉํ ๋งํด๋ณด๋ฉด ์ด๋จ๊น์?
public class Participant {
private final Name name;
private final PlayerStatus status;
...
}
public class PlayerStatus {
private final HandCards handCards;
private final Cost cost;
public int calculateProfit(WinStatus winStatus) {
... // ์ด๋ค ์๋ฌด๊ฐ ๋ก์ง...
}
}
์ฒดํฌ ๋ฆฌ์คํธ
test๋ฅผ ์คํํ์ ๋, ๋ชจ๋ ํ ์คํธ๊ฐ ์ ์์ ์ผ๋ก ํต๊ณผํ๋์?์ด๋ค ๋ถ๋ถ์ ์ง์คํ์ฌ ๋ฆฌ๋ทฐํด์ผ ํ ๊น์?
๊ธ์์ผ ํผ๋๋ฐฑ ํ๋์ธ
๋ณ๊ฒฝ ๋ฒ์ ๋น๊ต: ์ฌ์ดํด1 vs ์ฌ์ดํด2์ ์ฐ์ ์ ์ผ๋ก ํ์ธํ๊ณ ์ถ์๊ธฐ ๋๋ฌธ์ ๋๋ค.Controller์์ ์น๋ฌดํจ ๋ก์ง์ ์๋์ ์ผ๋ก ์ฃผ์์ฒ๋ฆฌ ํ์ต๋๋ค.
์ง๊ธ์ ์ฌ๋ฌ๊ฐ์ง ์ง๋ฌธ์ ์กฐ๊ธ ํ๊ณ ์ถ์ต๋๋ค..
์ด์ฝ์นฉ์ ์๊ฐ์ด ๊ถ๊ธํด์!
๋ฉ์๋๋ช ๊ณผ ๋ณ์๋ช ์ ์ง๋ ๊ฒ ์ด๋ ต์ต๋๋ค.
AI๋ฅผ ์ฌ์ฉํ์ง ์๊ณ ํด๋ณด๋ ค ๋ ธ๋ ฅ์ค์ ๋๋ค. ํ์ง๋ง ๋ฉ์๋๋ช ๊ณผ ๋ณ์๋ช ์์ฑ์ ์ถํ ๋๋ฅผ ์ํด์๋, ๋ด ์ฝ๋๋ฅผ ๋ณด๋ ๋ชจ๋ ์ด๋ค์ ์ํด ์ ์ง์ด์ผ ํ๋ค๊ณ ์๊ฐํฉ๋๋ค. ์ง๊ธ์ ๊ตฌ๊ธ ๋ฒ์ญ๊ธฐ๋ ๋จ์ด ๊ฒ์์ ํตํด ์์ฑํ๊ณค ํฉ๋๋ค..
Q) ๋ค์ด๋ฐ ๊ฐ์ ๊ฒฝ์ฐ๋ AI๋ฅผ ์ฌ์ฉํด๋ ๋ฌด๋ฐฉํ ๊น์?
๋ธ๋์ญ ์๋ฃ ํ ์ด๋ค ๊ณต๋ถ๋ฅผ ํ๋ฉด ์ข์๊น์?
๋ค๋ฅธ ํฌ๋ฃจ์ ์ฝ๋์ ๋น๊ตํด๋ณด๋ฉด ์ ์ฝ๋๋ ์ ๋๋์ง ์์ ๋๋์ ๋๋ค. ๋ ธ๋ ฅ์ ํ๋ค๊ณ ์์ ํ ์ ์์ผ๋, ๊ฒฐ๊ณผ๋ฌผ์ ๐ค ..
๊ทธ๋์
์ข์ ์ฝ๋, ๋์ ์ฝ๋๋ฅผ ์ฝ์ด๋ณผ๊น ์ถ๊ธฐ๋ ํฉ๋๋ค. ๋ชจ๋ ๊ณต๋ถ๋ ์งํ ํ ์์ ์ด์ง๋ง ๊ณต๋ถ ์์์ ๊ณ ๋ฏผ์ด ์๊น๋๋ค.๊ฐ์ฒด์งํฅ์ ์ฌ์ค๊ณผ ์คํด๋ ์ฝ์ด๋ณด์์ผ๋ ์ฒดํ ํ๊ธฐ์ ๋ถ์กฑํ๋ ๊ฒ ๊ฐ์ต๋๋ค. ๊ณ ๋ฏผ์ค์ธ ๋์(๊ณต๋ถ) ํ๋ณด๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.ํด์ผ ํ ๊ณต๋ถ๋ ๋ง์ง๋ง, ๋ฐฉํฅ์ฑ์ ๋ํด์ ๊ฐํผ๋ฅผ ๋ชป ์ก๊ณ ์๋ ๊ฒ ๊ฐ์ต๋๋ค!.. ์กฐ์ธ ํด์ฃผ์ค ์ ์์๊น์?