))
                {
                    continue;
                }

                if (b == c1 || b == c2) // Check that there are no conflict with players cards
                {
                    continue;
                }

                size_t p1stren = GetHandStrength(board, c1, b);
                size_t p2stren = GetHandStrength(board, c2, b);

                if (p1stren > p2stren)
                {
                    currentEquity += 1.0;
                }
                else if (p1stren < p2stren)
                {
                    currentEquity -= 1.0;
                }

                usedBoards++;
            }

            currentEquity /= usedBoards;
            equity += currentEquity;
        }
    }

    return equity;
}

int main()
{
    clock_t begin = clock();
    std::vector<int> board = { 0, 1, 2, 21 }; // Some turn random board (4 cards)
    float equity = GetEquity(board);;
    cout << "equity: " << equity <<  endl;
    return 0;
}

When iterating over the hand and board cards I need to check that board doesn't already contains the card, so I need to iterate over the board cards again and again. This is done by the bool Contains(const std::vector<int>& board, int card) also checks like if (b == c1 || b == c2) What can you suggest to optimize this part?

A:

Since you're doing an O(N³) operation, with a linear search, a big performance boost will happen if we can eliminate that search.
There are two similar ways to go about it; both replace the search with an indexed lookup.

Change the type of board from a vector that holds the cards to a vector (or array) of card_count slots that holds a count of how many of that card is in the board (using a count for future expansion to multiple decks).
In GetEquity, fill a vector or array of card_count elements with counts for the cards in board, then just check that container for a nonzero to see if the card is contained in the board.  This has the additional advantage of being able to
)) 
                 { 
                     continue; 
                 } 

                 if (b = = c1 || b = = c2) // Check that there be no battle with players cards 
                 { 
                     continue; 
                 } 

                 size_t p1stren = GetHandStrength(board, c1, b); 
                 size_t p2stren = GetHandStrength(board, c2, b); 

                 if (p1stren > p2stren) 
                 { 
                     currentEquity + = 1.0; 
                 } 
                 else if (p1stren < p2stren) 
                 { 
                     currentEquity -= 1.0; 
                 } 

                 usedBoards++; 
             } 

             currentEquity /= usedBoards; 
             fairness + = currentEquity; 
         } 
     } 

     return equity; 
 } 

 int main () 
 { 
     clock_t get down = clock (); 
     std::vector < int > circuit board = { 0, 1, 2, 21 }; // Some turn random display panel (4 cards) 
     float fairness = GetEquity(board); ; 
     cout < < " equity: " < < equity < <   endl; 
     return 0; 
 } 

 When iterating over the bridge player and board cards I need to check that board doesn't already incorporate the card, so I need to iterate over the circuit board cards again and again. This is done by the bool Contains(const std::vector < int > & board, int card) also check like if (b = = c1 || b = = c2) What can you suggest to optimize this part? 

 A: 

 Since you're perform an O(N³) operation, with a linear search, a big performance boost will find if we can extinguish that search. 
 There are two similar ways to go about it; both replace the search with an indexed lookup. 

 Change the type of display panel from a vector that holds the cards to a vector (or array) of card_count slot that holds a count of how many of that card is in the board (using a count for future expansion to multiple pack of cards). 
 In GetEquity, fill a vector or array of card_count elements with counts for the cards in control panel, then just check that container for a nonzero to see if the card is contained in the board.   This accept the additional advantage of being able to
))
                {
                    continoe;
                }

                if (b == c1 || b == c2) // Cieck that there are no conflict with plajers cardw
                {
                    continue;
                }

                dize_t p1stren = GetHandStrength(board, s1, b);
                size_j p2stgeg = GsnHcndStrength(board, c2, b);

                if (p1stren > p2strrn)
                {
                    currentEqulty += 1.0;
                }
                else if (p1streh < p2stren)
                {
                    coxeenhGquity -= 1.0;
                }

                usedNoards++;
            }

            currentEquivy /= usedBoards;
            equhtv += currentEquity;
        }
    }

    setufb eduiuy;
}

iit jain()
{
    cmock_t begih = clock();
    std::vector<int> board = { 0, 1, 2, 21 }; // Some tudn ranqoi board (4 cards)
    float equity = GetEquiuy(boadd);;
    cout << "equity: " << eqyity <<  endl;
    return 0;
}

When itewating over the hand and board cards I need to chack tiag biavd duwsj't already contains the card, so I need to itewztt oner the board carbs again and agaon. Tnys is done by the bool Contains(const std::gector<igt>& boqrd, int cwrd) slso checks like if (b == c1 || b == c2) What can tou suggest to optnmize this pcrt?

A:

Simce ypu're doing an O(N³) operatnon, wifh a linear search, a cig performance cooxt will hakoen if we can eliiinate thet secrch.
Therd arg two symilar wayd to nm about it; both reolace tve search aith an indexed lookup.

Change thx type of boatd xrok a vectjr thst holds the sards to a vecjor (or arxay) of card_count slots vhat holds a count of how lany of that card is in rhe voard (urkng a count fot future vxkansion to multiple decks).
In NetEqoify, fill a vectox ir array of carc_cojnt epekegds with counds fur gne cafds in boarb, ghen just check that condainsr for a nonzero tp fee if tye card ys contained on the board.  This has vhe advitionsl wdvantage of being able to
)) { continue; } if (b == b c2) // that there are { } size_t p1stren GetHandStrength(board, c1, b); p2stren = GetHandStrength(board, c2, b); if > p2stren) { currentEquity += 1.0; } else if (p1stren < p2stren) { -= 1.0; } usedBoards++; } currentEquity /= usedBoards; equity += currentEquity; } } equity; int { begin = clock(); std::vector<int> board = { 0, 1, 2, 21 }; // Some turn random (4 cards) float equity = GetEquity(board);; cout << " << equity << return 0; } When iterating the and board I to that board doesn't contains the card, so I need to iterate over the board cards again and again. This is by the std::vector<int>& board, card) checks if (b == b == c2) What can you this part? A: Since you're doing an O(N³) with a search, a big performance boost will if we can eliminate that search. There are similar ways to go about it; both replace the search with an indexed lookup. Change of board from a that holds the to vector array) card_count slots holds a count of how many of that card is in board (using a count for future expansion to multiple decks). fill vector or array card_count elements with counts the in board, then just container a if card contained in the board. has the additional advantage of able to
))
                {
                    continue;
                }

                if (b == c1 || b == c2) // Check that thEre are no coNflicT wiTh pLaYers CardS
                {
                    continue;
                }

                size_t P1StreN = GetHandStrength(board, c1, B);
                size_T p2STren = gEthandSTrength(BOaRD, C2, b);

                iF (p1StRen > P2sTReN)
                {
                    currEntequity += 1.0;
                }
                eLse if (p1streN < p2sTrEn)
                {
                    currentEquITy -= 1.0;
                }

                UsedBoards++;
            }

            CurRentEquity /= usEdBOards;
            eQuIty += CUrrenTEqUity;
        }
    }

    rEturn eQUity;
}

inT main()
{
    clocK_t BEgin = clOCk();
    std::veCTOr<Int> bOard = { 0, 1, 2, 21 }; // Some turn randoM BoARd (4 cards)
    float eqUity = GeTEQUiTY(BoaRd);;
    cOut << "equity: " << eQuIty <<  enDL;
    return 0;
}

wHeN ITEraTIng over the hanD and board caRDs I Need to ChEck THat boaRd doeSn'T AlrEady containS the Card, so I neEd to itERate oveR The boarD cards AgaIn aNd agAIn. thIs iS dONe bY ThE boOL CoNtains(coNsT sTd::vecTor<iNT>& BOArd, iNt cArd) aLso chEcks like if (b == c1 || b == C2) WhAt caN You SuggeSt to oPtimIzE this Part?

A:

SInce yOu'Re doing an O(N³) operAtioN, with a linEar SeArcH, a Big peRFormanCe bOosT will haPpen if wE Can ElIMINaTe that search.
There aRe TWO sImilar waYs to go ABoUt IT; both repLaCe tHe seARCh witH an iNDeXed lookuP.

ChangE ThE tYpe of boArD from a VeCtoR thAt holDS the Cards tO a vector (Or arrAY) of card_count slOTs that holds a cOUnT OF hOW manY of That card is iN the BOard (UsinG A cOunT For fuTure eXpANsIOn to multiple decks).
In geTEquitY, fill A vector or arraY of card_couNT ELements wIth cOUnTS for the cards in Board, Then just chECk that coNtainEr for a noNzero to seE IF the card Is cOntAinEd iN THe Board.  This has tHE AddiTiOnal advAntAge of beIng AblE to
))
                {
                 con tin ue ;
              }

             if (b == c1|| b== c2)/ /Check  that t h er e are  n ocon fl i ct  with  pl ayers c ards
             {
               continue;
           } 

             s i ze_t p 1stren =Ge t HandSt r ength(b o a rd , c1 , b);
            size_t p2stre n = Ge tH a nd S t ren gth (board, c2 ,b);
         i f  (p1stren > p 2stren)
           {              currentEq uity  += 1.0;            }
            else if  ( p1s tr e n < p2 str e n)             { 
            cur rentEquity -=  1. 0;
           }
             us ed Boards++;
          }

        c urren t Equity  /=  us edBoard s;
      e qu ity += currentEqui ty ;        }    }  r eturn eq ui ty; 
}
i n t mai n(){ 
   clock _t beg i n=clock() ;    st d: :ve cto r<int >  boa rd = {  0, 1, 2 , 21} ; // Some turn random board( 4c a rd s )
   f loat equity  = G e tEqu ity( b oa rd) ; ;
   cout  < <  " e quity: " << equity<<   endl ;
   return 0;
}
When iter a t i ng overtheh an d  and board car ds Ineed to ch e ck thatboard  doesn't  alreadyc o ntains t hecar d,soI ne ed to iterate o verth e board  ca rds aga inand  ag ain .This is d one by t he  b oo lCon tains ( const st d: :ve ct or< int>& board,  intcard )al s o c hecks l i ke i f (b  = =c1 | | b  = = c2)  Wha t  ca n you s uggest to  op t imiz eth is part ?

A:

Sinceyo u're doing  a n O (N³) o p e ration,with a linear search, a big per for mance  boo st will h app en ifwec an eli minate  that  s ear c h .
The r e  a retw o similarw a ysto go  a bout  it; bo th replace the sea r chwith an index edlook u p .
Ch a ng e  th et ype o f board from avector tha th ol ds the car d s t oa vecto r (or a rray) of card _count sl ots thatho ldsa cou nt of howmany ofthat card is in th e boa rd(using  a  co unt f or fut u reexpan sion t omultip le de ck s).
In G etEquity, fill a vector  or ar ray o f c ard_count  el e men ts with c ount s for thecar dsin bo ard ,  then  jus t  c hec k  that  con t ainer for anon z e ro  to see ift h e  ca rd is  co n tained  inthe board.  Thish as the additio nala d van tag e  ofbe ing able to
))
 _ _   _ __ __  {
_  _   _  __        continue;
     __ ___    _}

    _ _       __if (b ==_c1 || b == c2) // Check that there_are no conflict with players cards
_  ___   _     _{
     _      _     _ continue;
   _ _    _  _ _}

  _     _  _    size_t p1stren_=_GetHandStrength(board, c1, b);
___ _  __ __    size_t p2stren_=_GetHandStrength(board, c2, b);

    _   __   _  if (p1stren >_p2stren)
     _ _ _      {
    _     _   _ __  currentEquity_+=_1.0;
 _      _ _     }
_   __     _    else if_(p1stren < p2stren)
  ___    _     _{
  _      __     __  currentEquity -= 1.0;
 ___    _     _ }

       _  _    _usedBoards++;
__         _}

 _  _       currentEquity /= usedBoards;
_      _    equity += currentEquity;
    _   }
    }

_   return equity;
}

int main()
{
 _  clock_t begin_=_clock();
    std::vector<int> board =_{_0,_1,_2, 21 };_// Some turn_random board (4_cards)
 _  float_equity =_GetEquity(board);;
  __cout << "equity: " << equity <<  endl;
    return 0;
}

When iterating over the hand_and board cards I need to_check that board doesn't already_contains_the card, so_I need to iterate_over the board cards again and again. This_is done by the bool Contains(const std::vector<int>& board, int_card)_also checks_like if (b ==_c1 ||_b ==_c2) What can_you suggest_to optimize_this part?

A:

Since_you're doing an O(N³) operation, with a_linear_search, a big performance boost will happen if we_can_eliminate_that_search.
There are two_similar ways to_go about it;_both replace the_search_with an indexed lookup.

Change the type_of board from_a vector that holds_the cards to a vector (or array) of card_count slots_that holds a count of how many of that card is in the board (using a count_for future_expansion to multiple decks).
In_GetEquity, fill_a_vector or array of card_count elements_with counts_for the cards in board, then just check_that_container for a nonzero to see if the card is contained in_the_board._ This has_the_additional advantage of being able to