Example #1
0
 private void SaveAllChangesButton_Click(object sender, EventArgs e)
 {
     foreach (State s in stateIndexer.AllStates)
     {
         if (s.IsModProvince)
         {
             StateExporter.ExportState(s, outputFolderCheck.Checked);
         }
     }
 }
Example #2
0
        public string NeuralNetworkMove(Board board)
        {
            List <Coin>         coinsOnBoard = board.CoinsOnBoard;
            List <List <Mine> > minesOnBoard = board.MinesOnBoard;

            //Random random = new Random();
            string      possibleMovesStr = "";
            List <Move> moves            = new List <Move>();
            Move        move             = new Move();

            foreach (Move.PossibleMoves code in Enum.GetValues(typeof(Move.PossibleMoves)))
            {
                string moveCode = code.ToString();
                move = new Move(moveCode);
                if (Move.IsMovePossible(move, this, coinsOnBoard, minesOnBoard))
                {
                    Move newMove = new Move(moveCode);
                    moves.Add(newMove);
                    possibleMovesStr += (int)Enum.Parse(typeof(Move.PossibleMoves), moveCode);
                    possibleMovesStr += ",";
                }
            }
            possibleMovesStr = possibleMovesStr.Substring(0, possibleMovesStr.Length - 1);
            DeleteNone(moves);

            State state = new State()
            {
                CoinsOnBoard = board.CoinsOnBoard,
                MinesOnBoard = board.MinesOnBoard,
                Players      = board.Players
            };

            StateExporters.StateExporter exporter = new StateExporter();
            exporter.ExportCurrentState(state);
            string pathToState = "..\\..\\Exports\\" + "current.csv";

            string[] stateOfGameStr = File.ReadAllLines(pathToState);
            //            int[] stateOfGame = { 8, 8, 8, 8, 8, 1, 2, 0, 2, 1, 0, 0, 0, 1, 2, 0, 1, 3, 1, 0, 0, 1, 3, 0, 2, 1, 1, 0, 1, 1, 1, 0, 0, 1, 3, 1, 0, 2, 0, 2, 0, 0, 1, 4, 2, 2, 0, 2, 0, 0, 0, 5, 0, 2, 2, 2, 0, 5, 3, 0, 0, 2, 1, 2, 5, 3, 0, 0, 0, 3, 3, 4, 0, 3, 6, 3, 0, 3, 1, 4, 6, 3, 0, 0, 3, 3, 4, 5, 0, 0, 0, 7, 3, 3, 0, 3, 0, 3, 3, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            //            string stateOfGameStr=String.Join(", ", new List<int>(stateOfGame).ConvertAll(i => i.ToString()).ToArray());


            //TODO dodac lsite possiblemoves i stangry
            int moveInt = run_cmd("C:/Program Files/Python36/python.exe", "..\\..\\..\\Neural_Network\\Network-in-runtime.py " + possibleMovesStr + " " + stateOfGameStr[0]);

            // string a = (Move.PossibleMoves) move;
            return(Enum.GetName(typeof(Move.PossibleMoves), moveInt));
        }