Script Library: 1238 scripts
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Archive version of: guess-the-number.r ... version: 3 ... caridorc 25-Sep-2014

Amendment note: little fix || Publicly available? Yes

REBOL [
    	File: %guess-the-number.r
    	Date: 25-9-2014
    	Title: "Guess the number"
    	Purpose: {
                       This game will ask you to enter a number
                       and will then say if it is more or less than a predefined random number
                       with best ability and worst luck
                       you will need (log in base 2 of MAX) tries to guess the number
                       (if you are interested in this google "Binary search")
                      }
       Author: "Caridorc"
       Known-bugs: {
                            The programme works flawlessly,
                            there are no bugs
                            }
        library: [
                       level: 'beginner
                       platform: 'all
                       type: [tutorial]
                       domain: [game]
                       tested-under: 'Windows
                       support: riki100024 AT gmail DOT com
                       license: CC 3.0 Attribution only
                       see-also: none
    ]


]

random/seed now/precise
MAX: 100

view layout [
    text "Number guessing game"
    slider 800x32 [
        guess: to-integer value * reduce MAX
    ]
    button "Start/Reset" [n: random reduce MAX]
    button "Check" [alert to-string guess
	                    if (guess = n) [alert "Right!"] 
                            if (guess < n) [alert "Too small"]
                            if (guess > n) [alert "Too big"]
                    ]
]