Jump to content

I can guess your number in less than 8 times.


Kip
 Share

Recommended Posts

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 muttley

Yes, math is cool. I like it.

When the words fail... music speaks.

Link to comment
Share on other sites

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

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

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 ?

#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

Is it just me or is this script bugged (the original)?

I pick 85...

Try 1 - 50

Try 2 - 75

Try 3 - 87

Try 4 - 80

Try 5 - 83

Try 6 - 84

Try 7 - 84

Try 8 - 84

Try 9 - 84

Try 10 - 84

Try 11 - 84

Try 12 - 84

Try 13 - 84

Try 14 - 84

Try 15 - 84

and so on....

If i do this 70 times another bug occour.

Posted Image

LAWL?

Edited by malu05

[center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center]

Link to comment
Share on other sites

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

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.

post-12929-1215202183_thumb.png

Link to comment
Share on other sites

Works fine for me too. What if you try this script? (Not so much different)

#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
Link to comment
Share on other sites

Mine compiles far smaller and runs faster of course :)

CODE
TITLE 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 by Kitsune
Link to comment
Share on other sites

Mine compiles far smaller and runs faster of course muttley

CODE
TITLE 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

ASM??

When the words fail... music speaks.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...