Kip Posted July 4, 2008 Share Posted July 4, 2008 This little program can guess your number (any number between 0 and 100) in less than 8 retries. You think that's not true? Try it! expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> $COUNT = 1 $DIVIDE = 2 MsgBox(0,"Mind Reader","Pick a number between 0 and 100.") $Form1 = GUICreate("Mind Reader", 451, 125) $Lower = GUICtrlCreateButton("My number is lower", 64, 72, 121, 25, 0) $Correct = GUICtrlCreateButton("That's it", 192, 72, 65, 25, 0) $Higher = GUICtrlCreateButton("My number is higher", 264, 72, 121, 25, 0) $Label1 = GUICtrlCreateLabel("Is this your number? :", 72, 32, 104, 17) $Number = GUICtrlCreateLabel("50", 192, 8, 120, 64) GUICtrlSetFont(-1, 40, 400, 0, "Arial") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Correct MsgBox(0,"Mind Reader","I knew I could guess it."&@CRLF&"I only tried it "&$COUNT&" times!"&@CRLF&@CRLF&"Ok, again. Pick a number between 0 and 100.") GUICtrlSetData($Number,50) $COUNT = 1 $DIVIDE = 2 Case $Higher $DIVIDE = $DIVIDE*2 $Add = 100/$DIVIDE $Read = GUICtrlRead($Number) GUICtrlSetData($Number,Round($Read+$Add)) $COUNT += 1 Case $Lower $DIVIDE = $DIVIDE*2 $Add = 100/$DIVIDE $Read = GUICtrlRead($Number) GUICtrlSetData($Number,Round($Read-$Add)) $COUNT += 1 EndSwitch WEnd MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
tlokz Posted July 4, 2008 Share Posted July 4, 2008 Lmao, this is pretty sweet i played with it for like 10 minutes straight trying to trick it but i couldnt I like it muttley Link to comment Share on other sites More sharing options...
Andreik Posted July 4, 2008 Share Posted July 4, 2008 Is not a Mind Reader, is pure math but I like your script, is very funny. muttley When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Uriziel01 Posted July 4, 2008 Share Posted July 4, 2008 Hehe muttley Tricky and nice scripted Link to comment Share on other sites More sharing options...
Kip Posted July 4, 2008 Author Share Posted July 4, 2008 This little program can guess your number (any number between 0 and 100) in less than 8 retries. You think that's not true? Try it! expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> $COUNT = 1 $DIVIDE = 2 MsgBox(0,"Mind Reader","Pick a number between 0 and 100.") $Form1 = GUICreate("Mind Reader", 451, 125) $Lower = GUICtrlCreateButton("My number is lower", 64, 72, 121, 25, 0) $Correct = GUICtrlCreateButton("That's it", 192, 72, 65, 25, 0) $Higher = GUICtrlCreateButton("My number is higher", 264, 72, 121, 25, 0) $Label1 = GUICtrlCreateLabel("Is this your number? :", 72, 32, 104, 17) $Number = GUICtrlCreateLabel("50", 192, 8, 120, 64) GUICtrlSetFont(-1, 40, 400, 0, "Arial") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Correct MsgBox(0,"Mind Reader","I knew I could guess it."&@CRLF&"I only tried it "&$COUNT&" times!"&@CRLF&@CRLF&"Ok, again. Pick a number between 0 and 100.") GUICtrlSetData($Number,50) $COUNT = 1 $DIVIDE = 2 Case $Higher $DIVIDE = $DIVIDE*2 $Add = 100/$DIVIDE $Read = GUICtrlRead($Number) GUICtrlSetData($Number,Floor($Read+$Add)) $COUNT += 1 Case $Lower $DIVIDE = $DIVIDE*2 $Add = 100/$DIVIDE $Read = GUICtrlRead($Number) GUICtrlSetData($Number,Floor($Read-$Add)) $COUNT += 1 EndSwitch WEnd MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Kip Posted July 4, 2008 Author Share Posted July 4, 2008 whoops double post. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Kip Posted July 4, 2008 Author Share Posted July 4, 2008 Is not a Mind Reader, is pure math but I like your script, is very funny. muttley MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Andreik Posted July 4, 2008 Share Posted July 4, 2008 If I choose my number between 0 and 1000, how retries? muttley When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Kip Posted July 4, 2008 Author Share Posted July 4, 2008 80? It's actually a piramide of possibilities. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Andreik Posted July 4, 2008 Share Posted July 4, 2008 80? It's actually a piramide of possibilities.Look I modify your script for numbers between 0 and 1000 and 10 tries is necessary. I like your script, It's funny. muttley expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> $COUNT = 1 $DIVIDE = 2 MsgBox(0,"Mind Reader","Pick a number between 0 and 1000.") $Form1 = GUICreate("Mind Reader", 451, 125) $Lower = GUICtrlCreateButton("My number is lower", 64, 72, 121, 25, 0) $Correct = GUICtrlCreateButton("That's it", 192, 72, 65, 25, 0) $Higher = GUICtrlCreateButton("My number is higher", 264, 72, 121, 25, 0) $Label1 = GUICtrlCreateLabel("Is this your number? :", 72, 32, 104, 17) $Number = GUICtrlCreateLabel("500", 192, 8, 120, 64) GUICtrlSetFont(-1, 40, 400, 0, "Arial") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Correct MsgBox(0,"Mind Reader","I knew I could guess it."&@CRLF&"I only tried it "&$COUNT&" times!"&@CRLF&@CRLF&"Ok, again. Pick a number between 0 and 1000.") GUICtrlSetData($Number,500) $COUNT = 1 $DIVIDE = 2 Case $Higher $DIVIDE = $DIVIDE*2 $Add = 1000/$DIVIDE $Read = GUICtrlRead($Number) GUICtrlSetData($Number,Round($Read+$Add)) $COUNT += 1 Case $Lower $DIVIDE = $DIVIDE*2 $Add = 1000/$DIVIDE $Read = GUICtrlRead($Number) GUICtrlSetData($Number,Round($Read-$Add)) $COUNT += 1 EndSwitch WEnd When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Kip Posted July 4, 2008 Author Share Posted July 4, 2008 How this program can guess your number (If your not so good at math) MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Andreik Posted July 4, 2008 Share Posted July 4, 2008 How this program can guess your number (If your not so good at math) muttley I`m not so good at math??? When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Kip Posted July 4, 2008 Author Share Posted July 4, 2008 I was talking in general MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Andreik Posted July 4, 2008 Share Posted July 4, 2008 I was talking in generalIf I see the script, I know algorithm from guess my number. Anyway a good script. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Kip Posted July 4, 2008 Author Share Posted July 4, 2008 To check how many retries are required with any number: $Poss = 1000 $Retries = 0 $i = 0 While 1 If 2^$i < $Poss And 2^($i+1) > $Poss Then $Retries = $i+1 ExitLoop EndIf $i += 1 WEnd MsgBox(0,"bla","Maximal retries: "&$Retries) MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
Andreik Posted July 4, 2008 Share Posted July 4, 2008 To check how many retries are required with any number: $Poss = 1000 $Retries = 0 $i = 0 While 1 If 2^$i < $Poss And 2^($i+1) > $Poss Then $Retries = $i+1 ExitLoop EndIf $i += 1 WEnd MsgBox(0,"bla","Maximal retries: "&$Retries)Yes. It`s correct. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Kip Posted July 4, 2008 Author Share Posted July 4, 2008 Cool! To guess a number between 0 and one million, it only has to take 20 retries. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
BrettF Posted July 4, 2008 Share Posted July 4, 2008 Once you get the number, and if you press the button, it still counts it as a try... muttley Otherwise i like! Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Kip Posted July 4, 2008 Author Share Posted July 4, 2008 Yes, because when you start over, it starts with a "guess" MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
monoceres Posted July 4, 2008 Share Posted July 4, 2008 (edited) Here's my simplified method on how to calculate amount of guesses: $poss=32 $answer=Ceiling(Log($poss)/Log(2)) MsgBox(0,"Max amount of guesses",$answer) Math is cool muttley Edited July 4, 2008 by monoceres Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now