Monday, May 26, 2008

Little Lies

I read an exceptionally good essay by Paul Graham entitled, "Lies We Tell Kids". It talks about white lies, the kind you tell to protect people rather than manipulate them. It's worth reading in full, but let me summarize what I took out of it:

People usually lie because the listener cannot emotionally or mentally handle the truth. While this is often the best thing for the listener at present, it has a cost: They do not understand reality as it truly is. They are unprepared to handle that truth when they encounter it in another fashion.

As I wrote earlier, I see strong parallels between designing AI and being a parent. There's a lot to be said for the "lies" that we as AI designers tell our AI: "No really, you can have perfect information about the entire world. And if you have to spend a long time thinking, that's okay. The entire world will stop and wait for you to decide." Whenever we let our AI cheat at the game, look up information it shouldn't know, or otherwise do things a player can't do, we are in some sense lying to our AI about what reality is like. And the price we pay is this:

We live in fear that our AI will encounter a game situation where the player will know the AI has cheated.

I spend a lot of time talking about good AI and bad AI, and why it's often worth the time to write good AI. But I'm not going to say we shouldn't lie to our bots! I recognize that "bad AI" has a place in AI design. Sometimes a corner must be cut because a problem is simply too difficult. And often these are not isolated exceptions. It's possible to write enjoyable AI that cuts an awful lot of corners as long as you know the right corners to cut.

For example, a bot can get away with almost anything if the player can't see the bot. The amount of cheating a bot can get away with dramatically decreases once the player actually watches the bot, in the same way that a magician's tricks only work when you watch the hand he wands you to watch.

The real key to writing good AI is learning which corners to cut and which problems must be explicitly solved in a human-like manner. In other words, it's about determining when to write bad AI and when to write good AI. In BrainWorks, I certainly erred on the side of too much good AI, but I think this is still a long term benefit. Once someone has solved the problem (and released the source code), everyone can reap the benefits and we can all move onto harder problems. But actually writing artificial intelligence that doesn't cheat about anything is an excruciatingly difficult problem. An AI that does everything like a human does would appear to observers to be a human. It could pass a Turing Test, the holy grail of Artificial Intelligence research.

When I say "Holy Grail", I mean it in more ways than one. Even the most optimistic estimates on when we'll be able to create a truly artificial mind say it won't be done for decades. My personal estimates are that it will be done in 300 to 1000 years. And some people claim that it is literally impossible to create an artificial mind, that it so complex that it can only be evolved or created by God (depending on your philosophical preference).

If you want an example of what roughly 700 years of research will give you, the atomic bomb was created only 500 years after the birth of Leonardo da Vinci. Think about how much science advanced in those 500 years. While that time was centuries long, it was punctuated by thousands of little scientific discoveries about how the universe worked. Einstein couldn't have had his flash of insight about how Newton was slightly wrong if Newton hadn't done work to come up with equations that were 99.9999% right.

I believe the next 700 years of AI Research (give or take a little) will be similarly punctuated. Humanity's journey to the creation of an artificial mind will be punctuated by little advancements. No one person could do all the work necessary to design everything needed for a true artificial mind, but every time an AI designer chooses to do a bit of "good AI" rather than cutting corners with "bad AI", we get one step closer to the final goal, even though the destination is light years away. I will not fault anyone for writing AI that cheats; I've done the same. But writing AI that cheats even a little less than usual is worthy of high praise.

Sunday, May 18, 2008

Making Things Worse

One of the major challenges of game AI is creating AI that's plays at an appropriate skill level for a range a players. Most games need AI in easy, medium, and hard settings so that as players become better, they can face more appropriate challenges. There are three typical methods for solving this problem.
  • More enemies appear on higher skill levels
  • Higher skill enemies have more health and deal more damage
  • Higher skill enemies act more intelligently
The first two are obviously far easier to implement than the last, but more intelligent enemies gives more satisfying results. While additional enemies works fine for a single player first person shooter like Half Life, it's not an option for Quake 3, since the player selects the number of enemies when they pick the level. The second option, adding more health and damage, was exactly what iD software used for the two lowest skill bots in the original AI. While skills 3-5 gained better accuracy, skills 1 and 2 simply dealt less damage and died faster than a skill 3 bot.

Of course it's the last option, coding additional levels of intelligence, that's "real AI". The other methods have their place, generally when deadlines must be met. But the reason good human players beat bad human players at a game isn't that the bad players accidentally had the "deal less damage" option checked. They just get outsmarted. High skill AI needs to outsmart people more often than low skill AI does, and you don't encounter that kind of AI very often in computer gaming.

When designing BrainWorks, I was determined that all skill gradations would be created by additional intelligence, at least where applicable. So, yes, bots will have more accurate aiming as their skill increases. But they also gain abilities. Here are some of the abilities BrainWorks bots gain and their minimum skill levels. (Skill 1 is the lowest, 5 is the highest.)
  • Strafe jumping: Skill 4
  • Blast shots: Skill 3
  • Item Respawn Timing: Skill 3 (1 item), 4 (2 items), and 5 (3 items)
  • Simultaneous movement and attacking: Skill 2
That's right, a skill 1 bot stops moving whenever it starts shooting. There are also other abilities that gradually increase in effect as skill increases:
  • Aiming speed
  • Aiming error correction
  • Audio detection of enemies
  • Memory of enemies no longer in view
And more that I'm sure I've missed. To make realistic low skill bots, it's best to start with realistic high skill bots and then take away intelligence until the result seems appropriate for the intended human's skill level. AI designed the other way, by taking bad AI and giving it more health and damage, never quite feels realistic.

Monday, May 12, 2008

The Emperor's New God

Last week, I ended by explaining how I came to realize I didn't have a relationship with God. In short, I empirically tested whether or not God was speaking his words into my mind and I concluded that at least some of the time, things that "felt" like they were from God were not. Specific things I thought God had promised me didn't happen, so that must not have been from God. Moreover, even simple thoughts that were no more specific than a horoscope were also no more accurate. In short, I realized I had no evidence to conclude I had ever communicated with a higher power. And lacking a relationship with God, I realized I was not a Christian.

That is not the same thing as giving up my faith.

Indeed, for a few months I desperately wanted "back in". There is a categorical difference between not having a relationship with God and being unable to have that relationship. Even to this day, if it turns out God exists, then I really want a relationship with that God. Who wouldn't want to be friends with the creator of the universe?

So having lost the evidence supporting my religious faith, I started from first principles, to see if the tenets of Christianity logically made sense. In other words, I wanted to logically test whether Christianity was truth but modern Christians had pursued the faith in the wrong manner, or if the religion just didn't make sense and I should give up on it altogether.

For those of you who aren't that familiar with Christianity, here is the core doctrine:
God loves people, but God is perfect and righteous, and therefore cannot allow sin to exist in his presence. Because all humans are innately sinful and God loves them in spite of this, God devised a plan that would allow him to have a close relationship with humans on an individual level. God sent Jesus, who is himself fully God and fully human, to live a perfect, sinless life and then become a penitence sacrifice for all of humanity. Jesus suffered the penalty of death instead of me so that I could live and have a relationship with God. And Jesus.
When I broke the dogma down to this description, there were three potential logical issues that I spotted. If any one of these things is false, the religion doesn't make logical sense. Here are the issues:
  • Why can't God let sin exist in his presence?
  • Why is the penalty for sin death?
  • Why is someone else dieing for my sin considered justice?
According to the Bible, Jesus spent a lot of time with prostitutes, drunkards, and other "sinners", expressly because these were the people who needed ministering the most. If Jesus is fully God, why wasn't Jesus bothered being around sin? That sounds like a strong logical contradiction.

I don't have a problem accepting that everyone is a "sinner", meaning that no one lives a perfectly righteous life, never mistreating or hurting other humans, or taking advantage of them. But why is it fair that living unrighteously should be met by death? Jesus himself talks about how some sins are worthy of greater punishments than others, and a spiritual death in hell is clearly the worst punishment someone could earn. By and large, most people never do anything so disruptive to society that death is a just punishment for them. It doesn't make logical sense that all kinds of unrighteousness should be worthy of the same death sentence.

Last, there's the question of why, if I'm guilty and deserving a death, it's fair for someone else to die on my behalf. This kind of thing goes against the basic philosophy of penal systems. If I'm sentenced to serve 10 years in prison, the courts don't consider it fair if someone else chooses to serve 10 years instead, or even 30 years. That option is simply not allowed because it doesn't even relate to the issue at hand. The Bible supports this opinion as well, according to Ezekiel 18:20:
The soul that sins shall die. The son shall not bear the iniquity of the father, neither shall the father bear the iniquity of the son.
Historically there have been some penal systems that allowed, by consent, some people to receive the punishment intended for others. The result has always been that rich people pay poor people to serve sentences for them, and in most cases the systems were changed to disallow this abuse. So if I really am worthy of death for my sins, I don't logically understand why it would be okay for Jesus to die instead of me. That simply doesn't make sense.

I sent this list of questions four Christians whose opinions I respected. All of them were pastors at the time or had been in the past, and two of them had served time as missionaries in the third world as well. Of them, one actually tried to answer the questions. Two said they would think about it and get back to me, which never happened. The last didn't even respond. And all the answers I received boiled down to, "God knows better than you. It makes sense to God and that's what matters."

I'm sorry, but that's not a strong enough argument for me to base my life around a religion. The overall silence spoke louder than words and confirmed what I had suspected all along: the Christian religion is fundamentally flawed. A God might exist, and I certainly hope he does. But he is not the Christian God. A sentient being that could create the beautiful physics behind our universe can create a religion that doesn't have glaring logical holes in the core of its doctrine.

Now all that said, I'm still a big supporter of many Christian ideals as they relate to society. "Love your neighbor as yourself" is a good general rule for life, and creates a society that's better for everyone as a whole. Just because I've given up religion doesn't mean I've given up ethics.

At any rate, thanks for taking the time to hear my story. Next week I promise I'll be back with more AI themed discussion.

Monday, May 5, 2008

The Man Behind the Curtain

Last week I wrote about the Christian philosophy I had. The basic conclusion was that if someone has sufficiently strong reason to believe in a religion, nothing external from that religion can ever make them lose faith. Rather you will see them modify the fringes of their beliefs to fit whatever counter-evidence they encounter, without changing the core beliefs.

For example, a Christian may start claiming that God created the world in seven days. When presented with scientific data demonstrating the world is older than 6000 years, they might claim Satan just planted the dinosaur bones so deceive people into believing God doesn't exist. (Yes, I've heard someone present argument in all seriousness.) The more rational believers can apply Occam's Razor to this situation and conclude that maybe "day" isn't the right translation, and perhaps end at the conclusion that God used evolution to create humans. But no amount of external (scientific) evidence will convince a believer that their religion is wrong. I was familiar with all of those arguments and they didn't make me lose my faith in God. Only an internal inconsistency could fracture my faith.

I moved to California in the middle of 2000, a year and a half before I started work on BrainWorks. I started the project by programming on evenings and weekends, but after almost a year I realized that writing truly good AI would take more time than that. My wife and I talked about the options, and after a lot of time spent in prayer, we came to a rather dangerous conclusion. I decided to quit my day job and work on BrainWorks full time as a way of building my portfolio, live off savings, and then look for a job in the game industry. Even though this was a crazy idea, we felt assured by God in our prayers of four things:
  • God would provide for us
  • God would vindicate this audacious decision to others upon completion
  • I would truly meet God through the work I did
  • I would finish the project before we left the state of California
In the years following, we would return in prayer during difficult times, and also ask for the prayers from others, and we were continually encouraged when we heard these promises repeated, both in our minds and from the words of others.

Concurrently, there were other issues we had lifted up in prayer. Most notably I had back problems for over a decade. Having tried multiple chiropractors, doctors, physical therapists, exercises, and received countless prayer on the issue, I was at a loss. Nothing seemed to work. But I believed in a God that could do real miracles, and healing my back was certainly not the hardest of them. After years of prayer, I kept hearing that God really was going to heal my back, at the proper time, and that receiving healing was about more than just freedom from physical pain. It was about encountering God in a deeper way, which is why the timing mattered and why God didn't just heal me immediately. We felt like God spoke to us that he would give me full healing for my back before we left California. In some sense, our sojourn in California was an opportunity to witness the miraculous works of God, in my work and in my life, and to encounter God.

So what happened? In case there is any doubt about the story's outcome, let me set the record straight. While we did have enough to live while I was unemployed, I did not "encounter God" through the work. I received a job offer in Boston in January of 2007, which my wife and I prayed about and decided I should take. I did not complete BrainWorks before I left California, nor were my back problems healed. In our cross country drive from Los Angeles to Boston, the two of us were faced with a rather uncomfortable situation. Several things we thought we heard from God, including the prayers of others, all agreed with each other, but they were all wrong. That's really not supposed to happen. At the end of that drive, we came to one undeniable conclusion:

We are not very good at hearing from God.

Maybe the reason is that there is no God, or maybe just no Christian God. Or maybe the Christian God exists, and the problem is with us. When we arrived in Boston, we set aside one month for God, each day praying, "God, if you're real, undeniably reveal yourself to us." Since we are very bad at hearing from God, if we are to have a relationship with God, the effort must be his. After one last month, we still experienced nothing. And at that point I came across one truth, written in the Bible, that forever shattered my faith.

If you're not familiar with the Old Testament, one of the most common themes is the warning against idolatry, the worship of false gods through graven images rather than the one, true God, the "I am". The Hebrew scriptures are littered with hundreds of these warnings, but the best story is from 1 Kings 18, where Elijah confronts the prophets if Baal. Here is an excerpt:
Elijah went before the people and said, "How long will you waver between two opinions? If the Lord is God, follow him; but if Baal is God, follow him." But the people said nothing. Then Elijah said to them, "I am the only one of the Lord's prophets left, but Baal has four hundred and fifty prophets. Get two bulls for us. Let them choose one for themselves, and let them cut it into pieces and put it on the wood but not set fire to it. I will prepare the other bull and put it on the wood but not set fire to it. Then you call on the name of your god, and I will call on the name of the Lord. The god who answers by fire—he is God."
Naturally the prophets of the false god Baal have no success, but Elijah has success:
At the time of sacrifice, the prophet Elijah stepped forward and prayed: "O Lord, God of Abraham, Isaac and Israel, let it be known today that you are God in Israel and that I am your servant and have done all these things at your command. Answer me, O Lord, answer me, so these people will know that you, O Lord, are God, and that you are turning their hearts back again." Then the fire of the Lord fell and burned up the sacrifice, the wood, the stones and the soil, and also licked up the water in the trench.
The basic argument is always the same. What separates idols from God was the success rate. You should worship God because God is real and will provide for you. A true God produces results and a false God does not. After all, what purpose does God have if he can't make an impact on you? When I remembered this, I could not escape its conclusion in my life:

God is my idol.

I could not deny the promises that hadn't come to pass, and those promises that had were easily explained by things other than God. At the very least, the Bible I believed in condemned my God as an idol, since it also did not produce results. I had peeked behind the curtain, expecting to see the magnificence of God, and instead encountered a mirror. All this time, I was the man behind the curtain. The things I thought I heard from God in prayers were just my own desires and fears. I am not good at being God.

To continue worshiping this God would be worshiping an idol, something the religion condemns as an obviously pointless and worthless activity, but it was the only God I had ever known. From that point on, I knew I could no longer be a Christian. I realized Christianity did not have practical applications in my life. But that's different from saying Christianity is ideologically false. Next week I'll explain how I concluded the core ideology of Christianity was flawed, and how I went from an outcast of Christianity to living in the freedom of heathenism.