A proposal... (python)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sirridan
    Knight
    • May 2009
    • 560

    A proposal... (python)

    A couple of folks here seem to show interest in having Angband written in python; I myself am one of them. So why not do it? I think if we get enough people, we can get it working.

    I'd say start by making the AngbandBase in python first, then moving to porting over the logic. I know it's quite a few thousand lines of code (100k+ right?) but the conversion should knock it down quite a bit.

    Anyone interested?
  • Derakon
    Prophet
    • Dec 2009
    • 9022

    #2
    Much as I would love to see Angband in Python, I have far too many projects in the air right now to commit to helping out.

    Also, to do it properly, you'd need to do more than just a straight port. Angband is a procedural program that was written ~25 years ago; ideally a modern port of it would change the design into something more object-oriented without significantly changing the gameplay. Such a redesign would require the help of someone who has a good understanding of the overall program, though.

    Comment

    • fph
      Veteran
      • Apr 2009
      • 1030

      #3
      Maybe it's a stupid idea, but I'd like to bring it up for discussion, too.
      There are several methods to interface python with C; it could be a possibility to do the porting gradually, starting from small parts of the code which would benefit more from the scripting (e.g. spells and effects).
      This would make it easier to test and playtest, since the code would be usable from the early stages. It would also feel more like an evolution rather than a completely different project/fork.

      I know that scripting has been introduced in the past with LUA and then dropped, but I am not familiar with the reasons that led to its elimination. What were its drawbacks?
      --
      Dive fast, die young, leave a high-CHA corpse.

      Comment

      • d_m
        Angband Devteam member
        • Aug 2008
        • 1517

        #4
        Originally posted by Derakon
        Also, to do it properly, you'd need to do more than just a straight port. Angband is a procedural program that was written ~25 years ago; ideally a modern port of it would change the design into something more object-oriented without significantly changing the gameplay. Such a redesign would require the help of someone who has a good understanding of the overall program, though.
        This is the reason why I have never seriously started this. I actually think it will be really difficult to redesign the whole program to be object-oriented, use fewer (or no) global variables, etc, and still actually play the same. The current implementation is hairy enough that even a straight port would be buggy for a long time.

        Once you start redesigning things you're going to get bogged down into discussions about which legacy design choices were "bugs" and which were "important game features".

        If I were going to do it I would make it as close a port as possible. That would mean:

        1. structs become classes with no methods (initially)
        2. keep all the global variables
        3. remove the memory allocation code but keep the string processing/formatting code
        4. keep the current "term" design
        5. keep the current savefile and edit file structures

        Once you get the working (or maybe "if") then you can start refactoring code to be more modern. This plan loses a lot of the appeal of a Python port, which is probably why I haven't done it
        linux->xterm->screen->pmacs

        Comment

        • RogerN
          Swordsman
          • Jul 2008
          • 308

          #5
          Also, to do it properly, you'd need to do more than just a straight port. Angband is a procedural program that was written ~25 years ago; ideally a modern port of it would change the design into something more object-oriented without significantly changing the gameplay. Such a redesign would require the help of someone who has a good understanding of the overall program, though.
          After writing Cryptband, based loosely on Angband code, I can attest to the fact that Angband's code is not at all simple to translate into an object-oriented framework. A major design overhaul would be needed to take advantage of the benefits of a language like Python. Without it, you'll end up with yet another procedural code base which is no more extensible or moddable than what Angband already has. At the same time, you'll lose all the compile-type benefits of a strongly typed language.

          I think it would be best to attempt a project like this by not looking at the Angband code at all, or at least infrequently.

          Comment

          • Magnate
            Angband Devteam member
            • May 2007
            • 5110

            #6
            Hmmm. As someone with a good understanding of the code and the game, but without the skill or the time to play a major part in the python coding, I'm ideally positioned to act as the aforementioned consultant to this project!

            Seriously, I agree that this project should stick as closely as possible to the current V until a working port is running, before getting into major gameplay changes. OTOH I'm quite happy to take full advantage of Python in terms of redesigning how the code works - e.g. taking another look at what's read in from text files and how (elly on IRC has done a lot of work on this, with a more modern edit file syntax).

            One thing I think would need to be agreed at the outset: we're writing it for Linux, and thus postponing any and all port-specific issues. (Yes, ideally it should Just Work on any Python platform, but I think it would save energy and retain focus if we were not distracted by issues on non-Linux platforms.) Once it works on Linux, people can put effort into making it work on other OSs.

            (Oh, and I totally agree with the idea of starting from AngbandBase, as well.)

            So, who's actually up for this?
            "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

            Comment

            • Atarlost
              Swordsman
              • Apr 2007
              • 441

              #7
              Originally posted by Magnate
              Hmmm. As someone with a good understanding of the code and the game, but without the skill or the time to play a major part in the python coding, I'm ideally positioned to act as the aforementioned consultant to this project!

              Seriously, I agree that this project should stick as closely as possible to the current V until a working port is running, before getting into major gameplay changes. OTOH I'm quite happy to take full advantage of Python in terms of redesigning how the code works - e.g. taking another look at what's read in from text files and how (elly on IRC has done a lot of work on this, with a more modern edit file syntax).

              One thing I think would need to be agreed at the outset: we're writing it for Linux, and thus postponing any and all port-specific issues. (Yes, ideally it should Just Work on any Python platform, but I think it would save energy and retain focus if we were not distracted by issues on non-Linux platforms.) Once it works on Linux, people can put effort into making it work on other OSs.

              (Oh, and I totally agree with the idea of starting from AngbandBase, as well.)

              So, who's actually up for this?
              In theory shouldn't AngbandBase be dealing with any portability issues for non-handheld platforms?
              One Ring to rule them all. One Ring to bind them.
              One Ring to bring them all and in the darkness interrupt the movie.

              Comment

              • Derakon
                Prophet
                • Dec 2009
                • 9022

                #8
                To be quite honest I think the best way to deal with this would be to make a new roguelike from the ground up that strives to be similar to Angband and isn't afraid to steal content wholesale. Attempting to port a large established C codebase to Python would be a huge amount of work, and it'd be difficult to get motivated if you knew you weren't going to reap the rewards of that port for a long while.

                Comment

                • Magnate
                  Angband Devteam member
                  • May 2007
                  • 5110

                  #9
                  Originally posted by Atarlost
                  In theory shouldn't AngbandBase be dealing with any portability issues for non-handheld platforms?
                  Yes, in theory. But all these things take time, and if the python rewrite is going to happen, I just think we need to stay focused until it starts working. Just my 2p.

                  Besides, there are enough other people interested in AngbandBase that that might be fixed independently ...
                  "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

                  Comment

                  • cinereaste
                    Scout
                    • May 2010
                    • 43

                    #10
                    Originally posted by Derakon
                    To be quite honest I think the best way to deal with this would be to make a new roguelike from the ground up that strives to be similar to Angband and isn't afraid to steal content wholesale. Attempting to port a large established C codebase to Python would be a huge amount of work, and it'd be difficult to get motivated if you knew you weren't going to reap the rewards of that port for a long while.
                    I tend to agree with Derakon here. Although I can see the argument that fph puts forth about porting the code gradually to maintain functionality, I suspect that method will force (or strongly encourage) the adoption of the programming techniques and hacks that we would like to get away from by porting to Python. Maybe it can be avoided, but I think it would be much easier to adopt good coding practices by starting from the ground up.

                    I think in either case motivation might be an issue -- As Derkon states, a gradual port delays the time when we can reap the benefits of Python, but starting from the ground up will also take a long time.

                    Comment

                    • Tiburon Silverflame
                      Swordsman
                      • Feb 2010
                      • 405

                      #11
                      Were this to be done, I agree that a redesign would be preferable. As far as port-specific stuff, one approach that puts off this issue is to focus first on as much of the internals that should have no platform dependencies...which should be a very large chunk of the codebase.

                      The gradual port might work, *if* there are major sections that can be isolated and repackaged cleanly...but that's probably not common.

                      Comment

                      • nppangband
                        NPPAngband Maintainer
                        • Dec 2008
                        • 926

                        #12
                        Isn't somebody working on a first person, real time (as opposed to turn based) version of Angband coded in Python? Why not combine efforts and help him write his Angband code so he can just concentrate on the graphics for the objects and monsters?
                        NPPAngband current home page: http://nppangband.bitshepherd.net/
                        Source code repository:
                        https://github.com/nppangband/NPPAngband_QT
                        Downloads:
                        https://app.box.com/s/1x7k65ghsmc31usmj329pb8415n1ux57

                        Comment

                        • Magnate
                          Angband Devteam member
                          • May 2007
                          • 5110

                          #13
                          Originally posted by nppangband
                          Isn't somebody working on a first person, real time (as opposed to turn based) version of Angband coded in Python? Why not combine efforts and help him write his Angband code so he can just concentrate on the graphics for the objects and monsters?
                          Are you talking about jplur's Blengband? I thought that was in C# rather than Python?
                          "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

                          Comment

                          • Derakon
                            Prophet
                            • Dec 2009
                            • 9022

                            #14
                            IIRC he's using the Blender game engine, which should be all Python. It's worth checking, anyway.

                            Comment

                            • Magnate
                              Angband Devteam member
                              • May 2007
                              • 5110

                              #15
                              Originally posted by Derakon
                              IIRC he's using the Blender game engine, which should be all Python. It's worth checking, anyway.
                              Ironically that means that this project would have to focus on the boring stuff (the z-term type stuff in AngbandBase), if he's already doing the interesting (gameplay) stuff in Python. But yes, worth looking into.
                              "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

                              Comment

                              Working...
                              😀
                              😂
                              🥰
                              😘
                              🤢
                              😎
                              😞
                              😡
                              👍
                              👎