diff options
Diffstat (limited to 'src/main/game/search-state/game_state.cpp')
| -rw-r--r-- | src/main/game/search-state/game_state.cpp | 77 |
1 files changed, 4 insertions, 73 deletions
diff --git a/src/main/game/search-state/game_state.cpp b/src/main/game/search-state/game_state.cpp index bd533f1..8045e76 100644 --- a/src/main/game/search-state/game_state.cpp +++ b/src/main/game/search-state/game_state.cpp @@ -222,9 +222,9 @@ vector<card> game_state::gen_shuffled_deck(int seed, card::rank_t max_rank, } -///////////////////////// -// MODIFYING FUNCTIONS // -///////////////////////// +//////////////////// +// ALTERING STATE // +//////////////////// void game_state::make_move(const move m) { // Handles stock moves @@ -342,6 +342,7 @@ void game_state::undo_move(const move m) { // reorders the pile refs so that the largest pile is first void game_state::place_card(pile::ref pr, card c) { piles[pr].place(c); + #ifndef NO_PILE_SYMMETRY // If the stock deals to the tableau piles, there is no pile symmetry if (rules.stock_size == 0 || rules.stock_deal_t != sdt::TABLEAU_PILES) { @@ -362,76 +363,6 @@ card game_state::take_card(pile::ref pr) { return c; } -// Assesses whether the pile ref that was modified was a tableau, cell or -// reserve pile, and if so makes the relevant function call -void game_state::eval_pile_order(pile::ref pr, bool is_place) { - if (!original_tableau_piles.empty() - && pr >= original_tableau_piles[0] - && pr < original_tableau_piles[0] + original_tableau_piles.size()) { - - eval_pile_order(tableau_piles, pr, is_place); - } else if (!original_cells.empty() - && pr >= original_cells[0] - && pr < original_cells[0] + original_cells.size()) { - - eval_pile_order(cells, pr, is_place); - } else if (!original_reserve.empty() - && pr >= original_reserve[0] - && pr < original_reserve[0] + original_reserve.size()) { - - eval_pile_order(reserve, pr, is_place); - } -} - -// Finds the pile ref in the list and evaluates whether it should be moved to -// maintain the "pile order" -void game_state::eval_pile_order(list<pile::ref>& pile_lst, pile::ref changed_pr, - bool is_place) { - // Finds the first pile that is larger/smaller than the ref pile - // (the comp pile). - // If the card has been placed, search for the ref from the right hand side - // and if not from the lhs - if (is_place) { - auto changed_ref_iter = find(rbegin(pile_lst), rend(pile_lst), changed_pr); - auto comp_iter = changed_ref_iter; - - while (++comp_iter != rend(pile_lst) - && piles[*comp_iter] < piles[*changed_ref_iter]); - - if (comp_iter != ++changed_ref_iter) { - // Places the ref pile before the comp pile - pile_lst.insert(comp_iter.base(), changed_pr); - pile_lst.erase(changed_ref_iter.base()); - } - } else { - auto changed_ref_iter = find(begin(pile_lst), end(pile_lst), changed_pr); - auto comp_iter = changed_ref_iter; - - while (++comp_iter != end(pile_lst) - && piles[*comp_iter] > piles[*changed_ref_iter]); - - if (comp_iter != ++changed_ref_iter) { - // Places the ref pile before the comp pile - pile_lst.insert(comp_iter, changed_pr); - pile_lst.erase(--changed_ref_iter); - } - } - -#ifndef NDEBUG - // Makes sure the piles are in order - if (pile_lst.size() > 1) { - auto prev = begin(pile_lst); - auto cur = begin(pile_lst); - cur++; - - while (cur != end(pile_lst)) { - assert(piles[*prev] >= piles[*cur]); - prev++; cur++; - } - } -#endif -} - // Decides which 'auto foundation' booleans should be 'true' currently void game_state::update_auto_foundation_moves(pile::ref target_pile) { // If there are no foundations, or this is not a foundation move, do nothing |
