1
(big-bang ws
          (on-tick cth)
          (on-key keh)
          (on-mouse meh)
          ...)

I know that the first parameter is a number and it's the described as the world state. But that just seems like vague terminology to me. Basically I don't understand what this number is really/actually supposed to represent. Two examples I've seen so far are: "countdown mechanism" and "number of pixels to be moved". What exactly is it doing?

I am working Chapter 2 on HtDP (2nd Edition)

soegaard
  • 30,661
  • 4
  • 57
  • 106
dotnetN00b
  • 5,021
  • 13
  • 62
  • 95
  • If it helps, you can think of "state" as storage to carry information from one time slice to the next. It's like a big truck you can just dump stuff in :-) How you interpret that stuff is up to your program. – Marty Neal Jan 21 '13 at 15:04

2 Answers2

2

The world represent the current state of the program. In some program the entire state can be represented as a single number (e.g. a ufo that only moves up and down). It is rare that a single number is enough though. To represent the position of a space ship that can move in all directions, you need both an x- and a y-coordinate. Since the world must be a single value the two numbers are put into a structure. The following chapters in HtDP will introduce you to structures and how to use them as worlds.

soegaard
  • 30,661
  • 4
  • 57
  • 106
  • 1
    Another way to phrase it is: the world is a representation of the internal "model" of the system. It's all about representing the essential information of the system in play. If we're modeling a clock, the world may consist of the current clock time. Or it may consist of the position of the clock hands! It really depends on what you're trying to model, what parts of reality are important (or irrelevant!) for the problem that we're studying. – dyoo Jan 21 '13 at 01:30
0

I did not realize that the first parameter of type any/c. Which, for the uninitiated, means that the first parameter can be any type (ex: integer, string, boolean, structure, enumeration, etc). So in the examples I was working on, the big-bang function was using an integer as the simplest form of state. In using an integer as the state, the function is able to do things like manipulate the countdown clock and move the rocket by a certain number of pixels.

dotnetN00b
  • 5,021
  • 13
  • 62
  • 95