ropensci / unconf17

Website for 2017 rOpenSci Unconf
http://unconf17.ropensci.org
64 stars 12 forks source link

minecraft package #13

Open daroczig opened 7 years ago

daroczig commented 7 years ago

It would be nice to provide an R package to interact with Minecraft -- to help kids learning R and programming. This could be the hipster version of the TurtleGraphics package :)

Proof of concept: http://smarterpoland.pl/index.php/2016/09/minecharts-1-minecraft-r-edgar-andersons-iris-data

kbroman commented 7 years ago

I'd played with minecraft via python with my son, and it was great fun (though the set up was really painful; I need to find my notes). Interacting with minecraft via R would be cool.

We used the book Learn to Program with Minecraft, which is really well done.

This api reference was really helpful.

daroczig commented 7 years ago

I'm very happy to see the high number of thumbs up and smiling emojis above :)

Hoping that we can work on this package as part of the unconf, I've bought a copy of "Learn to Program with Minecraft" as suggested by @kbroman, and I think it's reasonable to build an MVP package interacting with the API, so that we can port some of the book examples into R.

I will try to setup some infra for this task (installing Minecraft, maybe bringing a raspberry pi with me with the image referenced in the above post), but as I don't have much experience with Minecraft, I could definitely use some help. On the other hand, I'm happy to work on the R package and write the functions to interact with the API, and/or I can also work on example tasks/exercises for future package users.

kbroman commented 7 years ago

Spent some time tonight refreshing my understanding of python and py3minepi.

karthik_minecraft

daroczig commented 7 years ago

That's very cool, thanks a lot for sharing, @kbroman :)

I tried to do some research on the related infrastructure too, but it turned out there are so many different ways to start that, so asking for some help here. Any ideas on what's the best SW to achieve this goal? Eg there's

All of these require the Minecraft game to be able to connect to the server (although that's bundled eg on the Minecraft Pi edition for free), so that's ~25 USD. Please correct me if I'm wrong about this :)

But there are also open-source client implementations, see eg http://wiki.vg/Client_List

And https://opensource.com/alternatives/minecraft also lists a bunch of open-source tools, eg http://www.minetest.net looks very cool -- with open-source server + clients on all platforms. I like the idea of building something not especially for the Minecraft game, but for some of its open-source variant, so that deployment to schools, workshops etc would be easier.

Any experience or feedback on these?

kbroman commented 7 years ago

I'd be inclined towards your fourth option (spigot, targeting RaspberryJuice).

If we can duplicate the functionality of py3minepi, it could be used either with Minecraft Pi or spigot.

I was going to say that the downside of Minecraft Pi is that we'd need to get R running on the raspberry pi, but it seems that it has been done.

To me, the real value of py3minepi, and so of an R package that does the same thing, is to build on kids' (or others') interest in minecraft as they learn to program. A key challenge that I see in learning to program is having suitable challenges/goals, and minecraft offers an abundance of them ranging from easy to difficult. And I think the target audience would likely have already paid the US$26.95 Minecraft fee.

My experience on Macs has been that the set up of spigot is tricky; I had to use all of my unix and googling experience to work through some troubles. This is an unfortunate barrier.

But back to your main point: I do like the idea of using an open-source alternative, though I do see some advantage of working with the actual Minecraft: "here look, you can write programs to manipulate minecraft" vs "here look, you can write programs to manipulate this game that looks a lot like minecraft".

But maybe we can separate the two things:

kbroman commented 7 years ago

@daroczig in your example with the iris data, you show how to write to a minecraft connection. How would you then read from it? For example, how can I use world.getHeight(0,0) and then grab the response?

kbroman commented 7 years ago

@daroczig I figured it out.

mc <- socketConnection("localhost", 4711, open="r+b", encoding="CP437")
writeLines("world.getHeight(0,0)", con=mc, useBytes=TRUE)
readLines(mc)
daroczig commented 7 years ago

Sorry for the late reply, @kbroman!

@daroczig in your example with the iris data, you show how to write to a minecraft connection

Ah, sorry for the confusion -- it's not my blog post, I've just found it and thought it would be a good reference/starting point

I'd be inclined towards your fourth option (spigot, targeting RaspberryJuice). [...] And I think the target audience would likely have already paid the US$26.95 Minecraft fee.

All right, sounds good to me. I went ahead and bought the Minecraft client, also tried the Rasbian version, but then decided to install Spigot on my Linux machine for improved performance -- which seems to work fine with the Minecraft client, and I can interact with the server from R. It's pretty inconvenient for now, but I hope we can improve that soon :) Eg reading from connection does not work here yet.

I do like the idea of using an open-source alternative, though I do see some advantage of working with the actual Minecraft: "here look, you can write programs to manipulate minecraft" vs "here look, you can write programs to manipulate this game that looks a lot like minecraft".

Yeah, very good point -- let's focus on Minecraft. Porting this to eg Minetest might be extremely easy, see eg https://forum.minetest.net/viewtopic.php?t=13316

kbroman commented 7 years ago

Been playing a lot of minecraft with my kids, and started a miner package.

kbroman commented 7 years ago

I created a repository with various notes I've taken on this project: https://github.com/kbroman/miner_notes

daroczig commented 7 years ago

This is awesome, thanks for putting that together @kbroman! Looking forward to working on this :)

revodavid commented 7 years ago

This sounds a fun thing to work on (and if it goes well, I might even be able to connect with the Minecraft team after the event)

daroczig commented 7 years ago

FTR the package dev was moved to the rOpenSciLabs fork at https://github.com/ropenscilabs/miner

kbroman commented 7 years ago

I shoved all of our vignettes into a bookdown book:

I also started a miner.extra package with supplementary code. (Currently the stuff that's not yet in the book.)

kbroman commented 7 years ago

After discussion with @daroczig and @geanders, we've changed the name of the "miner.extra" package to craft.

At the same time, I went ahead and changed the repo for the book from miner.book to miner_book. So the source is at https://github.com/ropenscilabs/miner_book and the product is viewable at https://ropenscilabs.github.io/miner_book.

stefaniebutland commented 7 years ago

@kbroman @daroczig, Scott pointed this out. Wondering if you want to list miner here https://github.com/showcases/hacking-minecraft (but I'm 100% naive about how to get added)

stefaniebutland commented 6 years ago

Repo: https://github.com/ROpenSciLabs/miner Blog post: http://kbroman.org/blog/2017/05/27/ropensci-unconf-2017/