ENGLISH

Realm of Racket: Learn to Program, One Game at a Time!

Book information

Publisher
No Starch Press
Year
2013
ISBN
1593274912, 9781593274917
Language
english
Format
PDF
Filesize
18 MB (18570436 bytes)
Pages
312\318
Time added
2020-11-29 05:13:01

Description

Racket is a descendant of Lisp, a programming language renowned for its elegance, power, and challenging learning curve. But while Racket retains the functional goodness of Lisp, it was designed with beginning programmers in mind.Realm of Racketis your introduction to the Racket language. InRealm of Racket, you'll learn to program by creating increasingly complex games. Your journey begins with the Guess My Number game and coverage of some basic Racket etiquette. Next you'll dig into syntax and semantics, lists, structures, and conditionals, and learn to work with recursion and the GUI as you build the Robot Snake game. After that it's on to lambda and mutant structs (and an Orc Battle), and fancy loops and the Dice of Doom. Finally, you'll explore laziness, AI, distributed games, and the Hungry Henry game. As you progress through the games, chapter checkpoints and challenges help reinforce what you've learned. Offbeat comics keep things fun along the way. As you travel through the Racket realm, you'll: Master the quirks of Racket's syntax and semantics Learn to write concise and elegant functional programs Create a graphical user interface using the 2htdp/image library Create a server to handle true multiplayer games Realm of Racketis a lighthearted guide to some serious programming. Read it to see why Racketeers have so much fun! Why Would I Want to Learn About Racket?......Page 19 Anything Else I Should Know?......Page 20 Introduction: Open Paren......Page 21 (.2Where Did Lisp Come From?......Page 22 (.3What Does Lisp Look Like?......Page 25 (.4Where Does Racket Come From?......Page 27 (.5What Is This Book About?......Page 29 Halt—Chapter Checkpoint......Page 30 1.1Readying Racket......Page 39 1.2Interacting with Racket......Page 41 Raise—Chapter Checkpoint......Page 43 2.1The Guess My Number Game......Page 47 2.2Defining Variables......Page 49 2.4Defining Functions in Racket......Page 50 A Function for Guessing......Page 51 Functions for Closing In......Page 52 The Main Function......Page 53 Resume—Chapter Checkpoint......Page 54 3.1Syntax and Semantics......Page 55 3.2The Building Blocks of Racket Syntax......Page 56 Booleans......Page 58 Numbers......Page 59 Strings......Page 60 CONS Cells......Page 61 Functions for CONS Cells......Page 62 The CONS Function......Page 63 The LIST Function......Page 64 Nested Lists......Page 65 Structure Basics......Page 67 Nesting Structures......Page 68 Structure Transparency......Page 69 Interrupt—Chapter Checkpoint......Page 70 4.1How to Ask......Page 71 One Thing at a Time with IF......Page 76 The Special Form that Does It All: COND......Page 78 A First Taste of Recursion......Page 79 Using the Stealth Conditionals AND and OR......Page 81 Using Functions that Return More than Just the Truth......Page 83 4.4Equality Predicates, Once More......Page 84 Writing a Test......Page 88 Testing in the Real World......Page 89 Call-with-current-continuation—Chapter Checkpoint......Page 90 Variable Definitions......Page 91 4½.2Local Definitions......Page 93 Abort—Chapter Checkpoint......Page 95 5.1Graphical User Interface......Page 99 5.2Landing a UFO......Page 100 5.3Using big-bang: Syntax and Semantics......Page 103 The Data......Page 105 The Main Function......Page 106 Key-Events......Page 107 Time to Stop......Page 108 Chapter Challenges......Page 109 6.1Robot Snake......Page 115 6.2A Data Representation for the Snake Game......Page 116 6.3The Main Function......Page 117 6.4Clock Ticks......Page 118 Eating and Growing......Page 119 Slithering......Page 120 Rotting Goo......Page 122 6.5Key-Events......Page 123 6.6Rendering......Page 125 6.7End Game......Page 127 6.8Auxiliary Functions......Page 128 Chapter Challenges......Page 129 7.1Functions as Values......Page 131 7.2Lambda......Page 133 7.3Higher-Order Fun......Page 134 7.4Two More Higher-Order Functions......Page 138 7.5Derive This!......Page 141 7.6apply......Page 142 Break—Chapter Checkpoint......Page 143 8.1Chad’s First Battle......Page 147 8.3Setting Up the World, a First Step......Page 148 8.4Action: How Structs Really Work......Page 151 8.5More Actions, Setting Up the World for Good......Page 155 8.6Ready, Set, big-bang......Page 156 8.7Initializing the Orc World......Page 160 8.8Rendering the Orc World......Page 162 8.9The End of the World......Page 166 8.10Actions, A Final Look......Page 167 Chapter Challenges......Page 171 9.1FOR Loops......Page 173 9.2Multiple Values......Page 175 9.3Back to FOR/FOLD......Page 176 9.4More on Loops......Page 177 Waitpid—Chapter Checkpoint......Page 180 10.1The Game Tree......Page 185 10.3Designing Dice of Doom: Take One......Page 186 End of Game......Page 187 10.4How Game Trees Work......Page 188 10.5Game States and Game Trees for Dice of Doom......Page 191 10.6Roll the Dice......Page 194 10.7Rendering the Dice World......Page 196 10.8Input Handling......Page 199 10.9Creating a Game Tree......Page 201 The Game Tree......Page 202 Neighbors......Page 204 Attacks......Page 207 10.10The End Game......Page 209 Chapter Challenges......Page 210 11.1Doomsday......Page 213 11.2Lazy Evaluation......Page 214 11.3Memoized Computations......Page 216 Delay—Chapter Checkpoint......Page 218 12.1An Intelligent Life-form......Page 223 12.2Lazy Evaluation......Page 224 12.3Adding Artificial Intelligence......Page 226 Stop-when—Chapter Checkpoint......Page 228 Chapter Challenges......Page 229 13.1What Is a Distributed Game?......Page 233 Previously Fabricated Structures......Page 235 iworld Structures......Page 236 13.4Organizing Your Universe......Page 237 13.5Distributed Guess......Page 239 The Server......Page 241 The Client......Page 243 Running the Game......Page 244 Chapter Challenges......Page 245 14.1King Henry the Hungry......Page 251 14.3Two United States......Page 252 Message Data and Structures......Page 253 14.5State of the Union......Page 256 State of the House......Page 257 14.6Main, Take Client......Page 258 The Appetizer State......Page 259 The Entree State......Page 262 14.7Main, Take Server......Page 265 The Join State and Network Events......Page 267 The Join State and Tick Events......Page 269 The Play State and Network Events......Page 271 The Play State and Tick Events......Page 273 14.8See Henry Run......Page 277 Chapter Challenges......Page 278 ).1Run Racket Run......Page 285 ).2Racket Is a Programming Language......Page 286 ).3Racket Is a Metaprogramming Language......Page 290 ).4Racket Is a Programming-Language Programming Language......Page 294 So Long......Page 301 Index......Page 305

Similar books