Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That makes 2 subscribers ;)


Make that 3.

I've always wondered why game rules have to be so rigid (use a state machine) and always thought it was the technology but what you described makes sense and makes use of older technology but in new applications.

I just took one AI course while in college but got hooked ever since.

Question: Can you expand on the motivators and deterrents concept? Specifically, how do you relate something like "getting food" with the world objects? Assigning points to specific world objects(apple, cow, chicken...) seems to get us back to a state-machine like game. Humans have experience (memory and patterns) to guide them, what would the characters have?


Yes, to answer your question, there are many ways to go about implementing it, but here is how I do it:

In reality, you have one knowledge base, which is simply a set of facts/rules about the world. For example...

a) berries are fruit b) red fruit is good (+1 score) c) green fruit is bad (-1 score) d) enemies are dangerous e) eating while in danger is bad (-10 score) f) eating while full is bad (-2 points)

In a finite state machine, you would have to have several combinations of state (are berries present? are enemies present? are you full? etc). Say (for argument's sake) you have 5 possible states (binary). In a FSM, this would have 32 possible permutations of the states, which all must have corresponding actions associated with them. In a motivation based system, it simply evaluates each state individually, and adds up the points. It chooses to pursue the state that gives the most points. So, here, that would be eating red fruit while enemies are not present.

The way prolog-like systems work, the computer does not have to have ANY idea what food or hunger or anything like that is -- it can be completely oblivious to abstract concepts. All it is doing, in essence, is (searching for and) matching strings. Those strings are the identifiers used for classes (or instances) of game world objects, NPCs, etc. So if you gave an NPC a motivator (kill(enemy) = +10 points, Bob = enemy, get_caught_doing(kill) = -100 points), it will find the best way to kill Bob while avoiding negative consequences. This is (obviously) metacode, and the actual implementation would require better organization and more explicit syntax.

Make sense?


Yup, makes sense.

I have written exactly 15 lines of prolog but I'm somewhat aware of how they work. This is great stuff, but as you said the devil is in the details. Please consider writing up your experiences and sharing it on HN.


Definitely, will do :) It is also encouraging to see that people are interested in this.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: