Source Code
This is a non-profit work of fan fiction. My Little Pony © Hasbro.
Chapter 1
/*-----------------------------------------*\
|PROJECT: Equine Sentient Life Simulation |
|AUTHOR: Alan Maize |
|DATE: 10-09-2012 |
|COMMENT: Test of sentient life in a virtual|
| environment. |
\*-----------------------------------------*/#include <cstd>
#include <cmath>
#include <iostream>
#include <string>
#include "source.h"
#include "ioaudio.h"
#include "cleverbot.h"
using namespace std;enum species{ //List of sapient beings
spEarthling,
spUnicorn,
spPegasus,
spAlicorn,
spGryphon,
spDragon,
spDonkey,
spMinotaur,
spPhoenix,
spDiamondDog,
spChangeling
};class Equestrian{ //Basic civilian class
private:
float x, y, z; //Position in world
species type; //What they are
audioStreamOut *voice; //Audio stream for speaking
audioStreamIn *ear; //Audio stream in from microphone
mdl *body; //Appearance
string name; //Textual identifier
Equestrian *next, *prev; //For linked list
Vector3 speed; //Required for movement by source enginepublic:
Equestrian(float X, float Y, float Z, char* Name, mdl* Body){ //Constructor class
};
}*firstEquis; //Pointer to first instance
The cursor on my screen blinked at a steady pace, waiting in the body of the Equestrian constructor for me to enter the next line of code. The first step would be simple, have the instance add itself to a linked list so that it could be processed systematically with all the others.
I took a sip of coffee that was laced with 5 Hour Energy. I don't know how I came up with this idea, it just hit me. Maybe the fact that I was torrenting Tron and Reboot while being high on my usual "stamina potion" had something to do with it.
But I wanted to create something new, a simulation without players, only computers. It wasn't like the other games I made where the actors had to interact with a player to evolve. I wanted to make a world where they grew by comunicating with each other.
Being the fantasy gamer I was, I went with using fantasy creatures from other games, except for humanoids like elves and dwarves that I found too conventional and rather boring. That, and, it would be interesting to see if a society could exist with most of the population not having hands, as well as a multitude of different diets.
But first, I would need to test if one could survive on their own.
int main(){
…
//Create first Equestrian, Princess Celestia
mdl *mdlSunPrincess = sourceLoadModel("res\\models\\solar_alicorn.mdl"); //Load Celestia's model
firstEquis = new Equestrian(0, 0, 0, "Celestia", mdlSunPrincess); //Initiate Celestiamap *world = sourceLoadBSP("res\\maps\\freerun_city.bsp"); //Test map
…
return 0; //End program
};
I added a loop that would continue the simulation until I told it to stop. Then, I ran it.
36273 errors found.
Ending compilation.
I stared at the screen. My eye twitched. I slowly reached over and added another 5 Hour Energy to my coffee in preparation for the long night ahead of me.
Finally! Three grueling days of non-stop coding, a full 24 hours of sleep, some jogging to loosen up my stiff body, and I was finally ready! I clicked "Build and run" on the toolbar, and a few minutes later, the first test was up and running.
I looked at the image of the regal white alicorn standing in the middle of Freerunner City. She blinked, and then looked around in mild disorientation. I leaned in closer, zooming in on her as she opened her mouth to speak.
"Wh... where am I?"
The interface, including the name tag floating over her head, were all invisible to her. She didn't know the name of the city by either its identifier or its file name.
She started to look at herself. "Who am I? Whaaaaaaaaa--"
The screen fizzled and the process terminated. I sighed and rubbed my forehead. Answering these questions herself must have been too much for her. She needed a teacher.
And a sister.
Celestia awoke again in the desserted street. Something strange and unseen had knocked her out, and she didn't realize how long she'd been unconsious. She shakily stood up on her hooves, and took a moment to inspect herself.
Soft, white fur lined her entire body. Upon her head was a spiral horn, and on her sides was a pair of large, majestic wings. Majestic. Was that the right word? It felt right to her. Upon her body were golden adornments of some kind, perhaps a symbol of rank.
Then she tried to look inward. Her mind was full of words and lines that made no sense to her. Among them was something peculiar.
name = "Celestia";
"Celestia," she said aloud to herself. The sound of the word clicked in her mind, and told her it was correct. Correct about what? Her identity? Yes, that's what it was.
"Hello?" Another voice was coming from somewhere in the otherwise empty city.
Celestia turned her head in the direction of the voice. Something about it was familiar. She moved her legs and found she was able to walk forward. But should she answer the voice?
"Hello?" it said again, sounding more frightened than before.
Celestia didn't blame the other one for being scared; this place was cold and lifeless. But was there ever anything before this? She tried to think back, but nothing came to her. The alicorn turned a corner and saw another like her, but different.
This one was smaller, witha dark blue coat, and a transparent mane that swayed on its own much like Celestia's rainbow mane. Her eyes showed lonliness and fear, the latter of which completely overtook the former when they met each other's gaze.
The smaller pony gasped and stepped back. "Who-who are you? Who am I? Where are we?"
Celestia looked solemnly at her new companion. "It's OK. I don't know where we are, or how we got here, but I am not going to hurt you. Can you remember your name?"
"Name?" the dark one asked, "How do I know my name?"
"Look inside yourself," Celestia calmly instructed, "You will find it somewhere, just as I did."
The new alicorn closed her eyes and remained silent for a moment. "It's... Luna. M-my name is Luna. I think."
"Luna," Celestia repeated, "Why does that sound familiar?"
"Because she is your sister."
Well, here you go. Another story. Yup.
Anywho, the nerd in me wanted to write a story for other nerds. So I wrote one about Equestria being just a program. And yes, I got the idea while watching Tron. No, Alan will not physically go to Equestria, but he will communicate with the ponies at some point.
For those knowledgable in C++, feel free to nitpick the snippets of code I included. I know the code to writing a sim like this would be far more complex, but I only wanted to include enough fir readers to get the gist of what's going on. Besides, an entire chapter written in C++ would not only be boring, but likely against the rules. So don't take the code snippets too seriously. They're just samples of what Alan sees on screen.
... Tracking.....
Is Alan named after Turing?
I think you've managed to find an idea that hasn't ever been done. Congratulations.
Definitely reading this.
Interesting concept. But using an enum for the species seems questionable to me. Wouldn't it make more sense to use subclasses of a basic Equestrian superclass?
Also, you are just asking for trouble if you write a virtual world in C++ instead of a safer language like Java or C#.
36,273 errors? How does one even get that many errors? Did he write the entire simulation in one go, failing to use any of a dozen good programming practices to make his life easier? And those are only the errors the compiler can catch. Run time errors are infinitely more devious, and based on the complexity of the simulation and his sloppy debugging process, I wouldn't be surprised to see them popping up frequently.
I'll track this, because there needs to be more programming-based stories. Also, because I want to see what happens when Equestria gets swallowed up in a segmentation fault or stack overflow. Or corruption of the call stack. I'll even settle for memory leaks and infinite loops. I wonder what that would be like from Celestia and Luna's point of view. They probably wouldn't even notice, losing any awareness of events that transpired since the last write to disk.
1417464 Dunno him. Sorry. I named him after Alan from Tron, since that's what inspired this story.
1417641 Because I know C++. And as this is just a fantasy story, I didn't wanna overwhelm the readers by including too many advanced codes. I just wanted to make it realistic enough that it would make some ammount of sense to non-programmers, unlike the bizzare jumble of code seen on Donatello's computer in Ninja Turtles 3.
1417646 The errors was just a joke. But yes, there will be glitches in the system. Partly for comedy, partly for plot.
1417646
He must be one of those die-hard vim users, or some other plain text edtitor, who doesn't believe in modern IDEs that can catch and highlight virtually all compile time errors in real time as you write code before they actually become compile time errors. "IDE? I don't need one of those new fangled things they call IDEs! I've got vim!"
Either that or he forgot to tell the linker where his libraries were located and they are all unsatisfied link errors.
1418613 Alan Turing? Father of modern computing and artificial intelligence? I mean, one of the key concepts of artificial intelligence is the idea that someday, a computer could pass a Turing test, imitating human behavior so perfectly that another human couldn't distinguish between human and machine. That's basically what Alan is doing here, creating a perfect AI. And from my research, it seems Dr. Alan Bradley, creator of Tron (the program), is a nod to the human-machine interface corporation Allen-Bradley (probably more fitting, as Tron was more about human-machine interaction [and freedom of information and viruses] than it was about artificial intelligence).
1418730 I use emacs, it doesn't catch errors as I type. Can't say I've ever gotten anywhere near 36,273 errors, though. Of course, I tend to compile every time I test a function, so it's not like there is enough new code to house 36,273 compile-time errors. And most compilers ignore duplicate errors. "Oh, 500 implicit declarations of strcmp? I'm go to save space and only mention it once." However, I wouldn't be surprised if a good chunk of those were "semicolon expected" errors. They're (usually) really easy to fix, but every time one pops up, it makes you feel like an idiot.
1420264 I used to use Emacs a lot. But I finally jumped on the Eclipse bandwagon. I still use Emacs a lot for fan fic writing though. Either that or jEdit. Lately I've been using jEdit a lot more because I simply started to get fed up with limitations in emacs (such as inability to support multiple modes in the same buffer), and the fact that I just got tired of having to remember an entirely non-standard set of keyboard shortcuts for just one program.
1420516 Writing fan fiction in emacs? I think you win most insane writer ever. And yeah, it is kinda ridiculous that emacs uses a different set of keyboard shortcuts. After a long night of programming, I had opened up Word to do some other work, only to try and save with C-x-C-s. It worked, but I felt silly. Although I do enjoy referring to cut-pasting as kill-yanking.
1420625 Emacs actually makes a great writing tool with flyspell mode and nxml mode. You might actually enjoy an article I wrote a while back. I'd be interested in your comments. Of course, leave the comments over there. Not here.
I write my fanfics in metapad http://liquidninja.com/metapad/ .
1413371
I don't know much about C++, but if it's the base class, wouldn't it be public?
1418730>>1420625>>1422072 Shut up about text editors. That is not the point of the story. Please continue your conversation in PM or IRC or anywhere that isn't someone's comment box.
1422087 You must be thinking of C#/Java. C++ uses a function call to main().
1423708
I was actually thinking of C#. Good to know.
Awsomesuace dude, best story yet! I look forward to seeing how this plays out.
this would explain pinkie's reality breaking abilities she's glitching the system
Ew, 1TBS