Jump to content

[1.5.1][WIP] Automation mod - computers


MarcinS

Recommended Posts

I have started and am at a quite advanced state of working on an "Automation" mod. This mod introduces computers and programming to your world of Minecraft.

 

Mod is currently in pre-alpha stage and soon I will add an alpha download to allow testing.

 

Why did I start working on this mod?

Being computer programmer myself, I was very excited when I saw Guude use ComputerCraft in his series. I've decided to start using turtles, when playing on my old laptop (single-player mode), but after starting just one turtle with "excavate", the frame rate dropped to 1-2, so I had to quickly abandon this idea.

I've decided to help fix the problems ComputerCraft has. Unfortunately, due to the fact that it is not open-source, I was unable to provide input to it. Also, I'm afraid that a lot of issues it has, are a result of some architectural choices made early during the project, and cannot be fixed without major changes. Therefore, I've decided to write my own mod.

 

Goals for this mod:

- be open-source - I can't understand non-commercial software being any other way,

- badly written programs should not cause a deadly lag (everything stops for couple of seconds) of the server/world,

- mod should work comfortably on servers with many users (i.e. public), and should not be just limited to private/white-listed servers,

- mod should not allow for dead-locks or server crashes (quite obvious),

- running computer programs should not start and run in new threads, as this consumes a lot of server resources and does not scale well above hundred computers running programs on a server,

- writing/editing a program should be user friendly and not impacted by client-server communication speed,

- syntax checking and error finding during program editing is a must, to avoid spending hours trying to find a typo in code after trying to run the program,

- if possible, mod should use a popular widely-known computer language,

- built-in objects should be extendable to allow adding new functions in new versions,

- mod should gracefully handle multiple players using the same computer at the same time,

- provide easy to use configuration and monitoring tools for server owners, to allow throttling of computer speed for players running many computers and other throttling and configuration options,

- provide an easy to use public API for adding new computer modules (see below).

 

Mod description:

Mod introduces several levels of computers, starting with a simple computer with limited capabilities, going up to "super-computer" class. The more advanced the computer is, the faster it runs, can house more modules, allows for larger program memory usage, etc.

 

Each computer has 1-5 (not finalized yet) slots for modules. Modules (items) are added to a computer via inventory interface of the computer. These add capabilities to the computer, as a computer without modules cannot really interact with the world. There will be several modules released with the core Automation mod (list not yet finalized):

- Location - module that allows the program to query the computer's location and which side it faces,

- Storage - module that allows to store items in the computer, as well as interacting with adjacent inventories,

- Mobility - module that allows the computer to change its location and facing (move in the world),

- Harvest - module that allows to harvest blocks in the vicinity of the computer,

- Redstone - module that allows to measure received and emit redstone signal.

 

In addition to modules, one extra item will be added to the game - Terminal. This item allows to connect to the computer, by right-clicking on it while holding Terminal in hand, to start a new computer session.

 

What's left to do:

- textures and icons,

- Mobility module testing,

- Harvest and Redstone modules - code and testing,

- configuration and monitoring tools to allow throttling; throttling part is actually very easy to do as mod was designed with this in mind,

- loads of testing by others.

 

Future plans:

1. Requirement for computers to consume energy (duh!). I would like to make the mod compatible with both Buildcraft and IC2 energy, and which one will be used, will be based on mod configuration and the other mod (BC, IC2) presence.

2. Computer user access, inter-computer communication security - this opens a nice field for extra-layer of game-play, where players can attempt to hack each other systems, if they manage to find a security whole in someone's program.

3. Peripherals and connecting/communicating with them using a cable, or if possible - using existing networks (for example glass-fibre cable from IC2).

Link to comment
Share on other sites

  • 2 weeks later...

I'm kind of interested in this for a certain project of mine. I propose Python for the programming language.

Reasoning: easy to learn, has a native Java implementation (Jython), great Java interoperability, lots of standard library features, it's not Lua.

Link to comment
Share on other sites

I'm kind of interested in this for a certain project of mine. I propose Python for the programming language.

Reasoning: easy to learn, has a native Java implementation (Jython), great Java interoperability, lots of standard library features, it's not Lua.

Actually I already implemented JavaScript syntax (a bit stricter version of it).

 

Also, I'm not sure if I would be able to use any existing language implementations, as these probably do not offer too much of a control over how many operations are executed in one go, and if a "busy wait" was done in a program, might introduce the same problem ComputerCraft has with world freezing.

 

I should have an alpha version in about 2 weeks, just need to figure out, what kind of options I want to give for the Redstone module, write and test it.

Link to comment
Share on other sites

I don't think it's a good idea. A custom language is basically useless outside the mod, and the implementation is quite tricky to get right. Jython shouldn't have the freezing issue, as long as it has at least a thread of its own. ComputerCraft does everything on the main thread and uses Lua coroutines for scheduling, which is a massive hack. I was thinking of a transaction based design for world changes, with the main interpreter running on a different thread, and the game commiting transactions every redstone tick (because no world state can change faster).

Link to comment
Share on other sites

I don't think it's a good idea. A custom language is basically useless outside the mod, and the implementation is quite tricky to get right. Jython shouldn't have the freezing issue, as long as it has at least a thread of its own. ComputerCraft does everything on the main thread and uses Lua coroutines for scheduling, which is a massive hack. I was thinking of a transaction based design for world changes, with the main interpreter running on a different thread, and the game commiting transactions every redstone tick (because no world state can change faster).

It's not really a custom language, as it's basically a JavaScript, by "stricter version" I mean - I enforce definition of variables (with "var") before the variable can be accessed, which allows me to detect any problems during parsing - editing the program and quickly highlight the problem. If need be, I can turn off that check.

 

Having one thread per each running program is also a scaling issue (ignore this comment if you mean having one thread for all the programs). With potentially hundreds of computers running programs in game, this poses a threat of exhausting Java resources by the mere volume of threads.

 

However, I do not understand your approach. What gain would that be, having interpreter on a separate thread, if it always has to run in sync with world ticks. Please keep in mind, that AFAIK Minecraft is not thread-safe and utilizes single-thread model when operating on World, therefore you shouldn't access, both read and/or write, it's data from any other thread than the main thread itself.

Link to comment
Share on other sites

Is your implementation ECMAScript compliant (assuming you turn off that check)? No? Then it's not JavaScript. I wanted to use something like this as an educational tool, and I don't think a subset of JavaScript is good for this use case. As for threading, Jython should be able to handle that with greenlets/coroutines, and if that doesn't cut it, there's always PyPy, which scales way better with implementation-native greenlets. Having it on a separate thread means that we don't have to care about scheduling it, but we can still have it run at lower priority. Synchronization needs testing, but I think a context switch every N ticks should be OK.

 

Edit: you also gave me another reason why an existing language should be easier to work with: tools. You'll want an editor with good syntax highlighting, and maybe even basic refactoring support, and that takes quite a lot of coding. For, say, Python or (compliant) JavaScript, there are lots of already existing open source tools and components that can be integrated into the game.

Link to comment
Share on other sites

Running a "busy waiting" thread (in case of badly written program) on a lower-priority does not prevent thread starvation (on main Minecraft thread), therefore I think it's a mistake to run a program on a separate thread. It only introduces complexity and potential for thread-safety issues when done wrong. If an implementation does not offer me complete control over scheduling it's a "no go" for me.

 

Thank you for your comments, but for the time being I will stick with what I have.

Link to comment
Share on other sites

As for conformance with ECMAScript, I've run the examples for Wikipedia page, and they get the results that are required for it. I do not intend to have full ECMAScript conformance, as I see little to no value in doing that. As an example, why have more than one way of defining an object?

 

Anyway, here are the tests I've written that give the expected results:


    @Test
    public void recursiveFunctionCall() throws IllegalSyntaxException, IOException, ExecutionException {
        final Variable variable = executeScript("function factorial(n) { if (n == 0) { return 1; } return n * factorial(n - 1); } return factorial(3);");
        assertEquals(6, ((Number) variable.getValue()).intValue());
    }

    @Test
    public void recursiveFunctionCall2() throws IllegalSyntaxException, IOException, ExecutionException {
        final Variable variable = executeScript("var factorial = function(n) { if (n == 0) { return 1; } return n * factorial(n - 1); }; return factorial(3);");
        assertEquals(6, ((Number) variable.getValue()).intValue());
    }

    @Test
    public void testClosure() throws IllegalSyntaxException, IOException, ExecutionException {
        final Variable variable = executeScript("var displayClosure = function() { var count = 0; return function () { return ++count; }; };"
                +" var inc = displayClosure(); return \"\"+inc()+\" \"+inc()+\" \"+inc();");
        assertEquals("1.0 2.0 3.0", variable.getValue());
    }

    @Test
    public void anonymousFunction() throws IllegalSyntaxException, IOException, ExecutionException {
        final Variable variable = executeScript("var v; v = 1; var getValue = (function(v) { return function() {return v;}; }(v)); v = 2; return getValue();");
        assertEquals(1, ((Number) variable.getValue()).intValue());
    }

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Dalam dunia perjudian online yang berkembang pesat, mencari platform yang dapat memberikan kemenangan maksimal dan hasil terbaik adalah impian setiap penjudi. OLXTOTO, dengan bangga, mempersembahkan dirinya sebagai jawaban atas pencarian itu. Sebagai platform terbesar untuk kemenangan maksimal dan hasil optimal, OLXTOTO telah menciptakan gelombang besar di komunitas perjudian online. Satu dari banyak keunggulan yang dimiliki OLXTOTO adalah koleksi permainan yang luas dan beragam. Dari togel hingga slot online, dari live casino hingga permainan kartu klasik, OLXTOTO memiliki sesuatu untuk setiap pemain. Dibangun dengan teknologi terkini dan dikembangkan oleh para ahli industri, setiap permainan di platform ini dirancang untuk memberikan pengalaman yang tak tertandingi bagi para penjudi. Namun, keunggulan OLXTOTO tidak hanya terletak pada variasi permainan yang mereka tawarkan. Mereka juga menonjol karena komitmen mereka terhadap keamanan dan keadilan. Dengan sistem keamanan tingkat tinggi dan proses audit yang ketat, OLXTOTO memastikan bahwa setiap putaran permainan berjalan dengan adil dan transparan. Para pemain dapat merasa aman dan yakin bahwa pengalaman berjudi mereka di OLXTOTO tidak akan terganggu oleh masalah keamanan atau keadilan. Tak hanya itu, OLXTOTO juga terkenal karena layanan pelanggan yang luar biasa. Tim dukungan mereka selalu siap sedia untuk membantu para pemain dengan segala pertanyaan atau masalah yang mereka hadapi. Dengan respon cepat dan solusi yang efisien, OLXTOTO memastikan bahwa pengalaman berjudi para pemain tetap mulus dan menyenangkan. Dengan semua fitur dan keunggulan yang ditawarkannya, tidak mengherankan bahwa OLXTOTO telah menjadi pilihan utama bagi jutaan penjudi online di seluruh dunia. Jika Anda mencari platform yang dapat memberikan kemenangan maksimal dan hasil optimal, tidak perlu mencari lebih jauh dari OLXTOTO. Bergabunglah dengan OLXTOTO hari ini dan mulailah petualangan Anda menuju kemenangan besar dan hasil terbaik!
    • Selamat datang di OLXTOTO, situs slot gacor terpanas yang sedang booming di industri perjudian online. Jika Anda mencari pengalaman bermain yang luar biasa, maka OLXTOTO adalah tempat yang tepat untuk Anda. Dapatkan sensasi tidak biasa dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering. Di sini, Anda akan merasakan keseruan yang luar biasa dalam bermain judi slot. DAFTAR OLXTOTO DISINI LOGIN OLXTOTO DISINI AKUN PRO OLXTOTO DISINI   Jackpot Slot Maxwin Sering Untuk Peluang Besar Di OLXTOTO, kami tidak hanya memberikan hadiah slot biasa, tapi juga memberikan kesempatan kepada pemain untuk memenangkan jackpot slot maxwin yang sering. Dengan demikian, Anda dapat meraih keberuntungan besar dan memenangkan ribuan rupiah sebagai hadiah jackpot slot maxwin kami. Jackpot slot maxwin merupakan peluang besar bagi para pemain judi slot untuk meraih keuntungan yang lebih besar. Dalam permainan kami, Anda tidak harus terpaku pada kemenangan biasa saja. Kami hadir dengan jackpot slot maxwin yang sering, sehingga Anda memiliki peluang yang lebih besar untuk meraih kemenangan besar dengan hadiah yang menggiurkan. Dalam permainan judi slot, pengalaman bermain bukan hanya tentang keseruan dan hiburan semata. Kami memahami bahwa para pemain juga menginginkan kesempatan untuk meraih keberuntungan besar. Oleh karena itu, OLXTOTO hadir dengan jackpot slot maxwin yang sering untuk memberikan peluang besar kepada para pemain kami. Peluang Besar Menang Jackpot Slot Maxwin Peluang menang jackpot slot maxwin di OLXTOTO sangatlah besar. Anda tidak perlu khawatir tentang batasan atau pembatasan dalam meraih jackpot tersebut. Kami ingin memberikan kesempatan kepada semua pemain kami untuk merasakan sensasi menang dalam jumlah yang luar biasa. Jackpot slot maxwin kami dibuka untuk semua pemain judi slot di OLXTOTO. Anda memiliki peluang yang sama dengan pemain lainnya untuk memenangkan hadiah jackpot yang besar. Kami percaya bahwa semua orang memiliki kesempatan untuk meraih keberuntungan besar, dan itulah mengapa kami menyediakan jackpot slot maxwin yang sering untuk memenuhi harapan dan keinginan Anda.   Kesimpulan OLXTOTO adalah situs slot gacor terbaik yang memberikan pengalaman bermain judi slot online yang tak terlupakan. Dengan variasi slot online terlengkap dan peluang memenangkan jackpot slot maxwin yang sering, OLXTOTO menjadi pilihan terbaik bagi para pemain yang mencari kesenangan dan kemenangan besar dalam perjudian online. Di samping itu, OLXTOTO juga menawarkan layanan pelanggan yang ramah dan responsif, siap membantu setiap pemain dalam mengatasi masalah teknis atau pertanyaan seputar perjudian online. Kami menjaga integritas game dan memberikan lingkungan bermain yang adil serta menjalankan kebijakan perlindungan pelanggan yang cermat. Bergabunglah dengan OLXTOTO sekarang dan nikmati pengalaman bermain slot online yang luar biasa. Jadilah bagian dari komunitas perjudian yang mengagumkan ini dan raih kesempatan untuk meraih kemenangan besar. Dapatkan akses mudah dan praktis ke situs OLXTOTO dan rasakan sensasi bermain judi slot yang tak terlupakan.  
    • OLXTOTO: Platform Maxwin dan Gacor Terbesar Sepanjang Masa Di dunia perjudian online yang begitu kompetitif, mencari platform yang dapat memberikan kemenangan maksimal (Maxwin) dan hasil terbaik (Gacor) adalah prioritas bagi para penjudi yang cerdas. Dalam upaya ini, OLXTOTO telah muncul sebagai pemain kunci yang mengubah lanskap perjudian online dengan menawarkan pengalaman tanpa tandingan.     Sejak diluncurkan, OLXTOTO telah menjadi sorotan industri perjudian online. Dikenal sebagai "Platform Maxwin dan Gacor Terbesar Sepanjang Masa", OLXTOTO telah menarik perhatian pemain dari seluruh dunia dengan reputasinya yang solid dan kinerja yang luar biasa. Salah satu fitur utama yang membedakan OLXTOTO dari pesaingnya adalah komitmen mereka untuk memberikan pengalaman berjudi yang unik dan memuaskan. Dengan koleksi game yang luas dan beragam, termasuk togel, slot online, live casino, dan banyak lagi, OLXTOTO menawarkan sesuatu untuk semua orang. Dibangun dengan teknologi terkini dan didukung oleh tim ahli yang berdedikasi, platform ini memastikan bahwa setiap pengalaman berjudi di OLXTOTO tidak hanya menghibur, tetapi juga menguntungkan. Namun, keunggulan OLXTOTO tidak hanya terletak pada permainan yang mereka tawarkan. Mereka juga terkenal karena keamanan dan keadilan yang mereka berikan kepada para pemain mereka. Dengan sistem keamanan tingkat tinggi dan audit rutin yang dilakukan oleh otoritas regulasi independen, para pemain dapat yakin bahwa setiap putaran permainan di OLXTOTO adalah adil dan transparan. Tidak hanya itu, OLXTOTO juga dikenal karena layanan pelanggan yang luar biasa. Dengan tim dukungan yang ramah dan responsif, para pemain dapat yakin bahwa setiap pertanyaan atau masalah mereka akan ditangani dengan cepat dan efisien. Dengan semua fitur dan keunggulan yang ditawarkannya, tidak mengherankan bahwa OLXTOTO telah menjadi platform pilihan bagi para penjudi online yang mencari kemenangan maksimal dan hasil terbaik. Jadi, jika Anda ingin bergabung dengan jutaan pemain yang telah merasakan keajaiban OLXTOTO, jangan ragu untuk mendaftar dan mulai bermain hari ini!  
    • OLXTOTO adalah bandar slot yang terkenal dan terpercaya di Indonesia. Mereka menawarkan berbagai jenis permainan slot yang menarik dan menghibur. Dengan tampilan yang menarik dan grafis yang berkualitas tinggi, pemain akan merasa seperti berada di kasino sungguhan. OLXTOTO juga menyediakan layanan pelanggan yang ramah dan responsif, siap membantu pemain dengan segala pertanyaan atau masalah yang mereka hadapi. Daftar =  https://surkale.me/Olxtotodotcom1
    • DAFTAR & LOGIN BIGO4D   Bigo4D adalah situs slot online yang populer dan menarik perhatian banyak pemain slot di Indonesia. Dengan berbagai game slot yang unik dan menarik, Bigo4D menjadi tempat yang ideal untuk pemula dan pahlawan slot yang berpengalaman. Dalam artikel ini, kami akan membahas tentang Bigo4D sebagai situs slot terbesar dan menarik yang saat ini banyak dijajaki oleh pemain slot online.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.