예제 #1
0
파일: Form1.cs 프로젝트: vvancak/ai
        private void Extern_button_Click(object sender, EventArgs e)
        {
            Process p = new Process();

            //p.StartInfo.FileName = @"C:\Documents and Settings\Ota\Dokumenty\Visual Studio 2010\Projects\MinesVisualizer\bin\Debug\MinesVisualizer.exe";
            p.StartInfo.FileName               = @".\solver.exe";
            p.StartInfo.UseShellExecute        = false;
            p.StartInfo.RedirectStandardInput  = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.Start();
            p.StandardInput.WriteLine(inp.nodesCount);
            for (int i = 0; i < inp.nodesCount; i++)
            {
                p.StandardInput.WriteLine((int)(Math.Floor(inp.getPoint(i).x)) + " " + (int)(Math.Floor(inp.getPoint(i).y)));
            }
            string result = p.StandardOutput.ReadLine();

            solution = TSPSolution.fromString(result, inp);
            solution.computeDistance();
            Length_label.Text = solution.totalDistance.ToString();
            vis.draw(solution);
        }