Bay 12 Games Forum

Finally... => Creative Projects => Topic started by: Outcast Orange on December 06, 2010, 07:37:17 pm

Title: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 06, 2010, 07:37:17 pm
Burried Houses is currently a simple AI simulation I've been building,
 but it will eventually be an interactive "experience" involving puzzling, diplomacy, and survival.

Debug list of short term memories:
Spoiler (click to show/hide)

Running in ultimate debug mode:
Spoiler (click to show/hide)

Current features:
- Long term memory of rooms, doors, and items
- AI Motivated by goal/action trees
- AI will create procedural goals to enter new doors found
- AI will create procedural goals to collect useful items found
- AI will wander to random rooms when there is nothing left to do
- AI creates short term memories of events
- AI can observe rooms through open doorways
- AI can create prerequisite goal relationships
- AI can unlock portals with keys
- AI can keep track of key/lock relationships

Next planned changes:
- ???
Title: Re: Burried Houses
Post by: Outcast Orange on December 06, 2010, 07:38:01 pm
I've been working on this AI project for the better part of a few months now (sparingly though).
It's finally hit the stage where I can work on it often without losing too much interest
 due to slogging through code and painful debugging issues.
The better part of a week was spent building in debug options and streamlining the debug procedure overall.
I've also gotten most of the really bad code out of the way.
My AI is doing some pretty neat tricks by now, and I thought I'd dump this back out into the public light.

Anyways, this project is a continuation/reboot/do-over of something I was working on for a few months last year (http://www.bay12forums.com/smf/index.php?topic=56077.0).

The current AI creates a memory version of everything it comes into contact with,
 updating the status of things whenever they are present.
So far this only includes rooms, doors, and items.
The pathfinding also works well.

My AI has a built in goal tree with associated actions.
The only default action I've added so far is "wander"
 which will pick a room at random and have them path over to it.
The AI will always be driven by such goals and their associated actions,
 picking the best ones based on weight and success rate (currently built in).

Besides these basic goal trees they can create their own procedurally generated goal trees in certain situations.
When they see a door they haven't opened, the'll add a goal to enter it.
When they see a useful item, they'll create a goal to collect it.
These goals and goal-actions store vital information about the task for later use,
 such as the location of the task and the index of the objective in their memory.

So for now all they can do is wander around exploring stuff and collecting keys,
 but they have one more trick up their sleeve.
The AI stores short-term memories of every event that happens,
 which go into a list where they slowly rot until they are forgotten.
These events are currently remembered by the AI in short term:
   - Discovery of new doors or useful items
   - Actions performed such as walking between rooms
   - Collection of useful items

That is just about everything for now.
Title: Re: Burried Houses (AI Programming Project)
Post by: Supermikhail on December 08, 2010, 09:12:29 am
Hm, with some parsing, the text in the screenshot could almost become interesting... Err, I mean, besides actions, it would be cool if discoveries were in a better-readable form. Like, not "Portal Found", but "Orange has discovered a portal" or something.
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 08, 2010, 10:02:55 am
To be fair, the green text is for debug clarity. Only the white text is currently meant to be read by the user.

I actually plan on making some procedurally generated sentences later on for flavor.
Especially for things such as character interaction and to facilitate some of the puzzles later on.

Thank you for the input though, I've been a little starved lately.

EDIT:

There are potential future issues with my current goal structure, so I'm back in a planning state until I can decide on the best way to proceed.
I also have to put in prerequisite goals and actions so things can be performed in a proper order.
Title: Re: Burried Houses (AI Programming Project)
Post by: Supermikhail on December 08, 2010, 10:14:40 am
To be fair, the green text is for debug clarity. Only the white text is currently meant to be read by the user.
I figured as much, "Err..." is where I did. I read the green text and thought it could be interesting, too.
Thank you for the input though, I've been a little starved lately.
No problem.
EDIT:

There are potential future issues with my current goal structure, so I'm back in a planning state until I can decide on the best way to proceed.
I also have to put in prerequisite goals and actions so things can be performed in a proper order.
Don't you try to abandon it! >:(

Seriously, sounds like an awesome idea and my dream.
Title: Re: Burried Houses (AI Programming Project)
Post by: Knight of Fools on December 08, 2010, 01:04:16 pm
Sounds interesting: It's simple enough to take little processing, but complex enough to make a casual observer think that the AI was actually trying to do something.

I don't know why, but I keep thinking about how much more realistic it'd make First Person Shooter AI...

What are your ultimate goals for the project?  Are you just experimenting, or is it going to be a game (Or part of a game)?
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 08, 2010, 06:25:56 pm
The final aim is to have a sort of mystery puzzle situation with interpersonal diplomacy elements,
 sort of like if LOST was a video game with an AI cast.
The default would probably be direct control of a character,
 but it would just as easily run as a simulator giving the user full control over all content.

I imagine it would be fun to play the part of any of the deterring agents,
 not to mention some of the "regular cast" will have goals or causes which push them to be violent.
Examples would include characters with assasination orders, phycho killers, theives,
 and basically any sort of motivation, since we could just break it down into goals.

I think I'm going to look back through the code tonight and if I don't see any glaringly obvious issues
 I'll start working on prerequisite goals.

I abandoned projects before, sure, but I have been into this one for the better part of this year, at least mentally.
I don't think it will go pear-shaped like Cloud Scream.
I only wandered awy from that project in the first place in order to better focus on pure AI.
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 12, 2010, 02:11:07 pm
I've been working on prerequisite goals.
Now things can be done in proper order for situations that don't make sense otherwise.

I've also added these pictures to the original post:

Debug list of short term memories:
Spoiler (click to show/hide)

Running in ultimate debug mode:
Spoiler (click to show/hide)
Title: Re: Burried Houses (AI Programming Project)
Post by: Supermikhail on December 12, 2010, 02:43:37 pm
Whoah. Reading the debug text is like learning about quantum physics for the first time!

So I wonder if there is eventually going to be long-term memory, but more importantly if there is priority value for memories based on their emotional importance.
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 12, 2010, 03:55:04 pm
There will definitely be long term memories created from short term memories,
 and they will be emotionally weighted,
 but I don't think their weight will ever be used to keep track of how long they are remembered.
I know I have done nothing but impractical things so far,
 but that would probably cross the line into runs really slow for minimal gain territory.

For now just distinguishing between "permanent" and "not permanent" coupled with
 a sort of "importance" value ought to be adequate.
Title: Re: Burried Houses (AI Programming Project)
Post by: Hugehead on December 15, 2010, 01:16:41 am
This sounds cool, even though half the stuff you're saying is going right over my head. :P
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 15, 2010, 01:37:23 am
Thanks!

Just curious, what sort of stuff?

Also:

I HAVE been working on this a little bit.
My last finals are later today, after which I intend to get back into some sort of routine over break.
I've added in some framework for prerequisite goals and they should be working some time Thursday.
The idea is to make a system where every addition and change will add complexity across multiple levels.
The final result will hopefully be very interesting not only for you, but also for me.

It is my wish to make a game that I can myself enjoy.

Some day I hope to quote the line above this one.
Title: Re: Burried Houses (AI Programming Project)
Post by: Minstrel on December 15, 2010, 04:40:47 pm
I am wondering about the way you described the WANDER action. You say the AI picks a room and then paths to it.

Wouldn't true wandering be more like the AI choosing a random direction to go for a random amount of rooms, then choosing another random course of action, avoiding backtracking, but ultimately relying on it if it came to a dead end? Or will that be another mode, like SAUNTER?
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 16, 2010, 10:06:14 am
It will actually just pick a random room to go to, and if it still hasn't found anything better to do
 it will pick another room and do it all over again.

You end up with them wandering all over the place.
The cool part is if you weren't specifically told they were wandering you might assume they were up to something important.
If I was following one around for instance to see what they did I might get mixed messages from the wandering.
I would like that sort of espionage/sabotage to be carried out later by some AI characters,
 so it would be neat for them to sometimes end up with the wrong conclusions
 because their target just happened to be wandering around aimlessly at the time.

"Ooh, they go into that storage room a lot, maybe I should sneak into there when they sleep."
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 16, 2010, 06:40:24 pm
Progress!

I've added prerequisite goal relationships,
 which meant putting in a ton of framework.

I've finally gotten to a point where there is a noticeable result.
When making a decision about which action they will perform next,
 the AI will ignore any action/goal trees with prerequisite actions.

The current working example goes like this:
They won't try opening a door that they know is locked unless it is unlocked first.

Now I will add in some sort of key using trial and error procedures.
Title: Re: Burried Houses (AI Programming Project)
Post by: Singularity-SRX on December 16, 2010, 08:45:19 pm
For the memory thing, maybe create an algorithm, which gives certain memories different values, the higher the value, the easier it is to remember, and an enforcement value as well, so that if they don't go into the area for a while, they'll still remember it because they went there a lot before.

I really like this project, good luck!
Title: Re: Burried Houses (AI Programming Project)
Post by: MrWiggles on December 16, 2010, 08:57:16 pm
This is a neat project.

A spy vs. spy mode would be interesting in this thing, or for something more complicated, Something like Clue.
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 16, 2010, 09:43:46 pm
I have so many crazy things planned for this game.

If it gets to a playable state, this thing will be very entertaining indeed.
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 20, 2010, 03:08:18 pm
So I've added a ton of framework for item collection and key/lock relationships.

Here is a test scenario where the player is presented with some things that might be keys,
 and the AI decides what to pick up:

Spoiler: Potato Dilemma (click to show/hide)

The AI will pick up the rusted key, and the key-shaped potato, as they both resemble keys.
The AI will ignore the potato though.
Later (after more programming) the AI will probably decide to leave the key-shaped potato due to uselessness.
And later still they might take it after all, as it might provide them with nourishment.
Which would mean all three items would be collected.

Spoiler: Unforeseen Observation (click to show/hide)

/silly shenanigans
Title: Re: Burried Houses (AI Programming Project)
Post by: MrWiggles on December 20, 2010, 08:39:21 pm
Neat.
Title: Re: Burried Houses (AI Programming Project)
Post by: Singularity-SRX on December 20, 2010, 11:03:14 pm
Is this going to be graphical? Or just text based?
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 20, 2010, 11:37:00 pm
This is going to be primarily text.

I think there will be some ambient sound / illustrations eventually,
 but for the greater part of its life this will be text only.

I'd love to do some simple 2D representations with sprites if it ever gets into a finished state.
Like a 2D stylized view of the current room complete with furniture and characters.
Spoiler: Like 2D Clue Box Art (click to show/hide)
Title: Re: Burried Houses (AI Programming Project)
Post by: darius on December 21, 2010, 06:34:11 pm
Woo very little project you have here Outcast Orange :)
Title: Re: Burried Houses (AI Programming Project)
Post by: MrWiggles on December 21, 2010, 08:08:35 pm
Well, sprites maybe cool, but ASCII is pretty easy to set up though.
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 21, 2010, 09:46:49 pm
For now we're sticking with ASCII.

In other news, I handed off the .exe to another forum member,
 and it had miserable problems working.

I am now in a rigorous debugging marathon.
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 24, 2010, 01:45:09 pm
Alfie and I worked out that the previous issues occurred on XP computers,
 and were caused by uninitialized variables.
I've since added forced declarations for all of them.

I've added a bunch of supporting code,
and the AI can now identify previously known items as possible objectives for goals.

Here's a screenshot of the first successful test:
Spoiler (click to show/hide)

So with the addition of a couple more functions, they should be trying to unlock doors with keys.
Also this framework supports future expansion such as switches or other mechanisms.
Title: Re: Burried Houses (AI Programming Project)
Post by: MrWiggles on December 24, 2010, 02:12:03 pm
Neat.

Now, go forth and recreate the Winchester Mansion.
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 24, 2010, 03:07:08 pm
Once I add RAWS you can do it yourself.

In case you didn't know already, my last iteration of this project already had that feature.
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 27, 2010, 03:04:23 pm
I've finally finished the plethora of support functions required to handle all of the special cases
 involved in finding keys and unlocking doors.

Here is what a week of toiling has produced:
Spoiler (click to show/hide)

So now that locks and keys work, I'm not entirely sure what to do.

I think i'll add in buttons and levers next.
Remote devices will utilize short term memory
 and I'll probably need to add in a system for the creation of hypothesis.

Which means I'll probably have to rework some of the key/lock structure to make use of them.
Title: Re: Burried Houses (AI Programming Project)
Post by: MrWiggles on December 27, 2010, 09:58:52 pm
Yea, having linked events happen in different rooms sounds neat. Something that can advantage of the memory system, I think, would be secret passages.
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 27, 2010, 10:17:38 pm
In what way?

I am definitely going to have secret passages,
 but I'm not sure what they have to do with the memory system.

I'm really not sure how to proceed, so I might as well start on levers.
Title: Re: Burried Houses (AI Programming Project)
Post by: hawkeye_de on December 28, 2010, 01:53:23 pm
Sounds nice.

What kind of AI techniques do you use?

I'm playing around with creating a roguelike and would have the need to solve similar challenges...
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 28, 2010, 02:12:33 pm
If you want to make a standard rogue like,
 just let them pick up any key they find, and enter any door they have a key to enter.
I mean without all of the fancy background stuff that will only really matter in strange circumstances.

I've decided to add in assumptions next.
I'll work them into the door unlocking process first.
They will be basic relationships between two things, with a degree of certainty involved.

The certainty will rise or fall whenever the assumption is tested in a situation.
Title: Re: Burried Houses (AI Programming Project)
Post by: Armok on December 28, 2010, 04:00:38 pm
This is really cool. Make sure to use proper Bayesian updating for that, it's exactly what it's for.
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on December 31, 2010, 03:09:20 pm
This is really cool. Make sure to use proper Bayesian updating for that, it's exactly what it's for.

I'll look into it.

---

In other news I've temporarily halted my procrastination.
I've added in a full assumptions class and keys/locks use assumptions now
 rather than the built in vectors I had added before.

Now I think I'll start the painfully daunting process of adding mounted switches.
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on January 03, 2011, 08:14:35 pm
So there is this really weird but that I can't figure out after hours of playing around with it.

It might be a logic problem, but it is not the usual sort.

I've narrowed it down to being caused by the calling of a function that (get this) doesn't have any code in it.
Just calling the function is causing this other virtually-unrelated pointer to change what it points to somehow.

Alfie and I have toiled with it for a while, and there is no progress in sight.
Title: Re: Burried Houses (AI Programming Project)
Post by: Virex on January 04, 2011, 07:11:12 pm
Have you tried adding a piece of code to the function that does absolutely nothing yet? It may be that the compiler is optimizing your code by lumping stuff together that just happens to form a bug in your code. (Oh and make sure the code seems to be doing something or the compiler will toss it right out again)
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on January 04, 2011, 08:16:22 pm
Sure, I'll have it print something to the screen.

I'm working around the issue for now,
 I've just cut from where it was causing the issue,
 since it isn't a necessary part of anything.
Title: Re: Burried Houses (AI Programming Project)
Post by: qwertyuiopas on January 04, 2011, 10:13:09 pm
If there are unnoticed conflicting definitions for the function, it might be interfering with the stack. Compilers tend to assume a function returns an int unless explicitly told otherwise, through a function prototype. I think.
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on January 05, 2011, 02:19:53 am
Even with something in the function I'm getting the issue.

I'll look into qwerty's suggestion.

The other thing I suspect is some sort of reserved word usage.
Title: Re: Burried Houses (AI Programming Project)
Post by: lordnincompoop on January 05, 2011, 05:29:24 am
How generic is this? How easily can it be adapted to new projects? Are you releasing it as open source?

Besides that, congrats for managing this. This is very neat.
Title: Re: Burried Houses (AI Programming Project)
Post by: salmonjockey on January 05, 2011, 07:03:02 am
This is interesting. I love seeing various approaches to AI.
Title: Re: Burried Houses (AI Programming Project)
Post by: Spreggo on January 05, 2011, 11:09:41 am
Yes, I too am interested.
Marking to follow :)
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on January 05, 2011, 02:35:50 pm
Woah.

So many awesome words so fast.

I will dedicate today to this project as a show of courtesy.

How generic is this? How easily can it be adapted to new projects? Are you releasing it as open source?

Besides that, congrats for managing this. This is very neat.

Why thank you!
And we seem to be on the same wavelength.
I'm fine with releasing any code I create, because any modifications could only make it better.
The idea is to make this system that can run these scenarios where major details can change,
 but still lead to a coherent and interesting game.

There will be the functionality to craft your entire experience, or have random chaos.
My favorite planned feature will be the ability
 to have the game craft the world around parameters you choose.
So for instance you can design a mansion, room for room,
 but the game can fill in all of the loot and secret passages and things,
 and plug that house into the story alongside the rest of the houses.

The only difference between a haunted mansion scenario and a pirate-ship mutiny:

- The setting
- The props
- The character goals

When you think about stuff like that, this project suddenly broadens.

If that doesn't answer your first question,
 then I'm not sure what will.

Everyone else:

Thanks, I love having an audience. * ~*
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on January 14, 2011, 12:36:59 pm
Okay, so I've fixed a few more issues relating to the unlocking process,
 and I've started adding in switches.

I've added support for static items (permanent fixtures) and I've linked a lever up with a door.
The character is identifying the lever as a possible mechanism to open the door,
 but the process of testing the lever and door is still floating around in my head.

I think I'll have them try pulling a lever, and if there are no immediate results they will recheck nearby rooms for changes.

I'm not really sure how I should have them handle this.
Title: Re: Burried Houses (AI Programming Project)
Post by: lordnincompoop on January 14, 2011, 12:39:18 pm
Are you going to have them do anything else? Friend/foe recognition? Stuff like that?
Title: Re: Burried Houses (AI Programming Project)
Post by: rarborman on January 14, 2011, 12:49:47 pm
Okay, so I've fixed a few more issues relating to the unlocking process,
 and I've started adding in switches.

I've added support for static items (permanent fixtures) and I've linked a lever up with a door.
The character is identifying the lever as a possible mechanism to open the door,
 but the process of testing the lever and door is still floating around in my head.

I think I'll have them try pulling a lever, and if there are no immediate results they will recheck nearby rooms for changes.

I'm not really sure how I should have them handle this.

Just have them go about like normal, because do you check every room in your house for changes when your lightswitch doesnt work?

If you can find a way to have them link changes to the lever by nondirect means then your AI is more realistic.
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on January 14, 2011, 07:07:02 pm
That sounds like a good idea.

I've noticed a lot of the reason it takes so long to accomplish anything
 with this project is there are too many classes that are too similar.

I'm combining a of the classes, and then working on a new system that will create
hypothesis/assumptions about things, then go about testing them.
Title: Re: Burried Houses (AI Programming Project)
Post by: Armok on January 15, 2011, 01:39:01 pm
*credit?*
Title: Re: Burried Houses (AI Programming Project)
Post by: SolarShado on January 15, 2011, 02:02:21 pm
Is sound implemented in any way? Locks generally make a sound when they're (un/)locked...
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on January 16, 2011, 03:17:42 pm
Armok gets credit for the idea of combining all of the classes,
 and he's been giving me a lot of suggestions over the hypothesis process.

If anyone else wants credit for something they once said or suggested, please just complain here.

Anyways, the sound thing is a great idea!

I've been wondering which sounds would be audible between rooms,
 and what sort of responses an AI would have to hearing them.

I'll confess that I haven't really worked on this at all this weekend,
 the new Minecraft update has been distracting me pretty heavily.
 
Title: Re: Burried Houses (AI Programming Project)
Post by: Armok on January 16, 2011, 03:27:08 pm
Sounds should probably wait until AI reacts to seeing other AI do things.
Title: Re: Burried Houses (AI Programming Project)
Post by: SolarShado on January 16, 2011, 04:00:04 pm
Sounds should probably wait until AI reacts to seeing other AI do things.

Actually... you might could use a similar system for both...
Title: Re: Burried Houses (AI Programming Project)
Post by: Armok on January 16, 2011, 04:06:33 pm
Yes, that is the reason. No point in cluttering the project with sound until it's gotten to the point where it might fill a purpose.
Title: Re: Burried Houses (AI Programming Project)
Post by: Korbac on January 16, 2011, 04:07:46 pm
Fantastic work, Outcast Orange.  :D

Also, for the sound thing - an AI would be more likely to shelve their current goal and investigate a noise the louder it is. An AI would be more likely to investigate a noise if they have no goal / no other option. An AI would be extremely likely to investigate a noise if it was concurrent to an unknown lever / switch they just used.

NINJAEDITED: Fair point, Armok.

Again, great work Sir Tangerine. (Can I call you that? I think it sounds pretty awesome.)
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on January 16, 2011, 04:13:22 pm
Sir Clementine please.
Not only does it sound wonderfully absurd, but the fruit tastes better too.

Thanks for the suggestions.

I feel I've been over-thinking a lot of these things,
 and my common sense has abandoned me.
Title: Re: Burried Houses (AI Programming Project)
Post by: Korbac on January 16, 2011, 08:10:34 pm
Sir Clementine, common sense is easily forgotten whence you are in the coding zone!  ;D
Title: Re: Burried Houses (AI Programming Project)
Post by: SolarShado on January 16, 2011, 10:58:12 pm
Sir Clementine, common sense is easily forgotten whence you are in the coding zone!  ;D

Amen :)
Title: Re: Burried Houses (AI Programming Project)
Post by: Outcast Orange on February 02, 2011, 05:45:39 pm
Combining the classes has taken a lot longer than I thought it would,
 especially since I've been really busy lately.
I've finally done it, and all of the obvious bugs or related issues have been rooted out,
 though I'm sure there are a lot more waiting dormant.

I'm still not sure how exactly to proceed,
 but here are the overall goals:

- AI stores a list of possible actions that have simple effects and prerequisites

I already have a system like this, but the structure is very rigid and wonky,
 which makes further expansion feel akin to guiding a spaghetti noodle into a sink drain.
I think gutting it and taking a cleaner route shouldn't be very hard at this point.

- AI Knowledge and Testing Hypotheses

I'm really not sure how to approach this one.
They hold tons and tons of information, tied in with abstract clones of everything they encounter.
There are certain aspects of each item unknown, and the AI should yearn to fill in these unknowns.

Hypotheses will have to be created by finding some process that would yield distinct results depending on the circumstances.
This part should be a bit more complicated, but still manageable.


I'll go ahead and start restructuring actions, since it shouldn't take more than a few hours.

Title: Re: Burried Houses (AI Programming Project)
Post by: MrWiggles on April 12, 2012, 06:24:18 am
Update?