Welcome to the BitCave!
Last Updated 12:27am PDT 02/11/14
This is Bits, and I’d like to welcome you to the BitCave, a central thread for discussion of the technical, design and coding aspects of Lua, AI, and Mods in general (I wish there was a way to Cross-Post). There will be tons of resources in this thread, and I will update the OP regularly with new info and ideas (It’s likely to get quite long). So with that, a disclaimer:
!!!WARNING!!!
This thread contains learning, humor, and more nerdiness. If you do not want to become infected, please direct your mouse to your back button and click vigorously until safety is assured, sometime after ~3000 clicks. Symptoms of learning include, but are not limited to:
- Mild loss of giving a crap about anything but this cool new thing you’ve learned.
- Knowing stuff, and being ‘That Guy who knows stuff’ in conversations.
- Experiencing idea cascades leading to sleeplessness, excitability, obsessive tendencies and a lack of measurable productivity
- A secondary symptom is eye and finger strain from clicking through and reading too much Wikipedia
- A penchant for correct spelling and a mocking disregard for correct grammar do.
- Magical beans which you decide are fake until scientifically proven to be magical.
- A shockingly adverse allergy to stupid.
If you experience ANY combination of these symptoms, it is highly likely that you have begun LEARNING, a dangerous, unregulated mental compulsion that can quickly lead to the demise of ignorance and an explosion of unfettered curiosity, And big words. If this happens to you, please consult a physician about how he got his job and how you can teach it to yourself using WebMD. THEY LOVE THIS.
So, on to the useful bits!
Resources
First we will go over places to learn Lua, the coding language used to write Mods and Additions to the game. Lua is a pretty uniform language, so you’ll want to specifically learn how further functions and processes are implemented in it. Radiant will most likely be providing us a ton of function that will serve as an API (Application Programming Interface) to connect us into the magic that is Stonehearth’s core, so knowing how to implement and use the various Lua bindings a program will have, not so much specifically, but generally, will be the first thing you need to master. I also write in way too many run-on sentences, so here’s a list:
Lua Tutorials
- http://luatut.com/introduction.html
- http://luatut.com/crash_course.html
- http://lua-users.org/wiki/TutorialDirectory
- http://lua.gts-stolberg.de/en/index.php?uml=1
Places to Practice
Lua
Javascript
HTML/CSS
References From This Very Forum (THANKS @SteveAdamo!)
- http://discourse.stonehearth.net/t/modding-in-lua-an-overview/508
- http://discourse.stonehearth.net/t/lua-sources-of-information-tutorials-guides-books-references-etc/1373
- http://discourse.stonehearth.net/t/lua-script-random-numbers-easy/1342
- http://discourse.stonehearth.net/t/lua-script-highest-lowest-number-easy/1427
- http://discourse.stonehearth.net/t/lua-check-if-file-exists-easy/1484
More From the Forum! (Thanks @voxel_pirate)
- http://discourse.stonehearth.net/t/best-self-teaching-resources-for-java-c-others/3015
- http://discourse.stonehearth.net/t/learning-how-to-mod-stonehearth/2352
Once you know the basics, You’ll need a place to implement it, and test your skills within an actual program. There are quite a few that already support it, but here are three of my favorites:
Once you get primed and ready, and become a Master Lua Slinger, spitting code so hot that it burns straight to the concrete floor of your mother’s basement, You will want to know where you can actually use this stuff. Well as a bonus that’s what the next section is about.
AI discussions and dissections within this topic
- http://discourse.stonehearth.net/t/welcome-to-the-bitcave-nerdiness-jokes-mods-ideas-and-coding/1622/56 (@voxel_pirate)
- http://discourse.stonehearth.net/t/welcome-to-the-bitcave-nerdiness-jokes-mods-ideas-and-coding/1622/57 (@jonyon54)
- http://discourse.stonehearth.net/t/welcome-to-the-bitcave-nerdiness-jokes-mods-ideas-and-coding/1622/59 (@Xavion)
Logic and AI, and Making Yours Better Than Theirs
It’s no secret that my first mod project is gigantic, that it’s essentially building a competitive AI Smackdown ladder where the hackers who can best optimize, improve and streamline their voxel-based pals can rise to the top and create Skynet. Or something. So, in that vein I have found some slightly more advanced articles on A* (pronounced ‘a-star’) pathfinding and AI logic. Save the Stanford article until you’re in that mood. You know, the one where you want your brain to pop. In order of complexity:
- A* Pathfinding Primer
- Two-Tiered A* Pathfinding
- Using Binary Heaps in Pathfinding
- Toward More Realistic Pathfinding
- Pathfinding Almanac (No, Seriously. Thanks @SteveAdamo)
- The use of Fuzzy Logic for Artificial Intelligence in Games (PDF)
- Logic and Artificial Intelligence (THE STANFORD PAPER)
Further Reading
And finally, we have a spattering of articles on Gamasutra about AI, Storytelling, and Design:
- Amit’s Game Programming Information (Thanks @Xavion!)
- The Designer’s Notebook: Three Problems for Interactive Storytellers, Resolved
- When Players Make the Rules: On Memes and the Meta-Game
- The Designer’s Notebook: Machinations, A New Way to Design Game Mechanics
- On Player Characters and Self Expression
- When Players Make the Rules: On Memes and the Meta-Game
- Programming Sins - Common Errors From Down In The Trenches
- The Secrets Of Enemy AI In Uncharted 2
- Scaling Ambient Animations for Improved Game Experience
- Two Brains Are Better Than One – How to Thread Game AI
- OMG, Multi-Threading is Easier Than Networking
- Video: Embracing the dark art of mathematical modeling in AI
- Video: Three unorthodox uses for video game AI
- GDC 2012: AI programmers can be artists!
- Hitman Tech Head: AI Programming Fun, But ‘Most Difficult Place To Be’
- From @Ondaderthad: The Procedural Generation Bible (or wiki) << Super Awesome!
Some of these are fascinating, some slogs through technical details and some might be more for @Ponder and @Tom than for any of us. Though they’ve prolly already read them.
Anyhow, now that we have a grasp of Lua, some fiddling experience with it, some knowledge of AI and Logic, and ideas spawned from reading random articles, let’s get to the good stuff.
Mod Ideas and Development Fun
This is where I dump all of my mod ideas, flesh them out, and once we have some beta, dump code and stuff. First, as you’d expect, is:
AI SMACKDOWN
What is an AI Smackdown? Who cares? It’s awesome and I care, that’s what! Some of you may remember me mentioning it during the Pizza Party, but here’s the gist:
Given how ridiculously moddable Stonehearth is shaping up to be, the fact that the units are somewhat autonomous, and the ease of programming in Lua (It's really not super hard!), I believe it is the perfect place to allow people to customize their AI, in addition to their Kingdom, and pit that AI against another Player's (or another of their own) in brutal, efficient combat.
The general plan is to provide an alternative ladder for AI modders (as I doubt mods will be allowed in competitive vanilla play. Read: I GAVE MYSELF DRAGON ARMOR AND INVISIBILITY!) to pit there modded logic and pathfinding against that of their friends and rivals. Will your troops turtle up behind bottlenecks and wait for the enemy to flood into the killing field? Or will your troops perform strategic raids, striking like a blitzkrieg before making a quick tactical retreat before hailing arrows into your pursuers?
As would most definitely be necessary, there will be balancing of the ladder over time. Glitching will most likely be prohibited (glitching being a way of guaranteeing a win through taking advantage of bugs.) But initially it will be a rumpus house of creative juices flowing into Lua magic. We would go from, "Oh look a nearby enemy, punch it until it dies" to "OH CRAP BAD GUYS! TELL EVERYONE TO GO TO DEFCON 'OHSHIT' AND BARRICADE THE WALLS! UNIT A TO POSTS! UNIT B FOCUS FIRE ON MY TARGET!" or something like that. I really can't wait.
Ideally the system would be self-regulating, but I know that there will be some ne'er-do-wells. So the real key to implementing this won't be figuring out how to enable mods in my sideloaded competitive ladder, it will be introducing self-regulation to limit or deny players with invincibility mods and so forth. I'm thinking providing tools for the community to self-regulate will be best. Beyond that, once beta comes out I will be diving into AI programming, starting with trying to sort out getting your units to communicate efficiently, then teaching them how to get places more better do, and finally making them read The Art of War.
This is extremely early design, so I'll be updating and uploading graphics, designs, simple challenges to hone your skills, and eventually (if I really get a lot of spare time) I will be compiling it into a manual to get started. I have to come up with a name for the ladder, probably have to get a domain to manage it, and I'm going to be reaching out to schools and universities once it's released to allow the largest number of people to participate.
@Tom & @Ponder, I do kind of wonder if down the road you’d be willing to officially (not really fiscally) back major educational AI Romps. Would you? < /Didyareadittest >
Audio Injection API/GUI
Once the game comes out, I’ll be slapping up an API/GUI to inject music of your choosing into the game. So if you want @Raj’s or @CaseyEdwards’ music in your game, in addition (or replacing) the stock music, you can totally do that. I am entirely confident that the default musical score will be epic, but I’m all about choice, and this reflects that. If I do end up creating an API, it will allow for detailed event scripting, and will function mostly as a library for mods that would like to add scripted musical events easily and quickly (essentially it would be a function that would allow you to play, pause, stop, loop, and control the relative volume of an asset or a (randomized?) playlist of assets, in whatever auditory formats Stonehearth natively supports (adding new ones may present licensing challenges… Time will tell.)
Other Stuff!
IF YOU RUN INTO AN ARTICLE YOU WANT ME TO ADD TO THE LIST, LET ME KNOW!
Daily Learning Challenge! (Still sort of on Hiatus.)
I’m almost done for the day, but today’s challenge is using computercraft or one of these (one) (two) emulators to create a program that could be construed as a hilariously broken Spelling Bee. (Broken as the answers are in the question.) and post your Lua code to the thread (Use a pastebin if it’s huge and make sure to select Lua as the codetype!). Show us that you can handle update loops, user input, and string comparison! Most efficient code gets a shoutout (! @Xavion !) , and will be immortalized in this post! (The emulators are multiplatform @Xavion )
Challenge Two was downloading Decoda, the software Radiant uses to debug their code, and playing around with it. Make it through the first luatut page! Best of luck!
Challenge One was getting luaforwindows installed on your machine! Go You! You can do it!