Ejemplo n.º 1
0
        public void PopulateOpenList()
        {
            foreach (var rule in Jug.GetTransferRules())
            {
                JugPath jugPath;
                var     jugClone1 = (Jug)_currentPath.J1.Clone();
                var     jugClone2 = (Jug)_currentPath.J2.Clone();

                if (rule.Value(jugClone1, jugClone2))
                {
                    jugPath = new JugPath(jugClone1, jugClone2, _open.Count)
                    {
                        Anterior = _currentPath
                    };

                    if (!jugPath.Paths.Any(item => item.J1.Current == jugClone1.Current &&
                                           item.J2.Current == jugClone2.Current)
                        )
                    {
                        _open.Add(jugPath);
                    }
                }
            }

            OrderOpenList();
        }
Ejemplo n.º 2
0
        public JugProblem(int m, int n)
        {
            J1 = new Jug(m);
            J2 = new Jug(n);

            SetSort(SortType.Asc);

            _rules = Jug.GetTransferRules();

            _currentState = new JugState(0, J1, J2);
        }