Small array with moves sorted by their value. More...
#include <SgSortedMoves.h>
Public Member Functions | |
| SgSortedMoves (int maxNuMoves) | |
| void | CheckOverflow () |
| void | Clear () |
| void | DeleteEqual () |
| delete all but one of equal-valued moves | |
| void | Delete (int index) |
| Delete move at index. | |
| void | Insert (const MOVE &move, VALUE value) |
| Insert move with given value in table. | |
| bool | GetMove (const MOVE &move, VALUE &value, int &index) const |
| void | GetMoves (SgVector< MOVE > *moves) const |
| void | SetMinValue (const MOVE &move, VALUE value) |
| If move in table: increase its value. | |
| void | SetMove (int i, const MOVE &move) |
| void | SetValue (int i, VALUE value) |
| void | SetMaxMoves (int nu) |
| Adjust number of moves: throw out all moves whose value has become less than the value of m_move[m_maxNuMoves - 1]. | |
| void | SetMaxNuMoves (int max) |
| Limit number of moves. | |
| void | SetLowerBound (VALUE bound) |
| Lower bound for accepting moves. | |
| void | SetInitLowerBound (VALUE bound) |
| See m_initLowerBound. | |
| int | LowerBound () const |
| int | NuMoves () const |
| int | MaxNuMoves () const |
| const MOVE & | Move (int i) const |
| Get move at given index i. | |
| const MOVE & | BestMove () const |
| The best move is sorted first in the table. | |
| VALUE | Value (int i) const |
| VALUE | BestValue () const |
| void | DecNuMoves () |
| void | AssertIndexRange (int i) const |
| Assert i is an index within the table. | |
| void | Shuffle () |
| randomly shuffle all the moves of equal value. | |
Static Public Attributes | |
| static const bool | CHECKMOVES = SG_CHECK |
| check move table before and after each operation | |
Private Member Functions | |
| void | CheckMoves () const |
| void | ShuffleInterval (int from, int to) |
| Randomly shuffle all moves in interval. | |
Private Attributes | |
| int | m_maxNuMoves |
| int | m_nuMoves |
| VALUE | m_lowerBound |
| Lower bound for accepting moves. | |
| VALUE | m_initLowerBound |
| Initial value of m_lowerBound after a Clear(). | |
| bool | m_checkOverflow |
| bool | m_considerEqual |
| MOVE | m_move [SIZE] |
| VALUE | m_value [SIZE] |
Small array with moves sorted by their value.
Definition at line 20 of file SgSortedMoves.h.
| SgSortedMoves< MOVE, VALUE, SIZE >::SgSortedMoves | ( | int | maxNuMoves | ) | [explicit] |
Definition at line 156 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::Clear(), and SG_ASSERT.
| void SgSortedMoves< MOVE, VALUE, SIZE >::AssertIndexRange | ( | int | i | ) | const |
Assert i is an index within the table.
Definition at line 114 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, SG_ASSERTRANGE, and SG_DEBUG_ONLY.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::Move(), SgSortedMoves< MOVE, VALUE, SIZE >::SetMove(), SgSortedMoves< MOVE, VALUE, SIZE >::SetValue(), SgSortedMoves< MOVE, VALUE, SIZE >::ShuffleInterval(), and SgSortedMoves< MOVE, VALUE, SIZE >::Value().
| const MOVE& SgSortedMoves< MOVE, VALUE, SIZE >::BestMove | ( | ) | const |
The best move is sorted first in the table.
Definition at line 94 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::Move().
| VALUE SgSortedMoves< MOVE, VALUE, SIZE >::BestValue | ( | ) | const |
Definition at line 100 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SG_ASSERT.
| void SgSortedMoves< MOVE, VALUE, SIZE >::CheckMoves | ( | ) | const [private] |
Definition at line 216 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound, SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SG_ASSERT.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), and SgSortedMoves< MOVE, VALUE, SIZE >::Insert().
| void SgSortedMoves< MOVE, VALUE, SIZE >::CheckOverflow | ( | ) |
Definition at line 29 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_checkOverflow.
| void SgSortedMoves< MOVE, VALUE, SIZE >::Clear | ( | ) |
Definition at line 166 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_initLowerBound, SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound, SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, and SG_ASSERT.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::SgSortedMoves().
| void SgSortedMoves< MOVE, VALUE, SIZE >::DecNuMoves | ( | ) |
Definition at line 107 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, and SG_ASSERT.
| void SgSortedMoves< MOVE, VALUE, SIZE >::Delete | ( | int | index | ) |
Delete move at index.
Shift remaining moves forward and adjust lower bound if necessary.
Definition at line 175 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::CheckMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::CHECKMOVES, SgSortedMoves< MOVE, VALUE, SIZE >::m_initLowerBound, SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound, SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_move, SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SG_ASSERT.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::DeleteEqual(), and SgSortedMoves< MOVE, VALUE, SIZE >::SetMinValue().
| void SgSortedMoves< MOVE, VALUE, SIZE >::DeleteEqual | ( | ) |
delete all but one of equal-valued moves
Definition at line 198 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), SgRandom::Global(), SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SG_ASSERT.
| bool SgSortedMoves< MOVE, VALUE, SIZE >::GetMove | ( | const MOVE & | move, | |
| VALUE & | value, | |||
| int & | index | |||
| ) | const |
Definition at line 282 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_move, SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, and SgSortedMoves< MOVE, VALUE, SIZE >::m_value.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::SetMinValue().
| void SgSortedMoves< MOVE, VALUE, SIZE >::GetMoves | ( | SgVector< MOVE > * | moves | ) | const |
Definition at line 327 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_move, SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, and SgVector< T >::PushBack().
| void SgSortedMoves< MOVE, VALUE, SIZE >::Insert | ( | const MOVE & | move, | |
| VALUE | value | |||
| ) |
Insert move with given value in table.
Update m_nuMoves, m_lowerBound of table if necessary.
Definition at line 230 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::CheckMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::CHECKMOVES, SgSortedMoves< MOVE, VALUE, SIZE >::m_checkOverflow, SgSortedMoves< MOVE, VALUE, SIZE >::m_considerEqual, SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound, SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_move, SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SG_ASSERT.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::SetMinValue().
| int SgSortedMoves< MOVE, VALUE, SIZE >::LowerBound | ( | ) | const |
Definition at line 82 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound.
| int SgSortedMoves< MOVE, VALUE, SIZE >::MaxNuMoves | ( | ) | const |
Definition at line 88 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves.
| const MOVE& SgSortedMoves< MOVE, VALUE, SIZE >::Move | ( | int | i | ) | const |
Get move at given index i.
Definition at line 91 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::AssertIndexRange(), and SgSortedMoves< MOVE, VALUE, SIZE >::m_move.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::BestMove(), and operator<<().
| int SgSortedMoves< MOVE, VALUE, SIZE >::NuMoves | ( | ) | const |
Definition at line 85 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves.
Referenced by operator<<().
| void SgSortedMoves< MOVE, VALUE, SIZE >::SetInitLowerBound | ( | VALUE | bound | ) |
See m_initLowerBound.
Definition at line 79 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_initLowerBound.
| void SgSortedMoves< MOVE, VALUE, SIZE >::SetLowerBound | ( | VALUE | bound | ) |
Lower bound for accepting moves.
Definition at line 76 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound.
| void SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxMoves | ( | int | nu | ) |
Adjust number of moves: throw out all moves whose value has become less than the value of m_move[m_maxNuMoves - 1].
Definition at line 361 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_considerEqual, SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound, SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxNuMoves().
| void SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxNuMoves | ( | int | max | ) |
Limit number of moves.
Definition at line 353 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves, and SG_ASSERT.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxMoves().
| void SgSortedMoves< MOVE, VALUE, SIZE >::SetMinValue | ( | const MOVE & | move, | |
| VALUE | value | |||
| ) |
If move in table: increase its value.
otherwise insert (move,value)
Definition at line 334 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), SgSortedMoves< MOVE, VALUE, SIZE >::GetMove(), and SgSortedMoves< MOVE, VALUE, SIZE >::Insert().
| void SgSortedMoves< MOVE, VALUE, SIZE >::SetMove | ( | int | i, | |
| const MOVE & | move | |||
| ) |
Definition at line 55 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::AssertIndexRange(), and SgSortedMoves< MOVE, VALUE, SIZE >::m_move.
| void SgSortedMoves< MOVE, VALUE, SIZE >::SetValue | ( | int | i, | |
| VALUE | value | |||
| ) |
Definition at line 62 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::AssertIndexRange(), and SgSortedMoves< MOVE, VALUE, SIZE >::m_value.
| void SgSortedMoves< MOVE, VALUE, SIZE >::Shuffle | ( | ) |
randomly shuffle all the moves of equal value.
Definition at line 313 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SgSortedMoves< MOVE, VALUE, SIZE >::ShuffleInterval().
| void SgSortedMoves< MOVE, VALUE, SIZE >::ShuffleInterval | ( | int | from, | |
| int | to | |||
| ) | [private] |
Randomly shuffle all moves in interval.
They must be of equal value
Definition at line 296 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::AssertIndexRange(), SgRandom::Global(), SgRandom::Int(), SgSortedMoves< MOVE, VALUE, SIZE >::m_move, SgSortedMoves< MOVE, VALUE, SIZE >::m_value, and SG_ASSERT.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::Shuffle().
| VALUE SgSortedMoves< MOVE, VALUE, SIZE >::Value | ( | int | i | ) | const |
Definition at line 97 of file SgSortedMoves.h.
References SgSortedMoves< MOVE, VALUE, SIZE >::AssertIndexRange(), and SgSortedMoves< MOVE, VALUE, SIZE >::m_value.
Referenced by operator<<().
const bool SgSortedMoves< MOVE, VALUE, SIZE >::CHECKMOVES = SG_CHECK [static] |
check move table before and after each operation
Definition at line 24 of file SgSortedMoves.h.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), and SgSortedMoves< MOVE, VALUE, SIZE >::Insert().
bool SgSortedMoves< MOVE, VALUE, SIZE >::m_checkOverflow [private] |
Definition at line 137 of file SgSortedMoves.h.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::CheckOverflow(), and SgSortedMoves< MOVE, VALUE, SIZE >::Insert().
bool SgSortedMoves< MOVE, VALUE, SIZE >::m_considerEqual [private] |
Definition at line 140 of file SgSortedMoves.h.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::Insert(), and SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxMoves().
VALUE SgSortedMoves< MOVE, VALUE, SIZE >::m_initLowerBound [private] |
Initial value of m_lowerBound after a Clear().
Definition at line 134 of file SgSortedMoves.h.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::Clear(), SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), and SgSortedMoves< MOVE, VALUE, SIZE >::SetInitLowerBound().
VALUE SgSortedMoves< MOVE, VALUE, SIZE >::m_lowerBound [private] |
Lower bound for accepting moves.
Definition at line 131 of file SgSortedMoves.h.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::CheckMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::Clear(), SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), SgSortedMoves< MOVE, VALUE, SIZE >::Insert(), SgSortedMoves< MOVE, VALUE, SIZE >::LowerBound(), SgSortedMoves< MOVE, VALUE, SIZE >::SetLowerBound(), and SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxMoves().
int SgSortedMoves< MOVE, VALUE, SIZE >::m_maxNuMoves [private] |
Definition at line 125 of file SgSortedMoves.h.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::CheckMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::Clear(), SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), SgSortedMoves< MOVE, VALUE, SIZE >::Insert(), SgSortedMoves< MOVE, VALUE, SIZE >::MaxNuMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxMoves(), and SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxNuMoves().
MOVE SgSortedMoves< MOVE, VALUE, SIZE >::m_move[SIZE] [private] |
Definition at line 143 of file SgSortedMoves.h.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), SgSortedMoves< MOVE, VALUE, SIZE >::GetMove(), SgSortedMoves< MOVE, VALUE, SIZE >::GetMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::Insert(), SgSortedMoves< MOVE, VALUE, SIZE >::Move(), SgSortedMoves< MOVE, VALUE, SIZE >::SetMove(), and SgSortedMoves< MOVE, VALUE, SIZE >::ShuffleInterval().
int SgSortedMoves< MOVE, VALUE, SIZE >::m_nuMoves [private] |
Definition at line 128 of file SgSortedMoves.h.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::AssertIndexRange(), SgSortedMoves< MOVE, VALUE, SIZE >::BestValue(), SgSortedMoves< MOVE, VALUE, SIZE >::CheckMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::Clear(), SgSortedMoves< MOVE, VALUE, SIZE >::DecNuMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), SgSortedMoves< MOVE, VALUE, SIZE >::DeleteEqual(), SgSortedMoves< MOVE, VALUE, SIZE >::GetMove(), SgSortedMoves< MOVE, VALUE, SIZE >::GetMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::Insert(), SgSortedMoves< MOVE, VALUE, SIZE >::NuMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxMoves(), and SgSortedMoves< MOVE, VALUE, SIZE >::Shuffle().
VALUE SgSortedMoves< MOVE, VALUE, SIZE >::m_value[SIZE] [private] |
Definition at line 146 of file SgSortedMoves.h.
Referenced by SgSortedMoves< MOVE, VALUE, SIZE >::BestValue(), SgSortedMoves< MOVE, VALUE, SIZE >::CheckMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::Delete(), SgSortedMoves< MOVE, VALUE, SIZE >::DeleteEqual(), SgSortedMoves< MOVE, VALUE, SIZE >::GetMove(), SgSortedMoves< MOVE, VALUE, SIZE >::Insert(), SgSortedMoves< MOVE, VALUE, SIZE >::SetMaxMoves(), SgSortedMoves< MOVE, VALUE, SIZE >::SetValue(), SgSortedMoves< MOVE, VALUE, SIZE >::Shuffle(), SgSortedMoves< MOVE, VALUE, SIZE >::ShuffleInterval(), and SgSortedMoves< MOVE, VALUE, SIZE >::Value().