Esempio n. 1
0
 public static int GetDiff(this NimState from, NimState to)
 {
     int diff = 0;
     if (from.X == to.X)
         diff++;
     if (from.Y == to.Y)
         diff++;
     if (from.Z == to.Z)
         diff++;
     return diff;
 }
Esempio n. 2
0
        public void AddScore(NimState state, double rawScore)
        {
            NimScore score;
            if (Scores.TryGetValue(state, out score)) {

                score.Add(rawScore);
            } else {

                score = new NimScore();
                score.Add(rawScore);
                Scores.Add(state, score);
            }
        }
Esempio n. 3
0
        public override NimState GetNextState(NimState state)
        {
            ("1) " + state.XReal).ToConsole();
            ("2) " + state.YReal).ToConsole();
            ("3) " + state.ZReal).ToConsole();

            int option = 0;

            bool goodRow = false;

            while (!goodRow) {

                option = IOHelper.PromptForInputInt("Which Row to Edit?", 1, 3);

                switch (option) {
                    case 1:
                        goodRow = state.XReal > 0;
                        break;
                    case 2:
                        goodRow = state.YReal > 0;
                        break;
                    case 3:
                        goodRow = state.ZReal > 0;
                        break;
                }

                if (!goodRow)
                    "Bad Row".ToConsole();
            }

            int numberToRemove = IOHelper.PromptForInputInt("Number to Remove?", 1);

            switch (option) {
                case 1:
                    state.XReal -= numberToRemove;
                    break;
                case 2:
                    state.YReal -= numberToRemove;
                    break;
                case 3:
                    state.ZReal -= numberToRemove;
                    break;
            }

            Console.WriteLine();

            return state;
        }
Esempio n. 4
0
        public override NimState GetNextState(NimState state)
        {
            NimState bestState = new NimState(0, 0, 1);
            double bestScore = -1;
            List<NimState> states = state.GetPossibleStates();

            foreach (NimState nimState in states) {

                double tempScore = _store.GetScore(nimState.Clone());

                if (tempScore > bestScore) {

                    bestScore = tempScore;
                    bestState = nimState.Clone();
                }
            }

            ("Of the " + states.Count + " States, Move: " + bestState + " decided, confidence: " + ((float) bestScore)).ToConsole();

            return bestState;
        }
Esempio n. 5
0
 protected bool Equals(NimState other)
 {
     return Z == other.Z && Y == other.Y && X == other.X;
 }
Esempio n. 6
0
 public void Add(NimState state)
 {
     History.Add(state);
 }
Esempio n. 7
0
 public double GetScore(NimState state)
 {
     NimScore score;
     return (Scores.TryGetValue(state, out score)) ? score.Score : 0;
 }
Esempio n. 8
0
 public static bool IsCompatibleWith(this NimState from, NimState to)
 {
     return GetDiff(from, to) == 1;
 }