Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: microsoft/malmo
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.22.0
Choose a base ref
...
head repository: microsoft/malmo
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Aug 6, 2016

  1. Copy the full SHA
    e154c29 View commit details

Commits on Aug 8, 2016

  1. Copy the full SHA
    ae5c98b View commit details

Commits on Jun 6, 2017

  1. Copy the full SHA
    b97e9a7 View commit details
  2. Updating to new forge

    DaveyBiggers committed Jun 6, 2017
    Copy the full SHA
    a1c8744 View commit details

Commits on Jun 8, 2017

  1. Copy the full SHA
    4001f1c View commit details
  2. Copy the full SHA
    6f9bf58 View commit details
  3. Experiment

    DaveyBiggers authored Jun 8, 2017
    Copy the full SHA
    fef45a1 View commit details
  4. Experiment...

    DaveyBiggers authored Jun 8, 2017
    Copy the full SHA
    3a26656 View commit details

Commits on Jun 9, 2017

  1. Copy the full SHA
    560b002 View commit details
  2. Copy the full SHA
    2b472db View commit details
  3. Copy the full SHA
    0718ec9 View commit details
  4. Copy the full SHA
    1f44a34 View commit details

Commits on Jun 13, 2017

  1. Copy the full SHA
    6c3a7c4 View commit details
  2. Updated types.xsd with new (MC 1.9, 1.10 and 1.11) entities, and fill…

    …ed in missing ones (closes #384)
    DaveyBiggers committed Jun 13, 2017
    Copy the full SHA
    0931c16 View commit details

Commits on Jun 16, 2017

  1. 1
    Copy the full SHA
    fda5e64 View commit details
  2. Fix for key hang

    DaveyBiggers committed Jun 16, 2017
    Copy the full SHA
    09cece4 View commit details

Commits on Jun 19, 2017

  1. Copy the full SHA
    4d06b91 View commit details
  2. Fixed world loading

    DaveyBiggers committed Jun 19, 2017
    Copy the full SHA
    c6d8f71 View commit details
  3. Copy the full SHA
    24333c3 View commit details

Commits on Jun 20, 2017

  1. Copy the full SHA
    7986efe View commit details
  2. New forge licence

    DaveyBiggers committed Jun 20, 2017
    Copy the full SHA
    eb8c930 View commit details
  3. Options for new MC

    DaveyBiggers committed Jun 20, 2017
    Copy the full SHA
    4c982a9 View commit details
  4. Tidied build.gradle

    DaveyBiggers committed Jun 20, 2017
    Copy the full SHA
    e0ae79a View commit details
  5. Copy the full SHA
    09b8bfd View commit details
  6. Copy the full SHA
    c943c89 View commit details
  7. Copy the full SHA
    7cb88f7 View commit details
  8. Updated version number

    DaveyBiggers committed Jun 20, 2017
    Copy the full SHA
    8d2877c View commit details
  9. Copy the full SHA
    fb3b75a View commit details
  10. Fix typo

    DaveyBiggers committed Jun 20, 2017
    Copy the full SHA
    5f7901b View commit details
  11. Copy the full SHA
    f5bcf6c View commit details
  12. Copy the full SHA
    352c595 View commit details
  13. Merge pull request #558 from Microsoft/newMC

    Update to newer version of Minecraft
    DaveyBiggers authored Jun 20, 2017
    Copy the full SHA
    b246ca3 View commit details

Commits on Jun 23, 2017

  1. Copy the full SHA
    d78c567 View commit details

Commits on Jul 4, 2017

  1. Copy the full SHA
    aa55291 View commit details
  2. Copy the full SHA
    a38ebc4 View commit details

Commits on Jul 7, 2017

  1. Copy the full SHA
    387be4c View commit details
  2. Copy the full SHA
    70ef288 View commit details
  3. Copy the full SHA
    74e7897 View commit details
  4. Copy the full SHA
    300bd75 View commit details
  5. Copy the full SHA
    9f7b677 View commit details
  6. Merge pull request #573 from Microsoft/authFixes

    Auth fixes
    DaveyBiggers authored Jul 7, 2017
    Copy the full SHA
    11ed272 View commit details

Commits on Jul 10, 2017

  1. Fixed NPE in recipe dump

    DaveyBiggers committed Jul 10, 2017
    Copy the full SHA
    16a2431 View commit details
  2. Copy the full SHA
    960fe34 View commit details

Commits on Jul 14, 2017

  1. Expanded inventory observations to work with nearby containers; begun…

    … to expand inv commands likewise.
    DaveyBiggers committed Jul 14, 2017
    Copy the full SHA
    722be1d View commit details
  2. Copy the full SHA
    1675823 View commit details
  3. Copy the full SHA
    a0b03d5 View commit details
  4. Copy the full SHA
    fce5345 View commit details

Commits on Jul 17, 2017

  1. Copy the full SHA
    a0598b3 View commit details
  2. Copy the full SHA
    4d091e9 View commit details
  3. Copy the full SHA
    97e36b8 View commit details
Showing 387 changed files with 31,391 additions and 9,794 deletions.
133 changes: 79 additions & 54 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -17,47 +17,63 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ------------------------------------------------------------------------------------------------

cmake_minimum_required( VERSION 2.8 )
cmake_minimum_required( VERSION 3.8 )

project( Malmo )

# -------------------- Options --------------------------------

set( MALMO_VERSION_MAJOR 0)
set( MALMO_VERSION_MINOR 22)
set( MALMO_VERSION_REVISION 0)
file( STRINGS "VERSION" MALMO_VERSION_FILE )
string( REPLACE "." ";" MALMO_VERSION_LIST ${MALMO_VERSION_FILE} )
list( GET MALMO_VERSION_LIST 0 MALMO_VERSION_MAJOR )
list( GET MALMO_VERSION_LIST 1 MALMO_VERSION_MINOR )
list( GET MALMO_VERSION_LIST 2 MALMO_VERSION_REVISION )
set( MALMO_VERSION ${MALMO_VERSION_MAJOR}.${MALMO_VERSION_MINOR}.${MALMO_VERSION_REVISION} )

message("Configure MALMO_VERSION at ${MALMO_VERSION}")

# N.B. Check that this version number matches the ones in the schemas.

set( BUILD_MOD_DESC "Specifies whether to build the Malmo Minecraft Mod" )
set( BUILD_DOCUMENTATION_DESC "Specifies whether to build the documentation for the API and XML" )
set( INCLUDE_ALE_DESC "Specifies whether to build Malmo with bindings to the Arcade Learning Environment" )
set( INCLUDE_CSHARP_DESC "Specifies whether to build Malmo with C# bindings" )
set( INCLUDE_JAVA_DESC "Specifies whether to build Malmo with Java bindings" )
set( INCLUDE_LUA_DESC "Specifies whether to build Malmo with Lua bindings (Linux only)" )
set( INCLUDE_PYTHON_DESC "Specifies whether to build Malmo with Python bindings" )
set( INCLUDE_TORCH_DESC "Specifies whether to build Malmo with Torch bindings (Linux only)" )
set( STATIC_BOOST_DESC "Specifies whether to link Malmo statically against Boost" )
set( BUILD_MOD ON CACHE BOOL ${BUILD_MOD_DESC} )
set( BUILD_DOCUMENTATION ON CACHE BOOL ${BUILD_DOCUMENTATION_DESC} )
set( INCLUDE_ALE OFF CACHE BOOL ${INCLUDE_ALE_DESC} )
set( INCLUDE_CSHARP ON CACHE BOOL ${INCLUDE_CSHARP_DESC} )
set( INCLUDE_JAVA ON CACHE BOOL ${INCLUDE_JAVA_DESC} )
set( INCLUDE_PYTHON ON CACHE BOOL ${INCLUDE_PYTHON_DESC} )
set( STATIC_BOOST OFF CACHE BOOL ${STATIC_BOOST_DESC} )
set( STATIC_BOOST ON CACHE BOOL ${STATIC_BOOST_DESC} )

if( INCLUDE_PYTHON )
set( USE_PYTHON_VERSIONS_DESC "Specifies which versions of Python to build Malmo with Python bindings" )
set( USE_PYTHON_VERSIONS 2.7 CACHE STRING ${USE_PYTHON_VERSIONS_DESC} )
endif()
if( UNIX AND NOT APPLE )
set( INCLUDE_LUA ON CACHE BOOL ${INCLUDE_LUA_DESC} )
set( INCLUDE_TORCH ON CACHE BOOL ${INCLUDE_TORCH_DESC} )
else()
# Lua and Torch not currently supported
set( INCLUDE_LUA OFF CACHE BOOL ${INCLUDE_LUA_DESC} )
set( INCLUDE_TORCH OFF CACHE BOOL ${INCLUDE_TORCH_DESC} )
set( USE_PYTHON_VERSIONS_DESC "Specifies which version of Python to build Malmo with Python bindings" )
set( USE_PYTHON_VERSIONS 3.6 CACHE STRING ${USE_PYTHON_VERSIONS_DESC} )
if (NOT BOOST_PYTHON_NAME)
message("The name of the Boost Python library has not been set - trying to
determine it automatically...")
set(BOOST_PYTHON_NAME_DESC "Specifies which Boost Python module to build Malmo with" )

if (Boost_VERSION VERSION_GREATER 1.67 )
# From version 1.67 and up, Boost appends the Python version number to
# the library name by default.
# (https://www.boost.org/users/history/version_1_67_0.html)
execute_process(
COMMAND python3 -c "import sys; print('python' + str(sys.version_info[0]) + str(sys.version_info[1]), end='')"
OUTPUT_VARIABLE BOOST_PYTHON_NAME
)
else()
set (BOOST_PYTHON_NAME "python")
endif()
message("BOOST_PYTHON_NAME set to ${BOOST_PYTHON_NAME}. To override it, add
the flag -DBOOST_PYTHON_NAME=<name> where <name> is the name of the Boost
Python library on your system (see https://github.com/boostorg/build/pull/250).")
endif()
endif()

set( WARNINGS_AS_ERRORS OFF )

# ------------------- Detect the system -----------------------
@@ -75,10 +91,14 @@ elseif( UNIX )
elseif( EXISTS "/etc/debian_version")
file( READ /etc/debian_version DEBIAN_VERSION )
set( SYSTEM_NAME "${SYSTEM_NAME}-${DEBIAN_VERSION}")
elseif( EXISTS "/etc/os-release")
execute_process(COMMAND "sed" "-ne" "s/^ID=\"\\?\\([a-z]\\+\\)\"\\?$/\\1/p" "/etc/os-release" OUTPUT_VARIABLE OS_RELEASE_ID OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "sed" "-ne" "s/^VERSION_ID=\"\\?\\([0-9\\.]\\+\\)\"\\?$/\\1/p" "/etc/os-release" OUTPUT_VARIABLE OS_RELEASE_VERSION_ID OUTPUT_STRIP_TRAILING_WHITESPACE)
set( SYSTEM_NAME "${SYSTEM_NAME}-${OS_RELEASE_ID}-${OS_RELEASE_VERSION_ID}")
elseif( EXISTS "/etc/redhat-release")
set( SYSTEM_NAME "${SYSTEM_NAME}-Redhat")
endif()
elseif( WIN32)
elseif( WIN32 )
set( SYSTEM_NAME "Windows" )
endif()
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
@@ -88,47 +108,70 @@ else()
endif()

# -------------------- Find packages --------------------------

if ( WIN32 )
enable_language( CSharp )
else()
set( INCLUDE_CSHARP OFF )
endif()

set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake )

SET(Boost_ADDITIONAL_VERSIONS "1.59" "1.59.0")
SET(Boost_ADDITIONAL_VERSIONS "1.60" "1.60.0")
SET(Boost_ADDITIONAL_VERSIONS "1.61" "1.61.0")
SET(Boost_ADDITIONAL_VERSIONS "1.62" "1.62.0")
SET(Boost_ADDITIONAL_VERSIONS "1.63" "1.63.0")
SET(Boost_ADDITIONAL_VERSIONS "1.65" "1.65.0")
SET(Boost_ADDITIONAL_VERSIONS "1.66" "1.66.0")
SET(Boost_ADDITIONAL_VERSIONS "1.67" "1.67.0")
SET(Boost_ADDITIONAL_VERSIONS "1.68" "1.68.0")
SET(Boost_ADDITIONAL_VERSIONS "1.69" "1.69.0")
SET(Boost_ADDITIONAL_VERSIONS "1.70" "1.70.0")

# Boost release variant builds have symbol visibility set to hidden by default
# (https://boostorg.github.io/build/manual/develop/index.html#bbv2.overview.builtins.features)
# The line below adds compilation flags to make the visibility settings for compiling Malmo
# consistent with the visibility settings for Boost, and fixes linking warnings emitted by the
# GCC 9 compiler.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden")

# This allows users to override the Boost Python library name if different from
# the defaults (this can occur with certain package managers - e.g. For Boost compiled against Python 3.6,
# MacPorts would name the Boost Python library as libboost_python3 instead of libboost_python36).


if( WIN32 )
SET(Boost_USE_STATIC_LIBS ON)
find_package( Boost COMPONENTS chrono date_time filesystem iostreams program_options python regex system thread zlib REQUIRED )
find_package( Boost COMPONENTS chrono date_time filesystem iostreams program_options ${BOOST_PYTHON_NAME} regex system thread REQUIRED )
add_definitions(-DBOOST_ALL_NO_LIB=1) # Turn off auto-linking, creates problems when linking boost statically
else()
find_package( Boost COMPONENTS chrono date_time filesystem iostreams program_options python regex system thread REQUIRED )
SET(Boost_USE_STATIC_LIBS ${STATIC_BOOST})
find_package( Boost COMPONENTS chrono date_time filesystem iostreams program_options ${BOOST_PYTHON_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
if( WIN32)
set( XSD_ROOT "C:/Program Files (x86)/CodeSynthesis XSD 4.0" )
else()
if( NOT WIN32)
set( ALE_ROOT_DIR ~/ALE )
endif()

if( INCLUDE_CSHARP )
# Select the .NET architecture
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set( CSHARP_PLATFORM "x64" CACHE STRING "C# target platform: x86, x64, anycpu, or itanium")
else()
set( CSHARP_PLATFORM "x86" CACHE STRING "C# target platform: x86, x64, anycpu, or itanium")
endif()
find_package( CSharp REQUIRED )
endif()

if( BUILD_DOCUMENTATION )
find_package( Doxygen REQUIRED )
endif()

find_package( Git REQUIRED )
find_package( Java REQUIRED COMPONENTS Runtime Development )
find_package( ZLIB REQUIRED )

if ( INCLUDE_JAVA OR BUILD_MOD )
find_package( Java REQUIRED COMPONENTS Runtime Development )
endif()

if( INCLUDE_JAVA )
find_package( JNI REQUIRED)
endif()
@@ -140,27 +183,6 @@ if( INCLUDE_PYTHON )
endif()

find_package( SWIG REQUIRED )
find_package( Xsd REQUIRED )

if( INCLUDE_LUA )
set( LUABIND_ROOT_DIR ~/rpavlik-luabind/build/src )
find_package( Luabind REQUIRED )
else()
set( INCLUDE_TORCH OFF CACHE BOOL ${INCLUDE_TORCH_DESC} FORCE ) # (can't build for Torch without Lua)
endif()

if( INCLUDE_TORCH )
find_package( Torch QUIET HINTS ~/torch/install/share/cmake/torch )
if( NOT Torch_FOUND )
# for now Torch is only available on Ubuntu and a few other platforms, so we warn but continue
message( "" )
message( " ==== WARNING: ====" )
message( "" )
message( " Torch was not found! Build will proceed but without the Torch parts included." )
message( "" )
set( INCLUDE_TORCH OFF CACHE BOOL ${INCLUDE_TORCH_DESC} FORCE )
endif()
endif()

if( INCLUDE_ALE )
find_package(ALE QUIET)
@@ -187,7 +209,6 @@ endif ()

if( MSVC )
set( MALMO_PYTHON_DIR ${CMAKE_BINARY_DIR}/Malmo/src/PythonWrapper/$<CONFIG> )
set( MALMO_LUA_DIR ${CMAKE_BINARY_DIR}/Malmo/src/LuaWrapper/$<CONFIG> )
set( MALMO_CSHARP_DIR ${CMAKE_BINARY_DIR}/Malmo/src/CSharpWrapper/$<CONFIG> )
if( WARNINGS_AS_ERRORS )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX" )
@@ -197,7 +218,6 @@ if( MSVC )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS" )
else()
set( MALMO_PYTHON_DIR ${CMAKE_BINARY_DIR}/Malmo/src/PythonWrapper )
set( MALMO_LUA_DIR ${CMAKE_BINARY_DIR}/Malmo/src/LuaWrapper )
set( MALMO_CSHARP_DIR ${CMAKE_BINARY_DIR}/Malmo/src/CSharpWrapper )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
if( WARNINGS_AS_ERRORS )
@@ -249,13 +269,18 @@ if( INCLUDE_ALE )
add_subdirectory( ALE_ROMS )
endif()

# Save a small properties file, so we can easily tell what version of python this was built against, etc.
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/malmo.properties malmo.properties )
INSTALL( FILES ${CMAKE_BINARY_DIR}/malmo.properties DESTINATION .)

# -------------------- Package ------------------------------------
if( INCLUDE_ALE )
set( SYSTEM_NAME "${SYSTEM_NAME}_withALE" )
endif()
if ( STATIC_BOOST )
set( SYSTEM_NAME "${SYSTEM_NAME}_withBoost" )
endif()
set( SYSTEM_NAME "${SYSTEM_NAME}_Python${USE_PYTHON_VERSIONS}" )
set( CPACK_SYSTEM_NAME ${SYSTEM_NAME} )
set( CPACK_PACKAGE_VERSION "${MALMO_VERSION}" )
set( CPACK_GENERATOR "ZIP" )
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 Microsoft Corporation
Copyright (c) 2016, 2018 Microsoft Corporation

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
7 changes: 0 additions & 7 deletions Malmo/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -31,10 +31,3 @@ if( INCLUDE_PYTHON )
add_subdirectory( Python_examples )
endif()

if( INCLUDE_LUA )
add_subdirectory( Lua_examples )
endif()

if( INCLUDE_TORCH )
add_subdirectory( Torch_examples )
endif()
68 changes: 12 additions & 56 deletions Malmo/samples/CSharp_examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -17,65 +17,21 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# ------------------------------------------------------------------------------------------------

find_package( CSharp REQUIRED )
include( ${CSHARP_USE_FILE} )
# build the example CSharp mission

set( CSHARP_SAMPLE_SOURCES
App.config
Program.cs
)
add_executable( CSharpExamples_RunMission RunMission.cs )

configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/RunMission.csproj.pre ${CMAKE_CURRENT_SOURCE_DIR}/RunMission.csproj )
target_link_libraries( CSharpExamples_RunMission MalmoNET MalmoNETNative )

# install the executable

if( WIN32 )
SET( CSHARP_BUILD ${CMAKE_VS_MSBUILD_COMMAND} )
set( CSHARP_RUN "" )
set( CURRENT_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG> )
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration)/CSharpExamples_RunMission.exe
COMMAND ${CSHARP_BUILD}
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/RunMission.csproj /p:Configuration=$<CONFIG> /p:Platform=${CSHARP_PLATFORM} /p:OutputPath=${CURRENT_BUILD_DIR} /t:Clean,Build
DEPENDS Malmo MalmoNET ${CSHARP_SAMPLE_SOURCES}
)
add_custom_target(
CSharpExamples_RunMission ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/$(Configuration)/CSharpExamples_RunMission.exe
SOURCES ${CSHARP_SAMPLE_SOURCES}
)
else()
SET( CSHARP_BUILD xbuild )
set( CSHARP_RUN "mono" )
set( CURRENT_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR} )
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/CSharpExamples_RunMission.exe
COMMAND ${CSHARP_BUILD}
ARGS ${CMAKE_CURRENT_SOURCE_DIR}/RunMission.csproj /p:Platform=${CSHARP_PLATFORM} /p:OutputPath=${CMAKE_CURRENT_BINARY_DIR} /t:clean /t:build /p:TargetFrameworkVersion=v4.5
DEPENDS Malmo MalmoNET ${CSHARP_SAMPLE_SOURCES}
)
add_custom_target(
CSharpExamples_RunMission ALL
DEPENDS ${CURRENT_BUILD_DIR}/CSharpExamples_RunMission.exe
SOURCES ${CSHARP_SAMPLE_SOURCES}
)
endif()
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/CSharpExamples_RunMission.exe DESTINATION CSharp_Examples )
else( UNIX )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/CSharpExamples_RunMission.exe DESTINATION CSharp_Examples )
endif( WIN32 )

INSTALL( FILES ${CURRENT_BUILD_DIR}/CSharpExamples_RunMission.exe DESTINATION CSharp_Examples )

# add integration tests
add_test(
NAME CSharpIntegrationTests_RunMission_help
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CSHARP_RUN} ${CURRENT_BUILD_DIR}/CSharpExamples_RunMission.exe --help
)
set_tests_properties( CSharpIntegrationTests_RunMission_help PROPERTIES ENVIRONMENT "MALMO_XSD_PATH=$ENV{MALMO_XSD_PATH}" )
add_test(
NAME CSharpIntegrationTests_RunMission
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND ${CSHARP_RUN} ${CURRENT_BUILD_DIR}/CSharpExamples_RunMission.exe --test
)
set_tests_properties( CSharpIntegrationTests_RunMission PROPERTIES ENVIRONMENT "MALMO_XSD_PATH=$ENV{MALMO_XSD_PATH}" )
# install the sample files

INSTALL( FILES App.config DESTINATION CSharp_Examples )
INSTALL( FILES Program.cs DESTINATION CSharp_Examples )
INSTALL( FILES Properties/AssemblyInfo.cs DESTINATION CSharp_Examples/Properties/ )
INSTALL( FILES RunMission.csproj.in DESTINATION CSharp_Examples RENAME RunMission.csproj )
install( FILES RunMission.cs install_files/App.config install_files/RunMission.sln install_files/RunMission.csproj DESTINATION CSharp_Examples)
install( FILES install_files/Properties/AssemblyInfo.cs DESTINATION CSharp_Examples/Properties)
36 changes: 22 additions & 14 deletions Malmo/samples/CSharp_examples/Program.cs → Malmo/samples/CSharp_examples/RunMission.cs
100755 → 100644
Original file line number Diff line number Diff line change
@@ -53,22 +53,30 @@ public static void Main()
missionRecord.recordRewards();
missionRecord.recordObservations();

try
bool connected = false;
int attempts = 0;
while (!connected)
{
agentHost.startMission(mission, missionRecord);
try
{
attempts += 1;
agentHost.startMission(mission, missionRecord);
connected = true;
}
catch (MissionException ex)
{
// Using catch(Exception ex) would also work, but specifying MissionException allows
// us to access the error code:
Console.Error.WriteLine("Error starting mission: {0}", ex.Message);
Console.Error.WriteLine("Error code: {0}", ex.getMissionErrorCode());
// We can do more specific error handling using this code, eg:
if (ex.getMissionErrorCode() == MissionException.MissionErrorCode.MISSION_INSUFFICIENT_CLIENTS_AVAILABLE)
Console.Error.WriteLine("Have you started a Minecraft client?");
if (attempts >= 3) // Give up after three goes.
Environment.Exit(1);
Thread.Sleep(1000); // Wait a second and try again.
}
}
catch (MissionException ex)
{
// Using catch(Exception ex) would also work, but specifying MissionException allows
// us to access the error code:
Console.Error.WriteLine("Error starting mission: {0}", ex.Message);
Console.Error.WriteLine("Error code: {0}", ex.getMissionErrorCode());
// We can do more specific error handling using this code, eg:
if (ex.getMissionErrorCode() == MissionException.MissionErrorCode.MISSION_INSUFFICIENT_CLIENTS_AVAILABLE)
Console.Error.WriteLine("Have you started a Minecraft client?");
Environment.Exit(1);
}

WorldState worldState;

Console.WriteLine("Waiting for the mission to start");
Loading