Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8fae8be
Readded craft handlers and slight changes to argument
ccodel Oct 31, 2018
8d5f166
Reimplemented craft, collect handlers, added possess handler with dec…
ccodel Dec 6, 2018
230f49b
Added smelting reward and quit handlers
ccodel Feb 6, 2019
f1cf5d6
Bulk of implementation done, onto testing
ccodel Feb 9, 2019
c532889
Updated smelting to call matcher once every four now
ccodel Feb 9, 2019
74d89b3
Merge branch 'master' into craftEdits
brandonhoughton Feb 10, 2019
8d84d9b
Implemented nearby handlers, with lots of trig
ccodel Feb 13, 2019
4abdbca
Added some other files I guess
ccodel Feb 13, 2019
e60eb60
One more too
ccodel Feb 13, 2019
3ee2052
Fixed merge issues
ccodel Feb 13, 2019
3afbd41
Added place commands, not yet tested
ccodel Feb 20, 2019
c9c9e33
Swapped items back
ccodel Feb 20, 2019
a12f533
Updated commands for cayden's new handlers
brandonhoughton Feb 22, 2019
f815035
Merged master into craft edits
brandonhoughton Feb 22, 2019
60e4ea6
Reimplemented craft, collect handlers, added possess handler with dec…
ccodel Dec 6, 2018
f5776ac
Added smelting reward and quit handlers
ccodel Feb 6, 2019
2797851
Bulk of implementation done, onto testing
ccodel Feb 9, 2019
6c8586f
Updated smelting to call matcher once every four now
ccodel Feb 9, 2019
3b16457
Implemented nearby handlers, with lots of trig
ccodel Feb 13, 2019
353bf5c
Merged version changes
brandonhoughton Feb 22, 2019
222c084
Added place commands, not yet tested
ccodel Feb 20, 2019
a394b7f
Swapped items back
ccodel Feb 20, 2019
6da0907
Updated commands for cayden's new handlers
brandonhoughton Feb 22, 2019
af08f90
Merge branch 'craftEdits' of github.com:cmu-rl/malmo into craftEdits
brandonhoughton Feb 22, 2019
6c54ed2
Correct small isues with command naming
brandonhoughton Feb 22, 2019
36e611c
Fix API
brandonhoughton Feb 22, 2019
a4500e3
Fix api integration
brandonhoughton Feb 22, 2019
96ab4d6
Update value of craft and smelt nearby command
brandonhoughton Feb 22, 2019
bbdc0d4
Add new commands to python api =(
brandonhoughton Feb 22, 2019
8c2cb18
Revert testing change
brandonhoughton Feb 22, 2019
b2c5f93
Skrew the API
brandonhoughton Feb 22, 2019
89680e7
Java != Python
brandonhoughton Feb 22, 2019
3df3ebb
Made things strictly better
brandonhoughton Feb 22, 2019
7a901e9
Dont do silly things
brandonhoughton Feb 22, 2019
d284fdb
Make new messeges to pass to cute squirrels
brandonhoughton Feb 23, 2019
04a3c26
Likely need a new channel for each message
brandonhoughton Feb 23, 2019
b188b83
Check for non-existant items
brandonhoughton Feb 23, 2019
5a8de6b
Updated place logic
ccodel Feb 28, 2019
231bba9
Updated handler logic, how Forge events are fired
ccodel Mar 1, 2019
eda8aaf
Brandon/ref (#9)
brandonhoughton Mar 2, 2019
a9d9c35
Polished up all new handlers and commands
ccodel Mar 3, 2019
d6da97a
Added sample XML, removed print statements in smelt
ccodel Mar 3, 2019
112422c
Rebased original files from master
ccodel Mar 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ ClientBin/
*.pfx
*.publishsettings
node_modules/
.DS_Store

# RIA/Silverlight projects
Generated_Code/
Expand Down
16 changes: 10 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ set( STATIC_BOOST ON CACHE BOOL ${STATIC_BOOST_DESC} )

if( INCLUDE_PYTHON )
set( USE_PYTHON_VERSIONS_DESC "Specifies which version of Python to build Malmo with Python bindings" )
set( MACOS_USE_PYTHON_MODULE_DESC "Specifies which Python module to build Malmo on Apple MacOS" )
set( USE_PYTHON_VERSIONS 3.6 CACHE STRING ${USE_PYTHON_VERSIONS_DESC} )
set( BOOST_PYTHON_NAME_DESC "Specifies which Boost Python module to build Malmo with" )
set( BOOST_PYTHON_NAME "python3" CACHE STRING ${BOOST_PYTHON_NAME_DESC} )
# Boost has switched to using a 2 digit naming convention for python on MacOS.
set( MACOS_USE_PYTHON_MODULE "python37" CACHE STRING ${MACOS_USE_PYTHON_MODULE_DESC} )
endif()

set( WARNINGS_AS_ERRORS OFF )
Expand Down Expand Up @@ -105,18 +106,21 @@ SET(Boost_ADDITIONAL_VERSIONS "1.67" "1.67.0")

SET(BOOST_PYTHON_MODULE_NAME "python")
if ( USE_PYTHON_VERSIONS VERSION_GREATER 3 )
SET( BOOST_PYTHON_MODULE_NAME ${BOOST_PYTHON_NAME} )
if ( APPLE )
SET( BOOST_PYTHON_MODULE_NAME ${MACOS_USE_PYTHON_MODULE} )
else()
SET( BOOST_PYTHON_MODULE_NAME "python3" )
endif()
endif()

if( WIN32 )
SET(Boost_USE_STATIC_LIBS ON)
find_package( Boost COMPONENTS chrono date_time filesystem iostreams program_options ${BOOST_PYTHON_MODULE_NAME} regex system thread REQUIRED )
add_definitions(-DBOOST_ALL_NO_LIB=1) # Turn off auto-linking, creates problems when linking boost statically
find_package( Boost COMPONENTS chrono date_time filesystem iostreams program_options ${BOOST_PYTHON_MODULE_NAME} regex system thread zlib REQUIRED )
else()
SET(Boost_USE_STATIC_LIBS ${STATIC_BOOST})
find_package( Boost COMPONENTS chrono date_time filesystem iostreams program_options ${BOOST_PYTHON_MODULE_NAME} regex system thread REQUIRED )
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package( Threads REQUIRED )
SET(Boost_USE_STATIC_LIBS ${STATIC_BOOST})
endif()

# suggested install paths - see readme.md
Expand Down
22 changes: 22 additions & 0 deletions Malmo/samples/samples.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>MIXIN</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/Java_examples" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="com.microsoft.MalmoMod.Minecraft.main" exported="" />
<orderEntry type="module" module-name="com.microsoft.MalmoMod.Minecraft.test" scope="TEST" />
</component>
</module>
33 changes: 32 additions & 1 deletion Malmo/src/MissionSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ namespace malmo
const std::vector<std::string> MissionSpec::all_inventory_commands = { "swapInventoryItems", "combineInventoryItems", "discardCurrentItem",
"hotbar.1", "hotbar.2", "hotbar.3", "hotbar.4", "hotbar.5", "hotbar.6", "hotbar.7", "hotbar.8", "hotbar.9" };
const std::vector<std::string> MissionSpec::all_simplecraft_commands = { "craft" };
const std::vector<std::string> MissionSpec::all_nearbycraft_commands = { "craftNearby" };
const std::vector<std::string> MissionSpec::all_nearbysmelt_commands = { "smeltNearby" };
const std::vector<std::string> MissionSpec::all_chat_commands = { "chat" };
const std::vector<std::string> MissionSpec::all_mission_quit_commands = { "quit" };
const std::vector<std::string> MissionSpec::all_human_level_commands = { "forward", "left", "right", "jump", "sneak", "sprint", "inventory", "swapHands", "drop", "use", "attack", "moveMouse",
Expand Down Expand Up @@ -110,6 +112,7 @@ namespace malmo
child.erase("FlatWorldGenerator");
child.erase("FileWorldGenerator");
child.erase("DefaultWorldGenerator");
child.erase("BiomeGenerator");
}
}

Expand Down Expand Up @@ -137,6 +140,11 @@ namespace malmo
if (defaultWorldGenerator) {
defaultWorldGenerator.get().put("<xmlattr>.forceReset", true);
}
const auto& biomeWorldGenerator =
mission.get_child_optional("Mission.ServerSection.ServerHandlers.BiomeGenerator");
if (biomeWorldGenerator) {
biomeWorldGenerator.get().put("<xmlattr>.forceReset", true);
}
}

void MissionSpec::setTimeOfDay(int t,bool allowTimeToPass)
Expand Down Expand Up @@ -376,6 +384,9 @@ namespace malmo
child.erase("DiscreteMovementCommands");
child.erase("AbsoluteMovementCommands");
child.erase("SimpleCraftCommands");
child.erase("NearbyCraftCommands");
child.erase("NearbySmeltCommands");
child.erase("PlaceCommands");
child.erase("ChatCommands");
child.erase("MissionQuitCommands");
}
Expand Down Expand Up @@ -420,11 +431,16 @@ namespace malmo
{
addVerbToCommandType(verb, "Mission.AgentSection.AgentHandlers.InventoryCommands");
}

void MissionSpec::allowAllChatCommands()
{
mission.put("Mission.AgentSection.AgentHandlers.ChatCommands", "");
}

void MissionSpec::allowAllPlaceCommands()
{
mission.put("Mission.AgentSection.AgentHandlers.PlaceCommands", "");
}

// ------------------------------- information ---------------------------------------------------

Expand Down Expand Up @@ -522,6 +538,15 @@ namespace malmo

if (e.second.get_child_optional("AgentHandlers.SimpleCraftCommands"))
command_handlers.push_back("SimpleCraft");

if (e.second.get_child_optional("AgentHandlers.NearbyCraftCommands"))
command_handlers.push_back("NearbyCraft");

if (e.second.get_child_optional("AgentHandlers.NearbySmeltCommands"))
command_handlers.push_back("NearbySmelt");

if (e.second.get_child_optional("AgentHandlers.PlaceCommands"))
command_handlers.push_back("Place");

if (e.second.get_child_optional("AgentHandlers.MissionQuitCommands"))
command_handlers.push_back("MissionQuit");
Expand Down Expand Up @@ -582,6 +607,12 @@ namespace malmo
else if (command_handler == "SimpleCraft") {
allowed_commands = all_simplecraft_commands;
}
else if (command_handler == "NearbyCraft") {
allowed_commands = all_nearbycraft_commands;
}
else if (command_handler == "NearbySmelt") {
allowed_commands = all_nearbysmelt_commands;
}
else if (command_handler == "Chat") {
allowed_commands = all_chat_commands;
}
Expand Down
6 changes: 6 additions & 0 deletions Malmo/src/MissionSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,10 @@ namespace malmo
//! Only applies to the first agent in the mission. For multi-agent missions, specify the command handlers for each in the XML.
void allowAllChatCommands();

//! Adds a place command handler if none present, with neither an allow-list or a deny-list, thus allowing any command to be sent.
//! Only applies to the first agent in the mission. For multi-agent missions, specify the command handlers for each in the XML.
void allowAllPlaceCommands();

// ------------------------- information --------------------------------------

//! Returns the short description of the mission.
Expand Down Expand Up @@ -382,6 +386,8 @@ namespace malmo
static const std::vector<std::string> all_discrete_movement_commands;
static const std::vector<std::string> all_inventory_commands;
static const std::vector<std::string> all_simplecraft_commands;
static const std::vector<std::string> all_nearbycraft_commands;
static const std::vector<std::string> all_nearbysmelt_commands;
static const std::vector<std::string> all_chat_commands;
static const std::vector<std::string> all_mission_quit_commands;
static const std::vector<std::string> all_human_level_commands;
Expand Down
20 changes: 20 additions & 0 deletions MalmoEnv/malmoenv/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class CommandParser:
inventoryCommands = "Inventory"
chatCommands = "Chat"
simpleCraftCommands = "SimpleCraft"
nearbyCraftCommands = "NearbyCraft"
nearbySmeltCommands = "NearbySmelt"
missionQuitCommands = "MissionQuit"
humanLevelCommands = "HumanLevel"

Expand All @@ -50,6 +52,8 @@ class CommandParser:
"hotbar.7", "hotbar.8", "hotbar.9"]
all_chat = ["chat"]
all_simplecraft = ["craft"]
all_nearbycraft = ["nearbyCraft"]
all_nearbysmelt = ["nearbySmelt"]
all_mission_quit = ["quit"]
all_human_level = ["forward", "left", "right", "jump", "sneak", "sprint", "inventory",
"swapHands", "drop", "use", "attack", "moveMouse",
Expand Down Expand Up @@ -126,6 +130,14 @@ def get_actions(self, commands):
if verb != 'chat':
raise CommandHandlerException("Invalid chat command")
actions.append(verb)
elif type == 'NearbyCraft':
if verb != 'nearbyCraft':
raise CommandHandlerException("Invalid nearby craft command")
actions.append(verb)
elif type == 'NearbySmelt':
if verb != 'nearbySmelt':
raise CommandHandlerException("Invalid nearby smelt command")
actions.append(verb)
elif type == 'SimpleCraft':
if verb != 'craft':
raise CommandHandlerException("Invalid craft command")
Expand All @@ -152,6 +164,10 @@ def _command_hander(self, handlers, turnbased, commands):
commands.extend(self._add_commands(CommandParser.chatCommands, turnbased, ch))
elif ch.tag == CommandParser.ns + "SimpleCraftCommands":
commands.extend(self._add_commands(CommandParser.simpleCraftCommands, turnbased, ch))
elif ch.tag == CommandParser.ns + "NearbyCraftCommands":
commands.extend(self._add_commands(CommandParser.nearbyCraftCommands, turnbased, ch))
elif ch.tag == CommandParser.ns + "NearbySmeltCommands":
commands.extend(self._add_commands(CommandParser.nearbySmeltCommands, turnbased, ch))
elif ch.tag == CommandParser.ns + "MissionQuitCommands":
commands.extend(self._add_commands(CommandParser.missionQuitCommands, turnbased, ch))
elif ch.tag == CommandParser.ns + "HumanLevelCommands":
Expand Down Expand Up @@ -189,6 +205,10 @@ def _fill_command_list(self, command_type, turnbased, allow, deny):
allow = [(command_type, turnbased, c) for c in CommandParser.all_human_level]
elif command_type == CommandParser.simpleCraftCommands:
allow = [(command_type, turnbased, c) for c in CommandParser.all_simplecraft]
elif command_type == CommandParser.nearbyCraftCommands:
allow = [(command_type, turnbased, c) for c in CommandParser.all_nearbycraft]
elif command_type == CommandParser.nearbySmeltCommands:
allow = [(command_type, turnbased, c) for c in CommandParser.all_nearbysmelt]
elif command_type == CommandParser.missionQuitCommands:
allow = [(command_type, turnbased, c) for c in CommandParser.missionQuitCommands]
elif command_type == CommandParser.chatCommands:
Expand Down
11 changes: 3 additions & 8 deletions Minecraft/src/main/java/com/microsoft/Malmo/MalmoMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package com.microsoft.Malmo;

import com.microsoft.Malmo.MissionHandlers.*;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
Expand Down Expand Up @@ -57,14 +58,6 @@
import net.minecraftforge.fml.relauncher.Side;

import com.microsoft.Malmo.Client.MalmoModClient;
import com.microsoft.Malmo.MissionHandlers.AbsoluteMovementCommandsImplementation;
import com.microsoft.Malmo.MissionHandlers.DiscreteMovementCommandsImplementation;
import com.microsoft.Malmo.MissionHandlers.InventoryCommandsImplementation;
import com.microsoft.Malmo.MissionHandlers.ObservationFromFullInventoryImplementation;
import com.microsoft.Malmo.MissionHandlers.ObservationFromFullStatsImplementation;
import com.microsoft.Malmo.MissionHandlers.ObservationFromGridImplementation;
import com.microsoft.Malmo.MissionHandlers.ObservationFromSystemImplementation;
import com.microsoft.Malmo.MissionHandlers.SimpleCraftCommandsImplementation;
import com.microsoft.Malmo.Schemas.MissionInit;
import com.microsoft.Malmo.Server.MalmoModServer;
import com.microsoft.Malmo.Utils.AddressHelper;
Expand Down Expand Up @@ -134,6 +127,8 @@ public void preInit(FMLPreInitializationEvent event)
network.registerMessage(ObservationFromGridImplementation.GridRequestMessageHandler.class, ObservationFromGridImplementation.GridRequestMessage.class, 2, Side.SERVER);
network.registerMessage(MalmoMessageHandler.class, MalmoMessage.class, 3, Side.CLIENT); // Malmo messages from server to client
network.registerMessage(SimpleCraftCommandsImplementation.CraftMessageHandler.class, SimpleCraftCommandsImplementation.CraftMessage.class, 4, Side.SERVER);
network.registerMessage(NearbyCraftCommandsImplementation.CraftNearbyMessageHandler.class, NearbyCraftCommandsImplementation.CraftNearbyMessage.class, 13, Side.SERVER);
network.registerMessage(NearbySmeltCommandsImplementation.SmeltNearbyMessageHandler.class, NearbySmeltCommandsImplementation.SmeltNearbyMessage.class, 14, Side.SERVER);
network.registerMessage(AbsoluteMovementCommandsImplementation.TeleportMessageHandler.class, AbsoluteMovementCommandsImplementation.TeleportMessage.class, 5, Side.SERVER);
network.registerMessage(MalmoMessageHandler.class, MalmoMessage.class, 6, Side.SERVER); // Malmo messages from client to server
network.registerMessage(InventoryCommandsImplementation.InventoryMessageHandler.class, InventoryCommandsImplementation.InventoryMessage.class, 7, Side.SERVER);
Expand Down
Loading