Buenas!
Hoy mostrare como realizar 2 movimientos básicos con un Agente en Minecraft
- Avanzar
- Girar
El ejemplo de código al final del post, representa una ConsoleApp, que una vez conectado al host Minecraft, adelanta una serie de pasos, luego gira y vuelve a adelantar. Ejemplo en modo gráfico.
Pues bien, los comandos que usamos son
- Avanzar > “move {1}”
- Girar > “turn {1}”
Donde el primer parámetro es un entero entre 0 y 1 que define el movimiento a realizar. Estos 2 comandos son los mínimos que podemos utilizar en escenarios como por ejemplo un laberinto, así que tiene sentido que el siguiente post hable de eso.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
Saludos @ Toronto
El Bruno
References
- El Bruno, Minecraft missions options in Xml format Project Malmo
- El Bruno, Sample ConsoleApp to initialize missions in Minecraft using an Xml file definition
- El Bruno, Definition of Minecraft missions in Xml format
- El Bruno, Minecraft game interaction agents, missions definitions and recording with Project Malmo
- El Bruno, Learning to code with Minecraft? start with Hour of Code, MakeCode and Project Malmo
- Malmo, GitHub Home
- Malmo Mission Xml Schema
- Malmo Mission Xml Weather
- Superflat Preset Generator