code cleanup
This commit is contained in:
parent
d2e91d74d5
commit
423be6c01b
1 changed files with 4 additions and 22 deletions
|
@ -71,7 +71,6 @@ namespace Hanabi {
|
||||||
_weighted_draw_pile_size(deck.size()),
|
_weighted_draw_pile_size(deck.size()),
|
||||||
_stacks(),
|
_stacks(),
|
||||||
_hands(),
|
_hands(),
|
||||||
// _card_positions(draw_pile),
|
|
||||||
_draw_pile(),
|
_draw_pile(),
|
||||||
_endgame_turns_left(no_endgame),
|
_endgame_turns_left(no_endgame),
|
||||||
_pace(deck.size() - 5 * num_suits - num_players * (hand_size - 1)),
|
_pace(deck.size() - 5 * num_suits - num_players * (hand_size - 1)),
|
||||||
|
@ -138,16 +137,14 @@ namespace Hanabi {
|
||||||
--_stacks[card.suit];
|
--_stacks[card.suit];
|
||||||
_score++;
|
_score++;
|
||||||
|
|
||||||
BacktrackAction ret{_hands[_turn][index], index, 0};
|
|
||||||
|
|
||||||
if (card.rank == 0 and _num_clues < max_num_clues) {
|
if (card.rank == 0 and _num_clues < max_num_clues) {
|
||||||
// update clues if we played the last card of a stack
|
// update clues if we played the last card of a stack
|
||||||
_num_clues++;
|
_num_clues++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.multiplicity = draw(index);
|
BacktrackAction ret{card, index, draw(index)};
|
||||||
incr_turn();
|
|
||||||
|
|
||||||
|
incr_turn();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,14 +153,13 @@ namespace Hanabi {
|
||||||
ASSERT(index < _hands[_turn].size());
|
ASSERT(index < _hands[_turn].size());
|
||||||
ASSERT(_num_clues != max_num_clues);
|
ASSERT(_num_clues != max_num_clues);
|
||||||
|
|
||||||
|
const Card discarded = _hands[_turn][index];
|
||||||
_num_clues++;
|
_num_clues++;
|
||||||
_pace--;
|
_pace--;
|
||||||
|
|
||||||
BacktrackAction ret{_hands[_turn][index], index};
|
BacktrackAction ret{discarded, index, draw(index)};
|
||||||
|
|
||||||
ret.multiplicity = draw(index);
|
|
||||||
incr_turn();
|
incr_turn();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,9 +201,6 @@ namespace Hanabi {
|
||||||
ASSERT(index < _hands[_turn].size());
|
ASSERT(index < _hands[_turn].size());
|
||||||
|
|
||||||
const Card& discarded = _hands[_turn][index];
|
const Card& discarded = _hands[_turn][index];
|
||||||
if (_stacks[discarded.suit] > discarded.rank) {
|
|
||||||
// _card_positions[_hands[_turn][index]] = trash_or_play_stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
// draw a new card if the draw pile is not empty
|
// draw a new card if the draw pile is not empty
|
||||||
if (!_draw_pile.empty()) {
|
if (!_draw_pile.empty()) {
|
||||||
|
@ -226,10 +219,6 @@ namespace Hanabi {
|
||||||
card_in_hand = draw.card;
|
card_in_hand = draw.card;
|
||||||
card_in_hand.copy = draw.multiplicity - 1;
|
card_in_hand.copy = draw.multiplicity - 1;
|
||||||
|
|
||||||
if (_stacks[draw.card.suit] > draw.card.rank) {
|
|
||||||
// _card_positions[card_in_hand] = _turn;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(_draw_pile.empty()) {
|
if(_draw_pile.empty()) {
|
||||||
// Note the +1, since we will immediately decrement this when moving to the next player
|
// Note the +1, since we will immediately decrement this when moving to the next player
|
||||||
_endgame_turns_left = num_players + 1;
|
_endgame_turns_left = num_players + 1;
|
||||||
|
@ -245,9 +234,6 @@ namespace Hanabi {
|
||||||
// Put the card that is currently in hand back into the draw pile
|
// Put the card that is currently in hand back into the draw pile
|
||||||
ASSERT(index < _hands[_turn].size());
|
ASSERT(index < _hands[_turn].size());
|
||||||
const Card &drawn = _hands[_turn][index];
|
const Card &drawn = _hands[_turn][index];
|
||||||
if (_stacks[drawn.suit] > drawn.rank) {
|
|
||||||
// _card_positions[drawn] = draw_pile;
|
|
||||||
}
|
|
||||||
|
|
||||||
// put discarded_card back into draw pile (at the back)
|
// put discarded_card back into draw pile (at the back)
|
||||||
if (!_draw_pile.empty() and _draw_pile.back().card.suit == drawn.suit and
|
if (!_draw_pile.empty() and _draw_pile.back().card.suit == drawn.suit and
|
||||||
|
@ -260,9 +246,6 @@ namespace Hanabi {
|
||||||
_endgame_turns_left = no_endgame;
|
_endgame_turns_left = no_endgame;
|
||||||
}
|
}
|
||||||
_hands[_turn][index] = discarded_card;
|
_hands[_turn][index] = discarded_card;
|
||||||
if (_stacks[discarded_card.suit] > discarded_card.rank) {
|
|
||||||
// _card_positions[discarded_card] = _turn;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<std::size_t num_suits, player_t num_players, std::size_t hand_size>
|
template<std::size_t num_suits, player_t num_players, std::size_t hand_size>
|
||||||
|
@ -294,7 +277,6 @@ namespace Hanabi {
|
||||||
_draw_pile.push_back({card, nums_in_draw_pile[card]});
|
_draw_pile.push_back({card, nums_in_draw_pile[card]});
|
||||||
for (std::uint8_t copy = 0; copy < nums_in_draw_pile[card]; copy++) {
|
for (std::uint8_t copy = 0; copy < nums_in_draw_pile[card]; copy++) {
|
||||||
card.copy = copy;
|
card.copy = copy;
|
||||||
// _card_positions[card] = draw_pile;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue