游戏邦在:
杂志专栏:
gamerboom.com订阅到鲜果订阅到抓虾google reader订阅到有道订阅到QQ邮箱订阅到帮看

编程游戏可助新手掌握现实编程方法

发布时间:2011-09-14 23:15:57 Tags:,,

作者:Alexander Jhin

学习编程的过程可能是一个噩梦。热情满满的编程员费尽千辛万苦,克服了那么多令人讨厌的框架和百思不得其解的错误信息,终于,出成果了——屏幕上跳出”Hello, World!”这个字眼。然后,他疑惑了:”好吧,接下来怎么样?我到底要怎么办才能做出点像样的东西来啊?“

当游戏开发者看到有人在编程游戏上痛苦挣扎时,通常会发现“这整个东西就是拙劣游戏所走的路线:一堆徒劳无功的努力,不明所以的失败案例,强加给新玩家的高级功能”等等。如果我们能够单纯地运用一些简单的游戏设计原则,学习编程将会更有趣而更有效得多。

那么,理想的编程游戏应该是怎么样的呢?

Programming(from codinghorror.com)

Programming(from codinghorror.com)

编程游戏

以编程教学为主题的游戏概念并不算什么新创意。当下已有不少受欢迎的编程游戏,如《RoboRally》、《Robozzle》、《Robot Odyssey》和《Light-Bot》等。但这些游戏着重表现的是编程的抽象概念,而不是传授真实的编程方法。这种情况类似于FPS游戏可让人们捕捉到一些射击的快感,但却无从掌握真正的射击本领。

所以,我们怎样才能利用游戏教授真正意义上的编程方法?

编程游戏的关键特征

以下是一些关键的、游戏化的原则,可以让编程学习更加有趣。我已经根据这些原则制作 了一个可玩的网页游戏《CodeHero》。(游戏邦注:此游戏仍在测试,需要用到Flash Player和Actionscript 3.0.)

playable example(from gamasutra)

playable example(from gamasutra)

0)选择一种真正的语言。许多编程游戏使用的是游戏性语言、游戏性界面、游戏性环境。虽然这种设计很适合小孩子,但成年的玩家很快就会注意到这种语言的局限性,同时认为这门技术只适合游戏环境。显然,真实编程语言的缺失使得从编程游戏到现实的编程之间产生了难以逾越的障碍。

解决办法就是,使用专业的编程语言。保证语言的功能特征的完整,使玩家在掌握即学即用的语言的同时,还有充分的进步空间。技巧就是把语言简单地分成几个易吸收的小块。

1)容易入门。与所有游戏一样,编程游戏的上手门槛要低。一般来说,学习编程的第一步是安装并启动集成环境,但这并不是一个有趣的开端。为了消除这道障碍,代码与主游戏UI必须同步显示,玩家编写好代码后,可以直接在UI上运行代码并从UI上收到错误信息。

为了使用户简单快速地上手,还需要隐藏某些高级概念。比如,命名空间和主功能切入点,虽然这对于完整的程序运行是必要的,但对于初学者来说,这些内容太空洞了,而且需要事先弄懂非常多的高级概念。大多数传统的编程教学技术只会告诉学生把需要的代码敲进去,但基本上无视这些代码。好游戏不会让玩家去做一些他们摸不着头脑的事!

让编程容易呈现于游戏界面。仔细思考让游戏为玩家编写好切入点和错误处理程序,或是简单地隐藏这些概念。

2)明确的反馈结果。编程新手写的代码应该通过动画和声音让其清楚地看到效果。

大多数代码的运行是可视的。但是,“int a = 4 + 3;”这串代码的运行,用户是看不到效果的。好游戏的动作输出总是很明显——编程游戏也应该如此。理想情况是,上述代码语句能够在特殊的编译器中运行,而这个编译器必须能够重写“+ ”运算符,如,一个显示4+3的图表,然后结果7存在一个称为 “a”的变量中。当然,不可能每一种语言都这样,所以也许可以让用户编写一个显示输出的函数,如储存(“a”, add (4, 3))——可能是一个有效的解决办法。无论怎样,编程游戏应该有一个明确的、可检测的输出结果。

3)失败帮助。刚入门的代码写手可能会因为各种各样的原因而失败:语法错误、异常、无限循环和逻辑错误等。理想的情况是,游戏应该检测到最普遍的编写错误并提供修改指导。

4)清楚可达的目标。开始编程最困难的一部分是决定编写内容。编写内容取决于编程员的技术水平。不幸的是,大多数新代码写手并不知道自己能写什么,不能写什么(大家都知道有不少新手程序员妄想从零起点写出一款FPS)。编程游戏应该追踪用户已经掌握的技术,然后选择用户可以达到的目标。例如,如果编程游戏已经教会用户如何循环,那就可以在数组部分中涉及循环。事实上,在教授新知识的同时,迫使玩家使用之前学会的内容可以强化旧概念的记忆,即温故知新。

总之,游戏应该呈现用户已知的知识能解决的问题。

其他例子

还有其他一些程序运用了类似的技术。例如,Code School是一个商业教学网站,它通过代码界面互动地教授如 “Ruby on Rails”这样的课题。(游戏邦注:但因为要付费,所以作者没试过。)

结论

设计并制作一款好的编程学习游戏应该很贴近广大开发者的需求。毕竟,没有程序员,就没有这么多游戏。除了对游戏产业的实际效用,当运用于现实世界时,这种设计训练还展现出游戏设计的价值所在。虽然这类游戏存在于封闭的空间,但在现实的背景之下,其传达的知识是无价的。(本文为游戏邦/gamerboom.com编译,如需转载请联系:游戏邦

A Better Way to Learn How to Program

by Alexander Jhin

Teaching Programming: A Better Way

Learning how to program can be a nightmare. An aspiring coder has to jump through many unpleasant hoops and mysterious error messages just to get “Hello, World!” printed on the screen. Then, she’s left wondering, “OK, now what? How do I actually build something?”

As game developers seeing someone struggle through this, we should be screaming, “NOOOOO!” The whole thing reeks of bad game design: a lot of work with no reward, unclear failure cases, advanced features pushed on new players, etc. If we simply apply some simple game design principles, learning how to code can be much more fun and educational.

So, what would a programming game look like?

The Programming Game

A game that teaches programming concepts is not a new idea. An acclaimed short list of programming games includes: RoboRally, Robozzle, Robot Odyssey, and Light-Bot.

But these games focus on the abstract concepts of programming, rather than teaching real world programming. It’s similar to how a first person shooter captures the feeling of shooting without training someone how to actually shoot.

So, how can we use gaming to teach someone how to really code?

Key Features of a Real World Programming Game

Below are a list of key, game-influenced principles to make learning to code more fun. I’ve created a playable example of these principles that can be played in browser here: CodeHero. (The game is still in Beta, requires Flash Player and teaches Actionscript 3.0.)

0) Choose a Real Language. Many previous attempts at programming games use toy languages with toy interfaces in toy environments. While these may be suitable for young children, any mature gamer will quickly begin to notice the limitations of the language and feel they are learning a skill which only works in the toy domain.

This makes tranferring to the real world daunting.

The obvious solution is to use a programming language used by professionals. This guarantees the language will be full featured, giving the player room to grow while also teaching them an immediately real world usable language. The trick is to break down the language into easily digestable bites, which will be discussed next.

1) Easy to Start. Like all games, programming games must have a low barrier to entry. Traditionally, the first step to learning programming was to install and set up a

build environment, which is not a fun way to start. To remove this barrier, the user should be able to enter code directly into the main game UI, run it from there and receive error messages there.

Getting started quickly and easily also requires hiding advanced concepts like namespaces and main function entry points. While these are necessary for complete programs to run, they are boring and simply require too many advanced concepts. Most traditional code teaching techniques will simply tell students to type this required code, but basically ignore it. No good game would ever tell the player to do something they don’t understand!

Make coding easy through in game interfaces. Consider having your game write entry points and error handling for the player or simply hide it from them.

2) Give Obvious Feedback. The code that a new programmer writes should make the player feel powerful by triggering animations and sounds.

Most code runs invisibly. “int a = 4 + 3;” doesn’t do anything the user can see. Good games have actions whose outcomes are obvious — programming games should too.

Ideally, the example line above would run in a special compiler which overrides the + operator to output, say, a graphic of 4 adding to 3, becoming 7 and being stored in a variable called “a”. Of course, this is not possible in every language, so maybe having the user write a function which displays the outcome, such as store(“a”, add(4, 3)); may be an adequate solution. No matter what, programming assignments should have obvious, detectable outcomes.

3) Help on failure. A beginning coder can fail in multiple ways: syntax errors, exceptions, infinite loops and incorrect logic. Ideally, the game should detect the most common coder mistakes and offer guidance about how to fix them.

4) Clear, Attainable Goals. One of the hardest parts of starting programming is deciding what to program. Deciding what to program depends on the programmer’s skill.

Unfortunately, most beginning programmers aren’t advanced enough to know what they can’t yet program (how many beginning programmers do you know who want to write a First Person Shooter engine from scratch?) A programming game should track what skills the programmer has already mastered and choose goals that are known to be attainable. For example, if a programming game has taught the user loops, it’s fair to use loops in the discussion about arrays. In fact, forcing a player to use previous patterns helps reinfoce the older concepts while teaching a new one.

The game should present problems which are known to be solvable given the user’s knowledge.

Other Examples

There are some other programs that use similar techniques. For example, Code School is a commercial website that interactively teaches topics such as “Ruby on Rails” via a web based coding interface. (Note: I haven’t actually tried Code School as it costs money.)

Conclusion

Designing and creating good code teaching games should be a subject close to our hearts. After all, without programmers, there wouldn’t be many games. But beyond the substantial utility to our industry, this design exercise shows the value of game design when applied to the “real” world. While games may exist in enclosed universes, they all reveal something about the nature of people. And this knowledge can be invaluable when applied to the real world.(source:gamasutra


上一篇:

下一篇: