Читать книгу Beginning Programming All-in-One For Dummies - Wallace Wang - Страница 56

Programming a killer robot

Оглавление

Studying how to program by controlling a LEGO robot can be fun (see “Programming robots with LEGO Mindstorms,” earlier in this chapter), but to combine the thrill of controlling a robot with the joy of playing a video game, computer scientists have also created games that let you write a simple program for controlling a battling robot, as shown in Figure 3-4.


FIGURE 3-4: Using a battling robot to study programming can make programming more exciting.

Instead of writing a program just to control a robot, these games force you to write a program to move a robot onscreen, search for other robots nearby, and then attack those other robots with a cannon.

After you finish your program, you can see the results by watching your robot battle another robot in a gladiator-style battle. Write a “good” program, and your robot can defeat another robot. Write a “bad” program, and your robot gets blasted into chunks of (virtual) charred metal.

To program a “battling robot,” use a simplified version of a popular programming language, such as C, C++, or Java. That way, not only do you figure out the basics of a popular programming language, but you also can start writing “real” programs that actually do something interesting right from the start. Table 3-1 lists some popular “battling robot” programming games.

TABLE 3-1 Popular “Battling Robot” Programming Games

Program Language Used Where to Find It
C++ Robots C++ www.gamerz.net/c++robots
Crobots C https://crobots.deepthought.it
Robocode Java https://robocode.sourceforge.io
Beginning Programming All-in-One For Dummies

Подняться наверх