Beispiel #1
0
        public override void Learn(String strSolution, int playerNo)
        {
            String strFileName;

            if (playerNo == 1)
            {
                strFileName = "Brain1.txt";
            }
            else
            {
                strFileName = "Brain2.txt";
            }
            memory.add(strSolution, null);

            // Commit memory to file
            System.IO.StreamWriter filewriter = new System.IO.StreamWriter(new System.IO.FileStream(strFileName, System.IO.FileMode.Append));
            filewriter.WriteLine(strSolution);
            filewriter.Close();
        }
Beispiel #2
0
        public ComputerPlayer(TicTacToe ttt, int playerNo)
        {
            this.playerNo = playerNo;
            String strFileName;

            if (playerNo == 1)
            {
                strFileName = "Brain1.txt";
            }
            else
            {
                strFileName = "Brain2.txt";
            }
            memory = new Trie();
            System.IO.StreamReader filereader = new System.IO.StreamReader(new System.IO.FileStream(strFileName, System.IO.FileMode.OpenOrCreate));
            while (!filereader.EndOfStream)
            {
                memory.add(filereader.ReadLine(), null);
            }
            game = ttt;
            filereader.Close();
        }