public void Iterate(ConflictState state)
        {
            int    h    = 10;
            DPItem item = new DPItem();

            if (!space.TryGetValue(state.GetHashCode(), out item))
            {
                return;
            }

            for (int i = 0; i < iterationCount; i++)
            {
                foreach (KeyValuePair <int, DPItem> pair in space)
                {
                    //int min = int.MaxValue;
                    h = pair.Value.State.cost;
                    ConflictState current = pair.Value.State;
                    foreach (ConflictState s in pair.Value.Children)
                    {
                        h += s.probability * s.cost;
                        //if (state.cost < min)
                        //{
                        //    min = state.cost;
                        //}
                    }
                    pair.Value.State = current;
                }
            }
        }
        private void Recurse(ConflictState state, CharacterNPC character, CharacterNPC enemyChar, ActionType actinType, int step)
        {
            List <ConflictState> nextStates = GetSuccessors(state, character, enemyChar, actinType);
            DPItem item = new DPItem();

            item.Probability = state.probability;
            item.State       = state;
            item.Children    = nextStates;
            if (!space.ContainsKey(item.GetHashCode()))
            {
                this.space.Add(item.GetHashCode(), item);
            }

            step++;
            if (step < this.stateSpaceDeep)
            {
                ConflictState successor;
                for (int i = 0; i < nextStates.Count; i++)
                {
                    successor = nextStates[i];

                    if (this.stateSpace.Contains(successor))
                    {
                        //Logger.AddInfo("DP: nalezena duplicita. " + successor.ToString());
                        continue;
                    }
                    if (successor.enemyHP <= 0)
                    {
                        Logger.AddInfo("DP:Nalezen cilovy stav " + successor.ToString());
                        successor.cost = 0;
                        //step = this.stateSpaceDeep;
                        nextStates[i] = successor;
                        break;
                    }
                    else if (successor.myHP < character.hp / 4)
                    {
                        successor.cost = 100;
                        nextStates[i]  = successor;
                    }
                    this.stateSpace.Add(successor);
                    //try
                    //{
                    //    if (!space.ContainsKey(successor.GetHashCode()))
                    //    {
                    //        space.Add(successor.GetHashCode(), successor);
                    //    }
                    //    else
                    //    {
                    //        //Logger.AddWarning("DP: chyba pri pridavani do hash tabulky..." + successor.ToString());
                    //    }
                    //}
                    //catch (Exception)
                    //{
                    //    Logger.AddWarning("DP: chyba pri pridavani do hash tabulky..." + successor.ToString());
                    //}
                    Recurse(successor, character, enemyChar, actinType, step);
                }
                //this.stateSpace.AddRange(nextStates);
            }
        }