Package: test-evocraft-py
Evocraft-pyA Python interface for Minecraft built ongrpc.1. Set-uppython -m pip install test-evocraft-py2. Starting the modded Minecraft serverUsing python apiimport test_evocraft_py
test_evocraft_py.start_server()
# shutdown
test_evocraft_py.shutdown_server()Using cliUsage: test-evocraft-py [OPTIONS]

  Simple program that greets NAME for a total of COUNT times.

Options:
  --start / --shutdown  Start or shutdown server
  --interactive         Start server with interactive server console
  --help                Show this message and exit.3. Spawn blocks on the Minecraft server with PythonThere are three methods at the core of the API:spawnBlocksspawns a set of different blocks,fillCubespawns a single type of block over a cubic volume andreadCubewhich reads currently spawned blocks within a space.If you aren't a seasoned Minecraft scholar, you can checkinformation about different Minecraft blocks.Here'sexampleon how to spawn a flying machine with python (you'll need to have started the modded Minecraft server before):importgrpcimportminecraft_pb2_grpcfromminecraft_pb2import*channel=grpc.insecure_channel('localhost:5001')client=minecraft_pb2_grpc.MinecraftServiceStub(channel)client.fillCube(FillCubeRequest(# Clear a 20x10x20 working areacube=Cube(min=Point(x=-10,y=4,z=-10),max=Point(x=10,y=14,z=10)),type=AIR))client.spawnBlocks(Blocks(blocks=[# Spawn a flying machine# Lower layerBlock(position=Point(x=1,y=5,z=1),type=PISTON,orientation=NORTH),Block(position=Point(x=1,y=5,z=0),type=SLIME,orientation=NORTH),Block(position=Point(x=1,y=5,z=-1),type=STICKY_PISTON,orientation=SOUTH),Block(position=Point(x=1,y=5,z=-2),type=PISTON,orientation=NORTH),Block(position=Point(x=1,y=5,z=-4),type=SLIME,orientation=NORTH),# Upper layerBlock(position=Point(x=1,y=6,z=0),type=REDSTONE_BLOCK,orientation=NORTH),Block(position=Point(x=1,y=6,z=-4),type=REDSTONE_BLOCK,orientation=NORTH),# ActivateBlock(position=Point(x=1,y=6,z=-1),type=QUARTZ_BLOCK,orientation=NORTH),]))To read the blocks present within a set of coordinates usereadCube:importgrpcimportminecraft_pb2_grpcfromminecraft_pb2import*channel=grpc.insecure_channel('localhost:5001')client=minecraft_pb2_grpc.MinecraftServiceStub(channel)blocks=client.readCube(Cube(min=Point(x=0,y=0,z=0),max=Point(x=10,y=10,z=10)))print(blocks)You can see the implemented Python methods atminecraft_pb2_grpc.py.
For the general grpc definition please seeminecraft-rpc.If you'd like to interface with the server using other languages than Python, you can use the interface definition file you can generate clients for (almost) any programming language you like. Seehttps://grpc.io/docs/languages/andminecraft-rpc.4. Rendering MinecraftYou can use the methodclient.readCubethat allows to read which blocks are spawned, however, if you'd like to render Minecraft to see what your spawned creations look like or even interact with them, you'll need to buy and installMinecraftInstall and launch MinecraftCreate a compatible version:InstallationsNewGive it a nameSelect version 1.12.2CreateLaunch it:PlayMultiplayerDirect ConnectOnServer AddresswritelocalhostJoin ServerOn the server command line, you can use /tp @p x y z to teleport yourself to position {x,y,z} in the world.5. Useful commands that you can type in the running server consoledefaultgamemode creativeto set the default mode to creative;setworldspawn x y zto set the default player spawn point;time set dayto set time to day;gamerule doDaylightCycle falsestop the day/night cycle;gamemode creative <player name>set creative mode for a specific player (sometimes the default isn't working);teleport <player name> x y zteleport a player to x,y,z coordinates.Et voilà:Evolutionary algorithms implemented with the APIIn this section we'll compile implementations of evolutionary algorithms using the APIInteractive evolution: Evolve Minecraft entities interactively.Simple tower evolution in Python: Evolve tower that reach for a golden block in the sky.CitationIf you use the code for academic or commecial use, please cite the associated paper:@article{Grbic2020Dec,author={Djordje Grbic, Rasmus Berg Palm, Elias Najarro, Claire Glanois, Sebastian Risi},title={{EvoCraft: A New Challenge for Open-Endedness}},journal={arXiv},year={2020},month={Dec},eprint={2012.04751},url={https://arxiv.org/abs/2012.04751v1}}