Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Flashing Twelve
Mar 20, 2007

So the guy behind failed kickstarted roguelike CultRL has released his source code.

https://bitbucket.org/dmhagar/empyrea-public/raw/4759faba1443e6105ff6cbf9c2829735f55df593/empyrea.py

It's, uhh, it's something alright.

Adbot
ADBOT LOVES YOU

pseudorandom name
May 6, 2007

Try looking at the NetHack source code some time.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
That may have something to do with why it failed.

[e] Nethack at least has multiple files and has the excuse of being incredibly old.

Pollyanna
Mar 5, 2005

Milk's on them.


Flashing Twelve posted:

So the guy behind failed kickstarted roguelike CultRL has released his source code.

https://bitbucket.org/dmhagar/empyrea-public/raw/4759faba1443e6105ff6cbf9c2829735f55df593/empyrea.py

It's, uhh, it's something alright.

Whaaaaaaat the gently caress :psyduck:

I took one look at the bigass list of imports and just knew this was gonna be nuts. Holy god, I hope my code never looks like that.

Coffee Mugshot
Jun 26, 2010

by Lowtax
Uh, hate to break this to you, but that's not even a lot of imports in python. Also, I hope you never have to write something that uses tons of included dependencies like C/C++.

Pollyanna
Mar 5, 2005

Milk's on them.


Rainbow Pony Deluxe posted:

Uh, hate to break this to you, but that's not even a lot of imports in python. Also, I hope you never have to write something that uses tons of included dependencies like C/C++.

Well yeah, I mean it's not strange for a project to use a bunch of modules. But at least break it up into multiple files or make that list look nicer :(

Deus Rex
Mar 5, 2005

Rainbow Pony Deluxe posted:

Uh, hate to break this to you, but that's not even a lot of imports in python. Also, I hope you never have to write something that uses tons of included dependencies like C/C++.

That is a huge list of imports for a single Python file, which reflects how loving massive that source file is.

fritz
Jul 26, 2003

Flashing Twelve posted:

So the guy behind failed kickstarted roguelike CultRL has released his source code.

https://bitbucket.org/dmhagar/empyrea-public/raw/4759faba1443e6105ff6cbf9c2829735f55df593/empyrea.py

It's, uhh, it's something alright.

Some googling suggests it had performance problems, I glanced at the source code and if this:
code:

def queryTile(x, y, checklist):
    global wheightdict, wfeaturedict, tivar

    qcheck = {}

    if 'Shrubland' in checklist:
        qcheck['Shrubland'] = 'sl' in wfeaturedict['%s,%s' % (x,y)]
    if 'Heathland' in checklist:
        qcheck['Heathland'] = 'hl' in wfeaturedict['%s,%s' % (x,y)]
    if 'Marshland' in checklist:
        qcheck['Marshland'] = 'ml' in wfeaturedict['%s,%s' % (x,y)]
    if 'Cacti Forest' in checklist:
        qcheck['Cacti Forest'] = 'dl' in wfeaturedict['%s,%s' % (x,y)]
    if 'Broadleaf Forest' in checklist:
        qcheck['Broadleaf Forest'] = 'bf' in wfeaturedict['%s,%s' % (x,y)]
    if 'Deciduous Forest' in checklist:
        qcheck['Deciduous Forest'] = 'df' in wfeaturedict['%s,%s' % (x,y)]
    if 'Mixed Forest' in checklist:
        qcheck['Mixed Forest'] = 'mf' in wfeaturedict['%s,%s' % (x,y)]
    if 'Coniferous Forest' in checklist:
        qcheck['Coniferous Forest'] = 'cf' in wfeaturedict['%s,%s' % (x,y)]
    if 'Evergreen Forest' in checklist:
        qcheck['Evergreen Forest'] = 'ef' in wfeaturedict['%s,%s' % (x,y)]
    if 'Tropical Forest' in checklist:
        qcheck['Tropical Forest'] = 'tf' in wfeaturedict['%s,%s' % (x,y)]
    if 'Swamp' in checklist:
        qcheck['Swamp'] = 'sw' in wfeaturedict['%s,%s' % (x,y)]
    if 'Desert' in checklist:
        qcheck['Desert'] = 'd' in wfeaturedict['%s,%s' % (x,y)]
    if 'Cave' in checklist:
        qcheck['Cave'] = 'c' in wfeaturedict['%s,%s' % (x,y)]
    if 'Beach' in checklist:
        qcheck['Beach'] = 'b' in wfeaturedict['%s,%s' % (x,y)]
    if 'River' in checklist:
        qcheck['River'] = 'r' in wfeaturedict['%s,%s' % (x,y)]
    if 'Highland' in checklist:
        qcheck['Highland'] = wmlev - 8 < wheightdict['%s,%s' % (x,y)] < wmlev
    if 'Mountain' in checklist:
        qcheck['Mountain'] = wmlev < wheightdict['%s,%s' % (x,y)]
    if 'Plain' in checklist:
        qcheck['Plain'] = 'pl' in wfeaturedict['%s,%s' % (x,y)]
    if 'Tundra' in checklist:
        qcheck['Tundra'] = wfeaturedict['%s,%s' % (x,y)] == 's' and 152 < wheightdict['%s,%s' % (x,y)] < 168
    if 'Savannah' in checklist:
        qcheck['Savannah'] = len(wfeaturedict['%s,%s' % (x,y)]) == 0 and 152 < wheightdict['%s,%s' % (x,y)] < 168 and \
                             y > (((MAP_HEIGHT / 4) * 3) + tivar[x])
    if 'Glacier' in checklist:
        qcheck['Glacier'] = 'g' in wfeaturedict['%s,%s' % (x,y)]
    if 'River Bank' in checklist:
        qcheck['River Bank'] = 'r' in wfeaturedict['%s,%s' % (x,y)]
    if 'Pond' in checklist:
        qcheck['Pond'] = (float(y) / MAP_HEIGHT * 102) > ivar[x] and 'd' not in wfeaturedict['%s,%s' % (x,y)] and \
                         152 < wheightdict['%s,%s' % (x,y)] < wmlev
    if 'Ocean' in checklist:
        qcheck['Ocean'] = 'o' in wfeaturedict['%s,%s' % (x,y)]
    if 'Lake' in checklist:
        qcheck['Lake'] = 'l' in wfeaturedict['%s,%s' % (x,y)]
    if 'Lakeshore' in checklist:
        qcheck['Lakeshore'] = 'ls' in wfeaturedict['%s,%s' % (x,y)]

    condition = True

    for check in checklist:
        condition = condition and qcheck[check]

    return condition
is typical I'm not at all surprised.


ETA: queryTile is called in only one location, and checklist is always a 1-element list.

fritz fucked around with this message at 06:42 on Sep 24, 2013

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

I didn't read very far, but my favorite part was:

Python code:
sys.setrecursionlimit(50000)
right at the top of the file.

Extortionist
Aug 31, 2001

Leave the gun. Take the cannoli.

fritz posted:

ETA: queryTile is called in only one location, and checklist is always a 1-element list.

It's better than that:
Python code:
        checklist = ['Shrubland','Heathland','Marshland','Cacti Forest','Broadleaf Forest','Deciduous Forest','Mixed Forest', \
                     'Coniferous Forest','Evergreen Forest','Tropical Forest','Swamp','Desert','Cave','Beach','River','Highland', \
                     'Mountain','Plain','Tundra','Savannah','Glacier','River Bank','Pond','Ocean','Lake','Lakeshore']
...
        for check in checklist:
            vars()[check] = []
            for x in range(MAP_WIDTH):
                for y in range(MAP_HEIGHT):
                    if queryTile(x, y, [check]):
...
The elements in checklist are all of the conditions he's checking for in queryTile. So he's calling the function for every possible condition on every map square, and then checking again for every possible condition on that map square every time.

Extortionist fucked around with this message at 07:24 on Sep 24, 2013

Master_Odin
Apr 15, 2010

My spear never misses its mark...

ladies
I don't know why you guys are complaining. He gave us a "Coder's Guide" to navigating the file. Makes it super easy to navigate, unlike if it was broken up or something dumb like that.

breaks
May 12, 2001

I have to say I was a little disappointed that I searched for vars() and he only used it 4 times.

Oh, but there's 20 uses of globals().

breaks fucked around with this message at 07:36 on Sep 24, 2013

bucketmouse
Aug 16, 2004

we con-trol the ho-ri-zon-tal
we con-trol the verrr-ti-cal
That's even worse than Terraria's tile code and that's really saying something.

:gonk:

Jewel
May 2, 2009

bucketmouse posted:

That's even worse than Terraria's tile code and that's really saying something.

:gonk:

To be fair I think that was C# decompiling being weird, after studying the code a little while.

it is
Aug 19, 2011

by Smythe
Oh good, the first part of that code is "miscellaneous functions." Because when I look at a piece of source code for the first time I want to know what miscellaneous functions are in it.

Huragok
Sep 14, 2011
That's another crappy thing about python: no switch-case equivalent. I like syntactic purity as much as the next guy, but you'll also have to yield to pragmatism at some point for the sake of readability and maintainability.

Crosscontaminant
Jan 18, 2007

That's Empyrea. not Cult (which wasn't a failed Kickstarter at all, it asked for $5,000 and got $34,000).

Superschaf
May 20, 2010

Crosscontaminant posted:

That's Empyrea. not Cult (which wasn't a failed Kickstarter at all, it asked for $5,000 and got $34,000).

Empyrea is Cult and the Kickstarter was a failure as the developer gave up on finishing it.

nielsm
Jun 1, 2009



Okay Python, this is kinda annoying...

Python code:
def a(foo):
    def b():
        if len(foo) > 3:
            return True
        else:
            return False
    islong = b()
    print "{} is long: {}".format(foo, islong)
Does what you'd expect: Calling a('asdasd') prints True, and similar for a short string.

Change it to this:
Python code:
def a(foo):
    def b():
        if len(foo) > 3:
            foo = '"{}"'.format(foo)
            return True
        else:
            return False
    islong = b()
    print "{} is long: {}".format(foo, islong)
Surprise!
UnboundLocalError: local variable 'foo' referenced before assignment

Suddenly a separate foo variable gets introduced into b's scope and it no longer references that of the outer one. Because of an assignment.

I understand why it does this, but seriously, it's annoying. Couldn't there be a way to hoist in a variable from an outer scope, that isn't the global one?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Python 3 adds nonlocal for exactly that.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Master_Odin posted:

I don't know why you guys are complaining. He gave us a "Coder's Guide" to navigating the file. Makes it super easy to navigate, unlike if it was broken up or something dumb like that.

Ahah

code:
####################################
# Coder's Guide                    #
####################################
##     I. Misc. Functions
##       - f. wchoice, f. dchoice, f. DictCmp, f. ListCmp, f. ListCmp2, f. LenCmp,
##         f. HeightSort, f. modifyList, f. getRivChar, f. MergeTerritory, f. queryTile,
##         f. doNothing, f. DoChar, f. throwSwitches, f. delFile
##     I.A Music/Sound Functions
##    II. Graphical/Menu Classes
##       - c. IntroGraphics, c. CloudNoise, c. WCloudNoise, c. FadeText,
##         c. ButtonBox, c. Menu, c. RelMap c. LeaveWindow, c. ScrollBar,
##         c. InvWindow, c. Dialogue, c. NDialogue, c.OptWindow, c. CWindow,
##         c. ProgressBar
##   III. Misc. Graphical Functions
##       - f. renderButtons, f. renderMenus, f. renderText, f. renderLights, f. renderGraphics,
##         f. drawBox, f. doMenu, f. solidScale, f. textWrap, f. killMenus
##    IV. Input Functions
##       - f. handle_mouse, f. mouse_isvisible, f. handle_keys, f. adjustScreen
##     V. Screen Change Functions
##       - f. doIntroSetup, f. doWorldGenSetup, f. doWorldAtlasSetup
##    VI. Intro
##       - f. doIntro
##   VII. Intro Transition
##       - f. wipeIntro
##  VIII. World Drawing Functions
##       - f. LoadWorld, f. Draw[type]...
##    IX. Land Generation
##       - c. World
##     X. Terrain Feature Naming
##       - c. WorldNaming
##    XI. Entity Generation
##       - c. WorldCreatures
##   XII. History Generation
##       - c. WorldHistory
##  XIII. World Atlas
##       - c. WorldAtlas
##   XIV. Main Game Architecture
##       - c. PlayWorld, c. Pathfinder
##    XV. Thesaurus Entries
##       - f. t
##   XVI. Main Worldgen Loop
##       - f. doWorldGen
##  XVII. Main World Atlas Loop
##       - f. doWorldAtlas
## XVIII. Main Game Loop
##       - c. MainGame
##   XIX. Main Application Loop
How does someone learn Python to the degree of competence necessary to make this... thing, without picking up ideas like "split the project up into multiple modules in a logical fashion" and "put that poo poo in a docstring like a normal person"?

No Safe Word
Feb 26, 2005

Crosscontaminant posted:

That's Empyrea. not Cult (which wasn't a failed Kickstarter at all, it asked for $5,000 and got $34,000).


Superschaf posted:

Empyrea is Cult and the Kickstarter was a failure as the developer gave up on finishing it.

Yeah it's not hard to look at the updates on the Kickstarter and see he's refunding the money and releasing the source code just from the update titles, even though only backers can see the post contents.

nielsm
Jun 1, 2009



Hammerite posted:

How does someone learn Python to the degree of competence necessary to make this... thing, without picking up ideas like "split the project up into multiple modules in a logical fashion" and "put that poo poo in a docstring like a normal person"?

It mostly looks like something out of a 1980es BASIC game.
(What's the difference between ListCmp and ListCmp2 ?)


Plorkyeran posted:

Python 3 adds nonlocal for exactly that.

I thought I had seen that keyword before. Turns out we're just using the wrong version here. Ugh.
(And we could probably upgrade too.)

b0red
Apr 3, 2013

Flashing Twelve posted:

So the guy behind failed kickstarted roguelike CultRL has released his source code.

https://bitbucket.org/dmhagar/empyrea-public/raw/4759faba1443e6105ff6cbf9c2829735f55df593/empyrea.py

It's, uhh, it's something alright.

yeah. who the hell needs to split source code into multiple files. throwing it all into one is always the best way.

Huragok
Sep 14, 2011
Python imports and environments are two other things that grind my gears.

xtal
Jan 9, 2011

by Fluffdaddy
Guys when it comes to games you just can't accept the overhead of importing other files.

Gazpacho
Jun 18, 2004

by Fluffdaddy
Slippery Tilde

Hammerite posted:

How does someone learn Python to the degree of competence necessary to make this... thing, without picking up ideas like "split the project up into multiple modules in a logical fashion" and "put that poo poo in a docstring like a normal person"?
I've seen no correspondence at all between being an effective software engineer (able to deliver a product) and willingness to factor code. Wish I could say otherwise.

fritz
Jul 26, 2003

nielsm posted:

(What's the difference between ListCmp and ListCmp2 ?)


I got curious, and one compares lists by their first element and one by the second. ListCmp2 is identical to DictCmp, in case you were wondering.

Huragok posted:

That's another crappy thing about python: no switch-case equivalent. I like syntactic purity as much as the next guy, but you'll also have to yield to pragmatism at some point for the sake of readability and maintainability.

It's not the repeated-ifs-to-fake-a-switch I thought was bad it was the general hamfistedness nature of it. ETA: to be honest, I felt a little better about that switch once I realized that checklist could only every have one element, but dang, it's still bad.


I also like the fact that he's doing "wfeaturedict['%s,%s' % (x,y)]" instead of "wfeaturedict[x,y]". At least he doesn't appear to ever have to split that back out and cast to integers.

Also jiminy christmas:
code:

def modifyList(curpos):
    curpos = list(curpos)
    compos = curpos.index(',')
    curpos.remove(',')
    curpos = [curpos[0:compos],curpos[compos:]]
    curpos[0] = int(''.join(map(lambda x: str(x),curpos[0])))
    curpos[1] = int(''.join(map(lambda x: str(x),curpos[1])))
    return curpos
at least it's never called. :unsmith:

fritz fucked around with this message at 17:24 on Sep 24, 2013

astr0man
Feb 21, 2007

hollyeo deuroga
Clearly the worst part of that is that he's using camelCase in Python.

Huragok
Sep 14, 2011

astr0man posted:

Clearly the worst part of that is that he's using camelCase in Python.

Sure it's not idiomatic python, but it's fine as long as you stick the convention throughout the source, no?

astr0man
Feb 21, 2007

hollyeo deuroga
It was a joke

DaTroof
Nov 16, 2000

CC LIMERICK CONTEST GRAND CHAMPION
There once was a poster named Troof
Who was getting quite long in the toof

Hammerite posted:

Ahah

[snip]

How does someone learn Python to the degree of competence necessary to make this... thing, without picking up ideas like "split the project up into multiple modules in a logical fashion" and "put that poo poo in a docstring like a normal person"?

Nice of him to include a table of contents, but I would have preferred an alphabetical index of function names that tells us the line numbers where they get used.

Bonfire Lit
Jul 9, 2008

If you're one of the sinners who caused this please unfriend me now.

astr0man posted:

It was a joke
There's enough people who will tell you you're literally a worse human being than Pol Pot for not following PEP 8 to the letter that you can't expect everyone to get your joke

Qwertycoatl
Dec 31, 2008

Someone's trying to outdo losethos with their own homegrown language/OS monstrosity:
http://www.urbit.org/2013/08/22/Chapter-0-intro.html

quote:

If I can summarize Hoon’s goal, it’s to be the C of functional programming

So, how great an idea is this? Let's take a look at the networking code:
https://github.com/cgyarvin/urbit/blob/6012eed7a31f7dc9db323dbc4b1cbf361923f620/lib/191/arvo/ames.hoon
code:
!:
:: ames (4a), networking
::
  |= pit=vase
  ^- vane
  => =~
  ::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  :: section 4aA, identity logic ::
  ::
  |%
  ::
  ++ grip :: extend will
    |= [wet=will law=will]
    ^- will
    ?~ wet law
    ?: =(wet law) law
    ?^ t.wet
      ?>((meld i.wet i.t.wet) [i.wet $(wet t.wet)])
    ?~ law
      ?>((pier i.wet) [i.wet ~])
    ?~ q.p.q.i.wet
      ?>((meld i.wet i.law) [i.wet law])
    =+ rul=(sein r.p.q.i.wet)
    |- ^- will
    ?: ?& =(rul r.p.q.i.law)
            =(p.p.q.i.law u.q.p.q.i.wet)
        ==
      ?>((meld i.wet i.law) [i.wet law])
    ?>(?=(^ t.law) $(law t.law))
  ::
  ++ meld :: verify connect
    |= [new=deed old=deed]
    ^- &
    ?> (melt new old)
    ?> =((shaf %meld (sham q.new)) (need (sure:pu:(hail r.q.old) *code p.new)))
    %&
  ::
And so on. That file is 1500 lines. There are many other files. I've never before seen so much effort put into completely incomprehensible insanity.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

Qwertycoatl posted:

Someone's trying to outdo losethos with their own homegrown language/OS monstrosity:

quote:

So if we had to read the above decrement, omitting the spaces (which only a real purist would pronounce), we’d say: “luslus dec sigfas cen dec bartis a tis pat sigbar soq dec soq ketcab pat wutgal tis pel zero a per tislus b tis pat barhep wutcol tis pel a lus pel b per per b buc pel b lus pel b per per.”

Dren
Jan 5, 2001

Pillbug
There is possibly more than one person working on this

quote:

If you’re wondering how we wrote Hoon in Hoon when we didn’t have Hoon, the answer is that we wrote Hoon in C and evolved this C code into a mere jet.

And just some stuff.

quote:

Hoon, like Lisp, unlike Haskell, is also very comfortable with typeless data; it should be, because it has no types, only “types.”

quote:

On the other hand, the apparent complexity of Hoon is very high. When you open a Hoon file, you are confronted with an enormous avalanche of barely structured line noise. Again this reminds us of C, which makes no attempt at the kind of abstract prettiness we expect from a Pascal or a Haskell. Learning Hoon involves learning nearly 100 ASCII digraph “runes.”

Presto
Nov 22, 2002

Keep calm and Harry on.

quote:

You just have to memorize these names. Sorry.

No, actually I don't.

JawnV6
Jul 4, 2004

So hot ...
law.l

Qwertycoatl
Dec 31, 2008

He has unorthodox ideas about software versioning, too:

quote:

In Kelvin versioning, releases count down by integer degrees Kelvin. At absolute zero, the system can no longer be changed. At 1K, one more modification is possible. And so on. For instance, Nock is at 9K. It might change, though it probably won't. Nouns themselves are at 0K - it is impossible to imagine changing anything about those three sentences

Adbot
ADBOT LOVES YOU

Dren
Jan 5, 2001

Pillbug
To be as nice as I possibly can, this guy is absolutely awful at communicating the main idea of Hoon. I honestly can't tell if there is an idea here worth a further look.

Here is the hackernews thread. https://news.ycombinator.com/item?id=6438320

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply