#VS2017 – Commands with the basic movements for an #Minecraft Agent with #ProjectMalmo

Hi!

Today I will share how to perform 2 basic Agent movements in Minecraft

  • Move along
  • Turn

The code example at the end of the post, is part of a ConsoleApp, which once connected to the Minecraft host, controls the movement of the current player / agent. The script advances a series of steps, then turns and returns to the advance mode again and again. Animation sample.

2017 11 19 Malmo Movements 01.gif

The basic set of commands are

  • Move > “move {1}”
  • Turn > “turn {1}”

Where the first parameter is an integer between 0 and 1 that defines the movement to be performed. These 2 commands are the minimum we can use in scenarios such as a labyrinth, so it makes sense that the next post talk about it.

namespace Malmo06
{
class Program
{
private static AgentHost _agentHost;
private static MissionSpec _mission;
private static MissionRecordSpec _missionRecord;
private static WorldState _worldState;
public static void Main()
{
InitAgentHost();
InitMissionSpecs();
StartMission();
WaitMissionToStart();
Console.WriteLine("Mission in progress !");
Console.WriteLine();
int i = 0;
do
{
i++;
var command = "move 0.5";
if (i > 3)
{
i = 0;
command = "turn 0.5";
_agentHost.sendCommand(command);
Thread.Sleep(500);
command = "turn 0";
_agentHost.sendCommand(command);
Thread.Sleep(500);
}
else
{
_agentHost.sendCommand(command);
Thread.Sleep(1000);
}
Console.WriteLine($"{i} – command: {command}");
// Move
} while (_worldState.is_mission_running);
Console.WriteLine("Mission has stopped.");
}

Sample Project en GitHub link

Greetings @ Toronto

El Bruno

References

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.