Andreik Posted July 4, 2008 Share Posted July 4, 2008 Here's my simplified method on how to calculate amount of guesses (it works on all numbers > 4): $poss=32 $answer=Ceiling(Log($poss)/Log(2)) MsgBox(0,"Max amount of guesses",$answer) Math is cool muttleyYes, math is cool. I like it. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
newbiescripter Posted July 4, 2008 Share Posted July 4, 2008 It didn't guess mine.. my first guess was 98 and my second was 0. i couldn't figure it out at all. i'm sorry to say.. Try clicking lower and lower again and again.. it would never hit zero.. so you should change it to between 1 and 100, but it would still not work.. Regards Link to comment Share on other sites More sharing options...
Kip Posted July 4, 2008 Author Share Posted July 4, 2008 It's BETWEEN 0 and 100, -0 1 2 3 ... 98 99 100- --|____________|----- everything what's between 0 and 100, not including 0 and 100. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API. Link to comment Share on other sites More sharing options...
DexterMorgan Posted July 4, 2008 Share Posted July 4, 2008 This is really nice Kip. Good Work muttley code Link to comment Share on other sites More sharing options...
newbiescripter Posted July 4, 2008 Share Posted July 4, 2008 It's BETWEEN 0 and 100, -0 1 2 3 ... 98 99 100- --|____________|----- everything what's between 0 and 100, not including 0 and 100. Ok.. in that case you are right.. I've always included it. and I think alot will do that to.. but enough about that, I was talking about the first one you posted: I just couldn't make it work, when I guessed on 98 it couldn't guess it. it stops on 97 are there others having that problem ? 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 Regards Link to comment Share on other sites More sharing options...
malu05 Posted July 4, 2008 Share Posted July 4, 2008 (edited) Is it just me or is this script bugged (the original)?I pick 85...Try 1 - 50Try 2 - 75Try 3 - 87Try 4 - 80Try 5 - 83Try 6 - 84Try 7 - 84Try 8 - 84Try 9 - 84Try 10 - 84Try 11 - 84Try 12 - 84Try 13 - 84Try 14 - 84Try 15 - 84and so on....If i do this 70 times another bug occour. LAWL? Edited July 4, 2008 by malu05 [center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center] Link to comment Share on other sites More sharing options...
newbiescripter Posted July 4, 2008 Share Posted July 4, 2008 Yes exactly that was my point.. It was the one that I did referate to, when I said that it didn't worked.. But maybe it was because he double post it.. i remember that I made the first or second comment and after that it has been moved to this original post.. Regards Link to comment Share on other sites More sharing options...
gseller Posted July 4, 2008 Share Posted July 4, 2008 Cool script, can't guess 17 though... muttley Link to comment Share on other sites More sharing options...
shortstop Posted July 4, 2008 Share Posted July 4, 2008 log base 2 of 100 < 8 Link to comment Share on other sites More sharing options...
Andreik Posted July 4, 2008 Share Posted July 4, 2008 log base 2 of 100 < 8Yes, is true and... When the words fail... music speaks. Link to comment Share on other sites More sharing options...
James Posted July 4, 2008 Share Posted July 4, 2008 Same problem with the number 98. I edited the game so it would ConsoleWrite() the numbers from 1 to 100 along with the amount of retries it takes, 98 just fuckerz up. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
NELyon Posted July 4, 2008 Share Posted July 4, 2008 Same problem with the number 98. I edited the game so it would ConsoleWrite() the numbers from 1 to 100 along with the amount of retries it takes, 98 just fuckerz up. How odd. It seems to work just fine for me. Link to comment Share on other sites More sharing options...
Andreik Posted July 4, 2008 Share Posted July 4, 2008 Work fine for number 98, 7 tries. 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 Works fine for me too. What if you try this script? (Not so much different) expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> $Poss = 100 $COUNT = 1 $DIVIDE = 2 MsgBox(0,"Mind Reader","Pick a number between 0 and "&$Poss&".") $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($Poss/2, 192, 8, 300, 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 "&$Poss&".") GUICtrlSetData($Number,$Poss/2) $COUNT = 1 $DIVIDE = 2 Case $Higher $DIVIDE = $DIVIDE*2 $Add = $Poss/$DIVIDE $Read = GUICtrlRead($Number) GUICtrlSetData($Number,Round($Read+$Add)) $COUNT += 1 Case $Lower $DIVIDE = $DIVIDE*2 $Add = $Poss/$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...
Skrip Posted July 5, 2008 Share Posted July 5, 2008 Seems to work great! [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
notta Posted July 5, 2008 Share Posted July 5, 2008 (edited) It can't guess 88. [edit] Nevermind, I used the updated version below and it worked fine.[/edit] Edited July 5, 2008 by notta Link to comment Share on other sites More sharing options...
Kitsune Posted July 5, 2008 Share Posted July 5, 2008 (edited) Mine compiles far smaller and runs faster of course CODETITLE MindReader include Irvine32.inc .data prompinput db "Pick a number between 0 and 100",0 prompask db "Is this your number? ",0 prompanswer db "Lower=1 Correct=2 Higher=3, -1 to exit>",0 prompouta db "I knew I could guess it.",0 prompoutb db "I only tried it ",0 prompoutc db " times!",0 prompoutd db "Ok, again. ",0 guess sdword ? divide sdword ? .code main proc sub eax,eax sub ebx,ebx sub ecx,ecx sub edx,edx mov divide,2 mov guess,50 call crlf jmp L2 L1: call crlf mov edx,offset prompoutd call writestring call crlf L2: sub eax,eax sub ebx,ebx sub ecx,ecx sub edx,edx mov ecx,1 mov divide,2 mov guess,50 mov edx,offset prompinput call writestring call crlf L3: mov edx,offset prompask call writestring mov eax,guess call writedec call crlf mov edx,offset prompanswer call writestring call readint cmp eax,-1 je Return cmp eax,2 jb Lr je Ct ja Hr Lr: mov edx,0 mov eax,divide mov ebx,2 mul ebx push eax mov edx,0 mov ebx,eax mov eax,100 div ebx mov ebx,divide cmp edx,ebx jb Lr1 inc eax Lr1: mov ebx,guess sub ebx,eax mov guess,ebx pop eax mov divide,eax inc ecx jmp L3 Ct: call crlf mov edx,offset prompouta call writestring call crlf mov edx,offset prompoutb call writestring mov eax,ecx call writedec mov edx,offset prompoutc call writestring call crlf mov edx,offset prompoutd call writestring jmp L2 Hr: mov edx,0 mov eax,divide mov ebx,2 mul ebx push eax mov edx,0 mov ebx,eax mov eax,100 div ebx mov ebx,divide cmp edx,ebx jb Hr1 inc eax Hr1: mov ebx,guess add ebx,eax mov guess,ebx pop eax mov divide,eax inc ecx jmp L3 Return: exit main endp end main I wonder why.... muttley Edited July 5, 2008 by Kitsune Link to comment Share on other sites More sharing options...
Andreik Posted July 5, 2008 Share Posted July 5, 2008 Mine compiles far smaller and runs faster of course muttleyCODETITLE MindReaderinclude Irvine32.inc.dataprompinput db "Pick a number between 0 and 100",0prompask db "Is this your number? ",0prompanswer db "Lower=1 Correct=2 Higher=3, -1 to exit>",0prompouta db "I knew I could guess it.",0prompoutb db "I only tried it ",0prompoutc db " times!",0prompoutd db "Ok, again. ",0guess sdword ?divide sdword ?.codemain procsub eax,eaxsub ebx,ebxsub ecx,ecxsub edx,edxmov divide,2mov guess,50call crlfjmp L2L1:call crlfmov edx,offset prompoutd call writestringcall crlfL2:sub eax,eaxsub ebx,ebxsub ecx,ecxsub edx,edxmov ecx,1mov divide,2mov guess,50mov edx,offset prompinputcall writestringcall crlfL3:mov edx,offset prompaskcall writestringmov eax,guesscall writedeccall crlfmov edx,offset prompanswercall writestringcall readintcmp eax,-1je Returncmp eax,2jb Lrje Ctja HrLr:mov edx,0mov eax,dividemov ebx,2mul ebxpush eaxmov edx,0mov ebx,eaxmov eax,100div ebxmov ebx,dividecmp edx,ebxjb Lr1inc eaxLr1:mov ebx,guesssub ebx,eaxmov guess,ebxpop eaxmov divide,eaxinc ecxjmp L3Ct:call crlfmov edx,offset prompoutacall writestringcall crlfmov edx,offset prompoutbcall writestringmov eax,ecxcall writedecmov edx,offset prompoutccall writestringcall crlfmov edx,offset prompoutdcall writestringjmp L2Hr:mov edx,0mov eax,dividemov ebx,2mul ebxpush eaxmov edx,0mov ebx,eaxmov eax,100div ebxmov ebx,dividecmp edx,ebxjb Hr1inc eaxHr1:mov ebx,guessadd ebx,eaxmov guess,ebxpop eaxmov divide,eaxinc ecxjmp L3Return:exitmain endpend mainASM?? When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Kitsune Posted July 5, 2008 Share Posted July 5, 2008 (edited) ASM??yep muttleyAnd yes it works correctly when you answer honestly, pre-tested. Edited July 5, 2008 by Kitsune Link to comment Share on other sites More sharing options...
Andreik Posted July 5, 2008 Share Posted July 5, 2008 (edited) yep muttleyAnd yes it works correctly when you answer honestly, pre-tested.This is AutoIt Forum. Anyway your code is welcome. Edited July 5, 2008 by Andreik When the words fail... music speaks. 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