1

##### Code and examples / Re: XML Parser

« Last post by**ZXDunny**on

*18. August 2017, 12:33:19*»

I'm on a mac...

1

I'm on a mac...

2

I'm curious what web development interest is here on the forum? It seems Windows desktop is where BASIC calls home.

3

Yes that works, sort of...

Could put the equations in a string array and run the strings through eval. Just a thought...

Could put the equations in a string array and run the strings through eval. Just a thought...

4

You only have to uncomment the function you want to try.

5

Thanks, wish I could copy/paste into input.

6

Hello. The comment functions work nice.

Code: [Select]

` //LET Y=(X*X+Z*Z)/1000`

//LET Y=LOG(1+(X+Z)*SIG(X+Z))/10

//LET Y=SIN(((60-X*X-Z*Z)*(ABS(SIN(60-X*X-Z*Z))+1))/3000)

//LET Y=SIG(INT(23/(.00001+X*X+Z*Z)))/3+SIG(INT(55/(.00001+X*X+Z*Z)))/15

7

Hi Richey,

I would setup a Hi and Lo variable, starting the Hi at 101 and the Lo at 0 then the guess is (Hi - Lo)/2 + Lo, so first guess is 101/2 + 0 = 50 (You might need INT to round down to integer guesses.)

From the feed back on the guess, raise the Lo or Lower the Hi.

So say 50 was too high, then your new Hi is 50 and your next guess is 50/2 + 0 = 25

If 50 was too low then the Lo is made 50 and (101 - 50)/2 + 50 = 75 is your next guess.

Continue in this way until the guess is correct.

You would find a word in a sorted list in the same way.

Append: This works in SmallBASIC

EDIT: Hi start at 101 not 100

I would setup a Hi and Lo variable, starting the Hi at 101 and the Lo at 0 then the guess is (Hi - Lo)/2 + Lo, so first guess is 101/2 + 0 = 50 (You might need INT to round down to integer guesses.)

From the feed back on the guess, raise the Lo or Lower the Hi.

So say 50 was too high, then your new Hi is 50 and your next guess is 50/2 + 0 = 25

If 50 was too low then the Lo is made 50 and (101 - 50)/2 + 50 = 75 is your next guess.

Continue in this way until the guess is correct.

You would find a word in a sorted list in the same way.

Append: This works in SmallBASIC

Code: [Select]

`' Hi Lo AI.bas SmallBASIC 0.12.9 (B+=MGA) 2017-08-14`

secret = int(rnd*100) + 1 ' < 1 to 100

Hi = 101 : Lo = 0 '< make these higher and lower than what the secret number can be (just tested secret = 100, oops!)

label anotherGuess

guess = int((Hi - Lo)/2) + Lo

print "Guessing: ";guess

if guess = secret then

print "Yes! The secret number was ";guess

? : input "Want to see another, y + Enter for yes ";yes

if yes = "y" then

? : secret = int(rnd*100) + 1 : Hi = 101 : Lo = 0

else

stop

fi

elif guess > secret then

Print "Too high!"

Hi = guess

else

print "Too Low!"

Lo = guess

fi

goto anotherGuess

EDIT: Hi start at 101 not 100

8

I have come up with the following code in SpecBAS in response to a programming challenge to create an AI guessing game.

The aim is to get the computer to generate a random number and then for the computer to try and guess the number.

I can get the computer to eventually guess the randomly generated number but only through increments or decrements of 1.

Is there a way of getting the computer to reach the randomly generated number through a process of elimination as a human would, which may or may not necessarily be done through increments / decrements of 1?

Here is my code...

Many thanks in advance for any help. Any other suggestions for improvements would also be greatly appreciated.

The aim is to get the computer to generate a random number and then for the computer to try and guess the number.

I can get the computer to eventually guess the randomly generated number but only through increments or decrements of 1.

Is there a way of getting the computer to reach the randomly generated number through a process of elimination as a human would, which may or may not necessarily be done through increments / decrements of 1?

Here is my code...

Code: [Select]

`5 REM AI Guessing Game`

10 PRINT "I'M CHOOSING A NUMBER BETWEEN 1 AND 100"

20 LET AIChoose=INT(RND*100)

30 PRINT "The number is ";AIChoose

40 PRINT "I'M TRYING TO GUESS THE NUMBER"

60 LET AIGuess=INT(RND*100)

80 DO

90 IF AIGuess<AIChoose THEN INC AIGuess,AIGuess TO 100

95 IF AIGuess>AIChoose THEN DEC AIGuess,AIGuess TO AIChoose

110 PRINT "Is it ";AIGuess;"?"

120 IF AIGuess=AIChoose THEN EXIT

130 LOOP UNTIL AIGuess=AIChoose

140 PRINT "Yes, the number I guessed was ";AIGuess;" and the number you chose was ";AIChoose

150 STOP

Many thanks in advance for any help. Any other suggestions for improvements would also be greatly appreciated.

9

Ha! If his ad blocker worked, he wouldn't have seen any ads.

The thing is my browser already has an ad blocker built in.

AND this (see attachment) appears at the heading of the site:

What is one to think when they flat out lie? No popups, no annoyances? Who are they kidding?

The thing is my browser already has an ad blocker built in.

AND this (see attachment) appears at the heading of the site:

What is one to think when they flat out lie? No popups, no annoyances? Who are they kidding?

10

Hi Galileo,

Do you have suggestions for F(X, Z) = ?

Nothing I have tried has worked without error.

What function was used for screen shot?

Do you have suggestions for F(X, Z) = ?

Nothing I have tried has worked without error.

What function was used for screen shot?