コード例 #1
0
        public void Run()
        {
            a.EnterInput(0);
            a.Run();
            b.EnterInput((int)a.GetNextOutput());
            b.Run();
            c.EnterInput((int)b.GetNextOutput());
            c.Run();
            d.EnterInput((int)c.GetNextOutput());
            d.Run();
            e.EnterInput((int)d.GetNextOutput());
            e.Run();

            while (e.IsRunning)
            {
                a.EnterInput((int)e.GetNextOutput());
                b.EnterInput((int)a.GetNextOutput());
                c.EnterInput((int)b.GetNextOutput());
                d.EnterInput((int)c.GetNextOutput());
                e.EnterInput((int)d.GetNextOutput());
            }

            this.Output = (int)e.GetNextOutput();
        }
コード例 #2
0
            public void Run()
            {
                icm.Run();

                while (icm.IsRunning)
                {
                    while (icm.Output.Count > 0)
                    {
                        long x  = icm.GetNextOutput();
                        long y  = icm.GetNextOutput();
                        long id = icm.GetNextOutput();

                        if (x == -1 && y == 0)
                        {
                            CurrentScore = id;
                        }
                        else
                        {
                            var t = Tiles.FirstOrDefault(t => t.X == x && t.Y == y);

                            if (t == null)
                            {
                                Tiles.Add(new Tile(x, y, id));
                            }
                            else
                            {
                                t.TileId = id;
                            }
                        }
                    }

                    PrintTiles();


                    if (icm.IsRunning)
                    {
                        Logger.LogMessage(LogLevel.ANSWER, "L/R/N: ");
                        //string i = Console.ReadLine();

                        string i;

                        if (Logger.CURRENT_LOG_LEVEL == LogLevel.DEBUG)
                        {
                            i = Console.ReadLine();
                        }
                        else
                        {
                            var ball   = Tiles.First(t => t.TileId == 4);
                            var paddle = Tiles.First(t => t.TileId == 3);

                            if (ball.X > paddle.X)
                            {
                                i = "R";
                            }
                            else if (ball.X < paddle.X)
                            {
                                i = "L";
                            }
                            else
                            {
                                i = "N";
                            }
                        }

                        if (i == "L")
                        {
                            icm.EnterInput(-1);
                        }
                        else if (i == "R")
                        {
                            icm.EnterInput(1);
                        }
                        else
                        {
                            icm.EnterInput(0);
                        }
                    }
                }

                while (icm.Output.Count > 0)
                {
                    long x  = icm.GetNextOutput();
                    long y  = icm.GetNextOutput();
                    long id = icm.GetNextOutput();

                    if (x == -1 && y == 0)
                    {
                        CurrentScore = id;
                    }
                    else
                    {
                        var t = Tiles.FirstOrDefault(t => t.X == x && t.Y == y);

                        if (t == null)
                        {
                            Tiles.Add(new Tile(x, y, id));
                        }
                        else
                        {
                            t.TileId = id;
                        }
                    }
                }

                PrintTiles();
            }