News for hackers. Stuff that matters.
Re:Choosing Functional Programming for Our Game by SomeStupidPoint on Monday December 19, 2016 @07:03PM (#13216165)
Just a nitpick: you can live code in imperative languages and functional languages can require compilation. That has more to do with your design, framework, and tooling than the language itself. It mostly is a divide between compiled and interpreted languages, though that distinction gets blurrier over time.

That said, Im a big fan of functional languages for game scripts (and got in to that myself using LISP on text MUDs).

Re:Choosing Functional Programming for Our Game by throwaway7645 on Monday December 19, 2016 @07:08PM (#13216191)
Can you go into detail on using LISP for text MUDS? I have an appreciation for text based games. I find the simplicity to be elegant.
Re:Choosing Functional Programming for Our Game by SomeStupidPoint on Monday December 19, 2016 @07:24PM (#13216290)
I was only a lowly content builder and quest manager, so I can't speak much to how the server mechanics worked.

But essentially, each entity (usually a mob) would have a set of event scripts (attached to some kind of internal lookup table), and each time an event happened, it would call the appropriate scripts/function/macro.

So what I did was logic such as "game tick -> wander one step in a random direction" or "player enters room -> attack", but also slightly more complex ones such as "combat round -> if low health, flee".

The cool feature of the server was that you could specify multiple options in the template, and it would randomly pick one for a newly created instance, giving some variety to behaviors (eg, some guards flee and some fight to the death). Each instance could also be given a specific one after instantiated, which was how we constructed special events. (That is, use an existing template, tweak a couple behaviors of the instance, and then redecorate it.) This is mostly just a benefit of first-class functions and LISP's ability to switch strings to code.

LISP was mostly just nice in that you could often one-line fairly complex behavior, so you could build in-game over telnet.

Honestly, I really miss text MUDs, but does anyone actually want to read anymore?

Re:Choosing Functional Programming for Our Game by philipov on Monday December 19, 2016 @07:48PM (#13216409)
I too was a mobprogs builder, but I hung around diku-based muds, and none of those used lisp. I loved the SMAUG codebase in particular. There was a NO_FLOOR property, and I discovered that there was an brief input delay on hitting the floor, during which your commands would be completely thrown out of the buffer. If you made an On Entry script in the destination room to immediately teleport the player back to the room with no floor, you'd trap them in an infinite loop that didn't buffer overflow, and completely ignored their commands. They would fall, hit the floor, and before their input block had ended, they would be falling again.

Now, did you know that SMAUG's mudprogs ignored level restrictions, but could be activated by any IMM's force command? So when you force the mob to mpteleport a player, it doesn't check that you're only level 55 and the mpteleport target is level 65... so I called that a prison for gods.

I think I spent more time trying to break the code than actually producing content.

Re:Choosing Functional Programming for Our Game by SomeStupidPoint on Monday December 19, 2016 @09:32PM (#13216935)
For anyone reading: this is basically how all hacking works and why security is hard -- you have to think out every way several components might interact.
Re:Choosing Functional Programming for Our Game by throwaway7645 on Monday December 19, 2016 @09:44PM (#13216995)
I love text games. Looking forward to taustation which is going into alpha soon and written by a prolific perl author. Good stuff. Check out the blog articles.
Re:Choosing Functional Programming for Our Game by pdpi on Monday December 19, 2016 @07:48PM (#13216411)
I, for one, do. I have many fun memories playing in some MUDs, but never really read as much as I'd like about the development side of it.
Re:Choosing Functional Programming for Our Game by aptwebapps on Tuesday December 20, 2016 @03:00AM (#13218240)
The first code I ever wrote that was actually used by (not very many) people was in LPC ... good times.
Re:Choosing Functional Programming for Our Game by GavinMcG on Monday December 19, 2016 @07:25PM (#13216292)
This may not be what you're looking for, but it's a nifty example of building a small text adventure system in Racket and then leveraging its language building tools.

http://queue.acm.org/detail.cfm?id=2068896

Re:Choosing Functional Programming for Our Game by escherize on Monday December 19, 2016 @07:23PM (#13216285)
Re:Choosing Functional Programming for Our Game by ramseynasser on Tuesday December 20, 2016 @01:10PM (#13222332)
Fair, but there's an important difference between a tool where live coding is technically possible and a tool designed to support it. Clojure is built from the ground up for the REPL experience and supports e.g. redefining functions seamlessly. The fact that it's functional helps a lot, too, since that means that the order things are defined or executed in matters less.
Re:Choosing Functional Programming for Our Game by SomeStupidPoint on Tuesday December 20, 2016 @02:01PM (#13222807)
Python is an example of an OO + imperative language with a built in REPL.

My point was that it has to do with if there's an interpreter for the language, and if the interpreter works with your toolchain.

And that with the advent of JIT, that distinction becomes increasingly blurry, because the techniques to compile and link small blocks of code can be used by languages without an interpreter, per se.

Re:Choosing Functional Programming for Our Game by ramseynasser on Tuesday December 20, 2016 @03:07PM (#13223461)
Right, Clojure is always compiled and achieves live coding by running on top of VMs that support dynamic code emission.

Python REPLs are quite good, but in my experience order dependent state-mutating code can get tricky in an interactive context. FP helps a lot here.

Re:Choosing Functional Programming for Our Game by binthere on Monday December 19, 2016 @07:41PM (#13216361)
I believe that on Unreal Engine 4, you use C++ and it does have a feature that mimics "live coding" where it recompiles and hot-reload your game even while playing.

edit: here it is https://youtu.be/MOvfn1p92_8?t=580 (jump to 9:40 if it doesn't load at this point automatically)

Re:Choosing Functional Programming for Our Game by fdb on Tuesday December 20, 2016 @11:09AM (#13221066)
Handmade Hero implements a live coding workflow in C++: https://www.youtube.com/watch?v=WMSBRk5WG58
Re:Choosing Functional Programming for Our Game by davexunit on Tuesday December 20, 2016 @09:26PM (#13226342)
That's a far cry from a REPL.
Re:Choosing Functional Programming for Our Game by iopq on Monday December 19, 2016 @08:44PM (#13216647)
I've seen a C++ program get changed while it was running.