microsoft / malmo

Project Malmo is a platform for Artificial Intelligence experimentation and research built on top of Minecraft. We aim to inspire a new generation of research into challenging new problems presented by this unique environment. --- For installation instructions, scroll down to *Getting Started* below, or visit the project page for more information:
https://www.microsoft.com/en-us/research/project/project-malmo/
MIT License
4.09k stars 600 forks source link

Proposal for discussion: new `Grid` class in the API #108

Open timhutton opened 8 years ago

timhutton commented 8 years ago

Issues #105, #24 and #48 require a way to work with a cuboid of Minecraft block data and to send and save it efficiently.

A Grid class might have the following API:

void SetBlock(x,y,z,block_type)
void SetCuboid(x1,y1,z1,x2,y2,z2,block_type)
block_type GetBlockType(x,y,z)
string GetAsCompressedString()
void SetFromCompressedString(string)

The block data would be compressed as (e.g.) a base64 encoding of a zip of a JSON structure.

A new DrawingDecorator element would take such a compressed string, e.g.:

<DrawGrid x="10" y="60" z="10">
  ZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=
</DrawGrid>

Then the current ObservationFromGrid could have a new Boolean flag compressed (default=false) that determines if it sends as the current JSON string or the compressed version. Another flag sendOnlyAtStart (default=false) could specify if the observation is sent on every world tick or just at the beginning (after the generators have run). Another flag absoluteCoordinates (default=false) could specify whether the requested coordinates of the grid observation are relative to the player (as is currently the case) or in absolute coordinates, for e.g. retrieving a maze.

jorallo commented 8 years ago

I like it. Do all programming languages have base64 coders and decoders, like python, or is it always included in the JSON libraries independently of the language. Just to be sure that this solution is language-independent.

katja-hofmann commented 8 years ago

Sounds great! What would the format of the decoded json look like?

timhutton commented 8 years ago

@jorallo: My thought was that users can use Grid to extract whatever blocks they want from the compressed string. As part of the API it would be available in all the languages.

timhutton commented 8 years ago

@katja-hofmann: ObservationFromGrid currently sends a JSON structure with the block information in it, so the simplest is simply to use that.

TGlas commented 8 years ago

Sending potentially huge grids in the observer is nearly always wasteful, since subsequent frames have large overlap. An API for requesting blocks would be much better than having to decide beforehand which range to observe. At the very least the grid observer should contain an option to transfer only the differences to what's already known to the client. This boils down to the ability of sending shift information and sparse changes, maybe composed of sub-cuboids (since many changes are expected at the edges).