コード例 #1
0
ファイル: test_agent_host.cs プロジェクト: CubedCode/malmo
    public static void Main(string[] args)
    {
        using (AgentHost agent_host = new AgentHost())
        {
            agent_host.setVideoPolicy(AgentHost.VideoPolicy.LATEST_FRAME_ONLY);
            agent_host.setRewardsPolicy(AgentHost.RewardsPolicy.SUM_REWARDS);
            agent_host.setObservationsPolicy(AgentHost.ObservationsPolicy.LATEST_OBSERVATION_ONLY);

            WorldState world_state = agent_host.getWorldState();

            if (world_state.is_mission_running)
                Environment.Exit(1);

            if (world_state.number_of_observations_since_last_state != 0)
                Environment.Exit(1);

            if (world_state.number_of_rewards_since_last_state != 0)
                Environment.Exit(1);

            if (world_state.number_of_video_frames_since_last_state != 0)
                Environment.Exit(1);

            if (world_state.observations.Count != 0)
                Environment.Exit(1);

            if (world_state.rewards.Count != 0)
                Environment.Exit(1);

            if (world_state.video_frames.Count != 0)
                Environment.Exit(1);

            Console.WriteLine(agent_host.getUsage());
        }
    }
コード例 #2
0
ファイル: DefaultMission.cs プロジェクト: vadimas/events
        public static void Execute(AgentHost agentHost, ListBox lstMessage, Panel pnl3x3, Panel pnlDiagData, PictureBox pictureBoxMineCraft, CheckBox chkFullDebug)
        {
            WorldState           worldState;
            JavaScriptSerializer json_serializer = new JavaScriptSerializer();

            agentHost.setObservationsPolicy(ObservationsPolicy.LATEST_OBSERVATION_ONLY);
            agentHost.setVideoPolicy(VideoPolicy.LATEST_FRAME_ONLY);

            // main loop:
            do
            {
                // Get Worldstate
                worldState = agentHost.getWorldState();
                Thread.Sleep(500);

                // Make an Observation
                Observation objObservation = RunMission.LogMission(worldState, lstMessage, pnl3x3, pnlDiagData, chkFullDebug);

                if (worldState.is_mission_running && worldState.video_frames.Count > 0)
                {
                    // Converts the Malmo ByteVector to a Bitmap and display in pictureBoxMineCraft
                    pictureBoxMineCraft.Image = ImageConvert.GetImageFromByteArray(worldState.video_frames[0].pixels);
                    pictureBoxMineCraft.Invalidate();
                    pictureBoxMineCraft.Refresh();
                }
            }while (worldState.is_mission_running);

            lstMessage.Items.Insert(0, "Mission has stopped.");
        }
コード例 #3
0
    public static void Main(string[] args)
    {
        using (AgentHost agent_host = new AgentHost())
        {
            agent_host.setVideoPolicy(AgentHost.VideoPolicy.LATEST_FRAME_ONLY);
            agent_host.setRewardsPolicy(AgentHost.RewardsPolicy.SUM_REWARDS);
            agent_host.setObservationsPolicy(AgentHost.ObservationsPolicy.LATEST_OBSERVATION_ONLY);

            WorldState world_state = agent_host.getWorldState();

            if (world_state.has_mission_begun)
            {
                Environment.Exit(1);
            }

            if (world_state.is_mission_running)
            {
                Environment.Exit(1);
            }

            if (world_state.number_of_observations_since_last_state != 0)
            {
                Environment.Exit(1);
            }

            if (world_state.number_of_rewards_since_last_state != 0)
            {
                Environment.Exit(1);
            }

            if (world_state.number_of_video_frames_since_last_state != 0)
            {
                Environment.Exit(1);
            }

            if (world_state.observations.Count != 0)
            {
                Environment.Exit(1);
            }

            if (world_state.rewards.Count != 0)
            {
                Environment.Exit(1);
            }

            if (world_state.video_frames.Count != 0)
            {
                Environment.Exit(1);
            }

            Console.WriteLine(agent_host.getUsage());
        }
    }
コード例 #4
0
        public static void Execute(AgentHost agentHost, ListBox lstMessage, Panel pnl3x3, Panel pnlDiagData, PictureBox pictureBoxMineCraft, CheckBox chkFullDebug)
        {
            WorldState           worldState;
            JavaScriptSerializer json_serializer = new JavaScriptSerializer();

            agentHost.setObservationsPolicy(ObservationsPolicy.LATEST_OBSERVATION_ONLY);
            agentHost.setVideoPolicy(VideoPolicy.LATEST_FRAME_ONLY);

            // main loop:
            do
            {
                // Get Worldstate
                worldState = agentHost.getWorldState();
                Thread.Sleep(500);

                // Log Mission
                Observation objObservation = RunMission.LogMission(worldState, lstMessage, pnl3x3, pnlDiagData, chkFullDebug);
                var         yaw            = objObservation.Yaw;

                string current_yaw_delta = "";
                if (worldState.is_mission_running && worldState.video_frames.Count > 0)
                {
                    // do we have new Video?
                    if (worldState.video_frames.Count > 0)
                    {
                        current_yaw_delta = processFrame(worldState.video_frames[0].pixels);
                        if (current_yaw_delta != "")
                        {
                            agentHost.sendCommand(String.Format("turn {0}", current_yaw_delta));
                        }
                    }
                    else
                    {
                        agentHost.sendCommand(String.Format("turn {0}", yaw));
                    }
                }

                if (worldState.is_mission_running && worldState.video_frames.Count > 0)
                {
                    // Converts the Malmo ByteVector to a Bitmap and display in pictureBoxMineCraft
                    pictureBoxMineCraft.Image = ImageConvert.GetImageFromByteArray(worldState.video_frames[0].pixels);
                    pictureBoxMineCraft.Invalidate();
                    pictureBoxMineCraft.Refresh();
                }
            }while (worldState.is_mission_running);

            lstMessage.Items.Insert(0, "Mission has stopped.");
        }
コード例 #5
0
ファイル: AvoidTheLava.cs プロジェクト: vadimas/events
        public static void Execute(AgentHost agentHost, ListBox lstMessage, Panel pnl3x3, Panel pnlDiagData, PictureBox pictureBoxMineCraft, CheckBox chkFullDebug)
        {
            WorldState           worldState;
            JavaScriptSerializer json_serializer = new JavaScriptSerializer();

            agentHost.setObservationsPolicy(ObservationsPolicy.LATEST_OBSERVATION_ONLY);
            agentHost.setVideoPolicy(VideoPolicy.LATEST_FRAME_ONLY);

            string strMoveCommand = "";

            // main loop:
            do
            {
                // Get Worldstate
                worldState = agentHost.getWorldState();
                Thread.Sleep(500);

                // Make an Observation
                Observation objObservation = RunMission.LogMission(worldState, lstMessage, pnl3x3, pnlDiagData, chkFullDebug);

                // Only proceed if we are able to get back an Observation
                if (objObservation.floor3x3 != null)
                {
                    // Check for "lava" anywhere around us
                    if (!
                        (
                            (objObservation.floor3x3[1].ToString() == "lava") ||
                            (objObservation.floor3x3[4].ToString() == "lava") ||
                            (objObservation.floor3x3[7].ToString() == "lava")
                        ))
                    {
                        // There is no Lava -- keep moving forward
                        strMoveCommand = String.Format("{0} {1}", "move", 1);
                        agentHost.sendCommand(strMoveCommand);
                        lstMessage.Items.Insert(0, strMoveCommand);
                    }
                    else
                    {
                        // There is lava nearby
                        for (int i = 0; i < 8; i++)
                        {
                            if (objObservation.floor3x3[i].ToString() == "lava")
                            {
                                lstMessage.Items.Insert(0, String.Format("Lava found at block: {0}", i));
                            }
                        }

                        // Turn and move
                        strMoveCommand = String.Format("{0} {1}", "turn", 1);
                        agentHost.sendCommand(strMoveCommand);
                        lstMessage.Items.Insert(0, strMoveCommand);

                        strMoveCommand = String.Format("{0} {1}", "move", 1);
                        agentHost.sendCommand(strMoveCommand);
                        lstMessage.Items.Insert(0, strMoveCommand);
                    }
                }

                if (worldState.is_mission_running && worldState.video_frames.Count > 0)
                {
                    // Converts the Malmo ByteVector to a Bitmap and display in pictureBoxMineCraft
                    pictureBoxMineCraft.Image = ImageConvert.GetImageFromByteArray(worldState.video_frames[0].pixels);
                    pictureBoxMineCraft.Invalidate();
                    pictureBoxMineCraft.Refresh();
                }
            }while (worldState.is_mission_running);

            lstMessage.Items.Insert(0, "Mission has stopped.");
        }