跳棋

Preface: Following the previous #AI series and #MarvinMinksy series. This post is co-written with Claude.
Three claims about Arthur Samuel get repeated more than any others: that he coined the term "machine learning" and gave it its classic definition, "the field of study that gives computers the ability to learn without being explicitly programmed"; that in 1962 his program beat a state checkers champion; and that this was the first time a machine had beaten a human expert at a game of skill.

These claims turn up again and again in textbooks and lecture slides. The first is only half right, the second is wrong, and the third needs a heavy discount. But underneath the inflated stories, what Samuel actually accomplished matters more than the legend: he was the first to get a machine to judge whether a move was good or bad from its own experience, without waiting for the game to end.
1956: Checkers on Television
On the morning of February 24, 1956, IBM broadcast a live checkers demonstration on television. One of the players was an IBM 701, the company's first large commercial stored-program computer, a machine that filled an entire room.
IBM's founder, Thomas Watson Sr., made a point of arranging for the company's shareholders to watch, and predicted that after the demonstration IBM's stock would rise fifteen points. Supposedly it did. A few months later, Watson died. Standing behind the machine was a soft-spoken engineer in his fifties. He wasn't a mathematician or a psychologist. His specialty was vacuum tubes.
1901: The Vacuum Tube Engineer
Arthur Samuel was born in 1901 in Emporia, Kansas. He studied at the College of Emporia while working on and off at General Electric in Schenectady, New York. He earned a master's degree from MIT in 1926, stayed on as an instructor for two years, and joined Bell Labs in 1928.
He spent nearly two decades at Bell Labs, working mainly on electron tubes, the vacuum tubes we met in the SNARC post. During the war, he helped develop a key component of radar: a switch that protected the receiver from being burned out in the instant the radar fired off its powerful pulse.
In 1946 he became a professor of electrical engineering at the University of Illinois and joined a project to build one of the early electronic computers. Money was tight, and Samuel came up with an idea: write a program that played checkers and have it challenge the world champion. If it won, there would be no better way to show everyone how powerful electronic computers could be. At the time, he thought it wouldn't be hard.
The computer wasn't finished in time, so the checkers program was never completed at Illinois. In 1949 Samuel moved to IBM's lab in Poughkeepsie, New York, to help the company move from electromechanical equipment to electronic computers. He brought the checkers idea with him. He later said that the problem of writing a program that seemed intelligent took up nearly all his spare time for as long as he was at IBM.
Why Checkers
In 1952, Samuel wrote his first checkers program on the IBM 701.
He chose checkers deliberately. Its rules are much simpler than chess, with only two kinds of pieces, ordinary pieces and kings, yet the number of possible positions is around five hundred billion billion, a 5 followed by twenty zeros. Simple rules meant the program wasn't too hard to write, and most of the machine's effort could go into "thinking." The huge number of positions meant there was no way to win by working through all of them. Bellman's curse of dimensionality applied here too. The program had to learn to judge whether the position in front of it was good, without being able to calculate all the way to the end of the game.

This was the same problem Hassabis ran into as a teenager writing his Othello program. Samuel's program also had two parts.
One part looked ahead. The program spread out every possible move, and every reply the opponent could make to each one, layer by layer like the branches of a tree. It looked a few moves ahead, then used minimax, assuming the opponent would always make the move that was best for them, to carry the scores back from the future to the present.
The other part was the evaluation function. After looking a few moves ahead, the game was still far from over, so the program had to give those future positions a score. Samuel's approach was to pick out a set of features, like how many pieces each side had left, how many kings, who controlled the center of the board, whose pieces were more exposed to capture, give each feature a weight, and add them up into a total score.
An evaluation function is a formula for scoring a position. It is made up of a number of features, each multiplied by a weight, and the sum is the position's score.
Up to this point, this was only a program that played checkers, not a program that learned. The weights were set by a person. If the person set them well, the program played well; if not, it kept playing badly. What Samuel wanted was for the program to adjust those weights itself.
Samuel had the program learn in two ways.
The first he called "rote learning." As it played, the program stored the positions it encountered along with the scores it had worked out for them. The next time it looked ahead and found a position it had seen before at the end of a branch, it didn't need to analyze it again; it could simply pull up the stored score. And that stored score had itself come from looking several moves ahead the last time. In effect, the program could see further than it appeared to. This kind of learning was very slow, but it kept improving, and it was especially useful in the opening and the endgame, where positions repeat most often.
The second kind of learning was more interesting, and it's what earned Samuel his place in the history of reinforcement learning. He called it "generalization learning." What it adjusted were the weights in the evaluation function.
The question was which way to adjust them. The most direct approach would be to wait until the game was over, then strengthen the judgments used in that game if it was won and weaken them if it was lost. That's the logic of machines like SNARC and the matchboxes: wait for the reward, then look back and hand out credit. But a game of checkers can run dozens of moves, and by the end there's no way to tell which of the earlier judgments went wrong.
Samuel's idea was: don't wait for the end of the game.
Before each move, the program gave the position in front of it a score. This was its "first impression," what the evaluation function could see at a glance. Then it looked a few moves ahead, spread out the branches, and carried the scores of those future positions back, arriving at a new score. This new score was its "considered judgment," because it took into account what might happen over the next few moves, and it was usually more accurate than the first impression.
If the two scores differed, that meant the evaluation function's first impression was off. So the program adjusted the weights to bring its next first impression closer to the considered judgment.
Here's an example. At first glance, the program thinks it has a slight edge in some position and gives it a score of +3. After looking a few moves ahead, it discovers that the opponent has a double jump coming that will take two of its pieces, and the score carried back is only −5. The gap is 8 points, which means the evaluation function is too optimistic about this kind of position. So the program checks which features produced the +3. Say "control of the center" was weighted too heavily and "how exposed my pieces are" too lightly. It turns the first down a little and the second up a little.
This way, the program learned with every move, without waiting for the game to be decided. Every lookahead was a small test, with the self that thought more deeply correcting the self that thought more shallowly.
This was Samuel's answer to the credit assignment problem. SNARC gave the credit to the last few steps before the reward, because all it could do was wait for the finish. Samuel's program didn't wait. At every step, it used the later judgment to correct the earlier one, and in this way the error was passed back, one step at a time.
The idea is strikingly close to Bellman's equation: the value of a position can be worked out from the positions that follow it. But there's a fundamental difference. Bellman needed to know all the rules of the world in advance and sit down to calculate every situation. Samuel didn't. He had the program estimate the value of each position, step by step, from the experience of actually playing. Thirty years later, Richard Sutton turned this idea into a formal algorithm called temporal difference learning. In their textbook, Sutton and Barto devote a whole section to Samuel's checkers program, treating it as the most important forerunner of the idea.
Two Selves
To let the program adjust its own weights, Samuel also designed a way for it to play against itself.
He had two versions of the program running at once, one called Alpha and one called Beta. Alpha kept adjusting its evaluation function during every game in the way just described, while Beta stayed fixed. The two played each other. If Alpha won, that meant its adjusted evaluation function was better, so Beta was replaced with Alpha's current version, and the games continued. If Alpha kept failing to win, that meant it had drifted in the wrong direction and needed a shake-up to start again from a different direction.
This was one of the first attempts to make a machine stronger by having it play itself. More than fifty years later, AlphaGo Zero used the same basic idea, on a scale vastly larger.
In 1959, Samuel published a paper titled "Some Studies in Machine Learning Using the Game of Checkers." In the abstract, he wrote that with only about eight to ten hours of machine playing time, the program could learn to play a better game of checkers than the person who wrote it. The paper helped popularize the term "machine learning."

But the definition most often quoted, "the field of study that gives computers the ability to learn without being explicitly programmed," can't be found in the paper. It's a later summary of Samuel's work that eventually got attributed to him.
1962: An Exaggerated Victory
By 1962, Samuel's program had been moved to the faster IBM 7094. In a public match, it played a Connecticut player named Robert Nealey, and won. IBM's promotional materials described Nealey as a former Connecticut checkers champion and one of the best players in the country. The news spread nationwide, and many people came away believing that checkers had been conquered by a machine.
It hadn't. At the time of the match, Nealey wasn't a state champion; he didn't win that title until four years later, in 1966. He had never played in top-level events like the U.S. championship, and his reputation came mostly from beating local players. And in that game, Nealey made an obvious blunder. In the rematch that followed, Nealey won one game and drew five. The program didn't win a single game.
In 1965 the program played a few games against the world checkers champion, Walter Hellman. Hellman won all four games played by mail, and the one game played across the board was a draw. Samuel himself acknowledged in 1967 that his program still couldn't beat the best human players.
But the impression that checkers had been solved had already taken hold. Researchers moved on to chess, and checkers was largely neglected for more than twenty years. It wasn't until 1994 that Chinook, a program from the University of Alberta in Canada, truly reached world-champion level.
The Ceiling
Why did Samuel's program stop where it did? He gave the answer himself in his 1967 review.
Generalization learning was much faster than rote learning and did surprisingly well in the middle game, but its progress soon leveled off. The reason was that all the program could adjust were the weights, while the features themselves, what counted as "control of the center," what counted as "exposed to capture," had all been chosen by a person. If the features a person chose left out something important, no amount of reweighting could make up for it. What the program could learn would never go beyond the angles a person had taught it to look from.
This was the same wall Hassabis's Othello program ran into. He had to write "bonus points for corners" in by hand, and the machine just calculated according to his intuition. It would take AlphaGo for a machine to start deciding for itself what to look at on the board.
Samuel retired from IBM in 1966 and went to Stanford as a lecturer, later becoming a research professor, and taught there until 1982. He kept improving his checkers program until later programs completely outclassed it. He also never stopped writing code. He contributed to Stanford's operating system and to Donald Knuth's TeX typesetting system, and at eighty-six he was still writing programs for multi-font printing, possibly the oldest working programmer in the world at the time. He died at Stanford Hospital in July 1990 from complications of Parkinson's disease, at the age of eighty-eight.
While Samuel was at IBM getting his program to play against itself, on the other side of the Atlantic, an Englishman who had broken German codes at Bletchley Park also wanted to teach a machine to play a game. He had no IBM 701; he didn't even have an electronic computer. What he used was some three hundred matchboxes. 🧪
Preface:接之前的 #AI 和 #MarvinMinsky 系列,本文和claude合作完成。
关于 Arthur Samuel,流传最广的说法有三条:他发明了"机器学习"这个词,并给它下了一个经典的定义,"让计算机在没有被明确编程的情况下学习的研究领域";他的程序 1962 年打败了一位跳棋州冠军;这是机器第一次在智力游戏上击败人类高手。这三条在大量教科书和演讲稿里反复出现。第一条只对了一半,第二条不对,第三条要打很大的折扣。但在这些被夸大的故事底下,Samuel 真正做成的事情,比传说更重要:他第一次让一台机器不等到终局,就从自己的经验里判断出一步棋的好坏。
1956:电视上的跳棋
1956 年 2 月 24 日早上,IBM 在电视上直播了一场跳棋演示。下棋的一方是一台 IBM 701 计算机,这是 IBM 第一台商用的大型存储程序计算机,占满了整个房间。
IBM 的创始人老 Thomas Watson 特意安排公司的股东观看这次直播,还预言演示过后,IBM 的股价会上涨 15 个点。据说股价真的涨了 15 个点。几个月后,Watson 去世了。站在这台机器背后的,是一个五十多岁、说话温和的工程师。他不是数学家,也不是心理学家,他的专业是真空管。
1901:真空管工程师
Arthur Samuel 1901 年出生于堪萨斯州的 Emporia,在当地的 Emporia 学院读书,期间断断续续地在纽约州 Schenectady 的通用电气公司打工。1926 年他在麻省理工学院拿到硕士学位,留校当了两年讲师,1928 年进入贝尔实验室。
他在贝尔实验室待了将近二十年,主要研究电子管,也就是 SNARC 那篇里讲过的真空管。二战期间,他参与研制雷达的一个关键部件:一种开关,能在雷达发射强脉冲的瞬间保护接收机不被烧毁。
1946 年,他去伊利诺伊大学当电机工程教授,参与了一个建造早期电子计算机的项目。资金紧张,Samuel 想出一个主意:写一个下跳棋的程序,让它去挑战世界冠军。如果能赢,这就是向所有人证明电子计算机有多强大的最好办法。那时他以为这件事不难。
计算机没能按时造出来,跳棋程序也就没有在伊利诺伊完成。1949 年,Samuel 跳槽去了 IBM 在纽约州波基普西的实验室,帮助公司从机电设备转向电子计算机。他把那个跳棋的念头也一起带了过去。他后来说,写一个看上去有智能的程序,这个问题从此占据了他在 IBM 期间几乎所有的空闲时间。
为什么是跳棋
1952 年,Samuel 在 IBM 701 上写出了第一个跳棋程序。
他选跳棋,是经过考虑的。跳棋的规则比国际象棋简单得多,棋子只有两种,普通棋子和"王",但它的局面数量大约有五百亿亿种,也就是 5 后面跟二十个零。规则简单,意味着程序写起来不太费劲,机器的大部分力气可以花在"思考"上;局面极多,意味着不可能靠把所有局面都算一遍来取胜。Bellman 的维度诅咒在这里同样成立。程序必须学会判断:在算不到终局的情况下,眼前这个局面到底好不好。
这和 Hassabis 少年时写黑白棋程序遇到的是同一个问题。Samuel 的程序也由两部分组成。
一部分是往前看。程序把每一种可能的走法,以及对手针对每一步的所有回应,像树枝一样一层层展开,往前看几步,然后用极小化极大的办法,假设对手总会走对自己最有利的那一步,把分数从未来一层层推回现在。
另一部分是评估函数。往前看几步之后,棋局还远没有结束,程序必须给那些未来的局面打一个分数。Samuel 的做法是挑出一批"特征",比如双方各剩几个棋子,有几个王,谁控制着棋盘中央,谁的棋子更容易被吃掉,然后给每个特征一个权重,把它们加起来,得到一个总分。
评估函数是一套给棋局打分的公式。它由若干个特征组成,每个特征乘上一个权重,加起来就是这个局面的分数。
到这里为止,这还只是一个下棋程序,不是一个会学习的程序。权重是人定的,人定得好,程序就下得好;人定得不好,它就一直下不好。Samuel 想做的,是让程序自己去调这些权重。
Samuel 让程序用两种方式学习。
第一种,他称为"死记硬背"。程序在下棋的时候,会把遇到过的局面,连同它对这个局面分析出来的分数,一起存下来。下一次往前看时,如果在树枝的尽头碰到一个以前见过的局面,就不用再分析一遍,直接调出存好的分数。而那个存好的分数,本身又是上一次往前看了好几步才得出的。这样一来,程序实际上能看得比它表面上看到的更远。这种学习非常慢,但一直在进步,在开局和残局阶段尤其有用,因为这两个阶段的局面最容易重复出现。
第二种学习更有意思,也正是它让 Samuel 在强化学习的历史上留下了名字。Samuel 称第二种方式为"泛化学习"。它调整的是评估函数里的权重。
问题在于,权重该往哪个方向调?最直接的办法,是等一盘棋下完,赢了就加强这盘棋里用过的判断,输了就削弱。这正是 SNARC 和火柴盒那一类机器的思路:等奖励来了,再回头分配功劳。但一盘跳棋可能有几十步,等到终局,早先的那些判断究竟哪一个出了错,根本无从分辨。
Samuel 的想法是:不必等到终局。
程序每走一步之前,都会对眼前的局面打一个分数,这是它对局面的"第一印象",只靠评估函数一眼看出来的。然后它往前看几步,展开树枝,把未来那些局面的分数推回来,得到一个新的分数。这个新分数是"想过之后的判断",因为它考虑了接下来几步可能发生的事,通常比第一印象更准确。
如果两个分数不一样,就说明评估函数的第一印象有偏差。程序就去调整权重,让下一次的第一印象更接近想过之后的判断。
举个例子。程序第一眼看某个局面,觉得自己略占上风,打了 +3 分。往前看了几步之后发现,对手接下来有一个连跳,能吃掉它两个子,推回来的分数只有 −5。差距是 8 分,说明评估函数对这一类局面太乐观了。于是程序检查,是哪些特征让它给出了 +3,比如"中央控制"那一项权重太高,而"棋子是否容易被吃"那一项权重太低,就把前者调低一点,后者调高一点。
这样,程序每走一步都在学习,不需要等胜负揭晓。每一次往前看,都是一次小小的考试,用"想得更深的自己"去纠正"想得更浅的自己"。
这就是 Samuel 对功劳分配问题的回答。SNARC 把功劳交给奖励到来之前的最后几步,因为它只能等终点。Samuel 的程序不等终点,它在每一步都拿后来的判断去修正早先的判断,误差就这样一步一步地往前传。
这个思路和 Bellman 的方程惊人地相似:一个局面的价值,可以从它后面的局面推出来。但两者有一个根本的不同。Bellman 需要事先知道世界的全部规则,坐下来把所有处境算一遍;Samuel 不需要,他让程序在实际下棋的经验里,一步一步地估出每个局面的价值。三十年后,Richard Sutton 把这个思路正式写成了一种算法,叫做时序差分学习。Sutton 和 Barto 在他们的教科书里,专门用一节来讲 Samuel 的跳棋程序,把它看作这一思想最重要的先驱。
两个自己
为了让程序自己调权重,Samuel 还设计了一种"自己和自己下棋"的方法。
他让程序同时有两个版本,一个叫 Alpha,一个叫 Beta。Alpha 在每一盘棋里都按上面的办法不断调整自己的评估函数,Beta 则保持不变。两个版本互相对弈。如果 Alpha 赢了,就说明它调整过的评估函数更好,Beta 就换成 Alpha 现在的样子,然后继续对弈。如果 Alpha 一直赢不了,就说明它调歪了,需要打乱一下,换一个方向重新开始。
这是让机器跟自己下棋来变强的最早尝试之一。五十多年后,AlphaGo Zero 用的是同样的基本想法,只是规模大了不知多少倍。
1959 年,Samuel 发表了论文《用跳棋游戏进行机器学习的一些研究》。他在摘要里说,只需要大约八到十个小时的机器下棋时间,程序就能学会下一手比写程序的人自己还好的跳棋。他在论文里推广了"机器学习"这个词。
但那个最常被引用的定义,"让计算机在没有被明确编程的情况下学习的研究领域",在这篇论文里找不到。它是后人对 Samuel 工作的概括,后来被安到了他头上。
1962:一场被夸大的胜利
1962 年,Samuel 的程序已经移植到更快的 IBM 7094 上,在一场公开比赛中对阵康涅狄格州的棋手 Robert Nealey,并且赢了。IBM 的宣传材料称 Nealey 是前康涅狄格州跳棋冠军,全美最顶尖的棋手之一。这条新闻传遍了全国,很多人由此以为,跳棋已经被机器攻克了。
实际情况并非如此。比赛时,Nealey 并不是州冠军,他直到四年后,也就是 1966 年才拿到这个头衔。他也从来没有参加过全美锦标赛这类顶级比赛,他的名气主要是在当地赢来的。而且那一局,Nealey 下出了一步明显的失误。在随后的重赛里,Nealey 一胜五和,程序一盘没赢。
1965 年,程序又和跳棋世界冠军 Walter Hellman 下了几盘。Hellman 赢下了四盘通信对局,唯一的一盘当面对局是和棋。Samuel 自己在 1967 年承认,程序仍然下不过最好的人类棋手。
但"跳棋已经被解决"的印象已经传开。研究者纷纷转向国际象棋,跳棋在之后二十多年里几乎被冷落。直到 1994 年,加拿大阿尔伯塔大学的程序 Chinook 才真正达到世界冠军的水平。
天花板
Samuel 的程序为什么停在了那里?他自己在 1967 年的回顾里给出了答案。
泛化学习比死记硬背快得多,在中盘阶段表现得出人意料地好,但进步很快就趋于平缓。原因是,程序能调的只是权重,而那些特征,什么叫"中央控制",什么叫"容易被吃",全都是人挑出来的。如果人挑的特征本身漏掉了某种重要的东西,程序再怎么调权重也补不回来。它能学会的,永远不会超出人教给它看的那些角度。
这正是 Hassabis 的黑白棋程序遇到的同一面墙。他得亲手把"占角加分"写进去,机器只是照着他的直觉去算。要等到 AlphaGo,机器才开始自己决定该看棋盘上的什么东西。
Samuel 1966 年从 IBM 退休,去斯坦福大学当讲师,后来成为研究教授,一直教到 1982 年。他一直在改进跳棋程序,直到它被后来的程序全面超越。他也一直在写代码,参与过斯坦福的操作系统和 Donald Knuth 的 TeX 排版系统,八十六岁时还在写多字体打印的程序,可能是当时世界上年纪最大的在职程序员。1990 年 7 月,他因帕金森病的并发症在斯坦福医院去世,享年八十八岁。
就在 Samuel 在 IBM 让程序自己和自己下棋的时候,大西洋另一边,一个曾在布莱切利园破译德军密码的英国人,也想让机器学会下棋。他没有 IBM 701,手边甚至没有一台电子计算机。他用的是三百多个火柴盒。🧪