11

##### Code and examples / Re: Functions 3D

« Last post by**B+**on

*16. August 2017, 22:43:10*»

Thanks, wish I could copy/paste into input.

11

Thanks, wish I could copy/paste into input.

12

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

13

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

14

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.

15

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?

16

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?

17

Hello again. A bit of nostalgia.

Code: [Select]

`// Adaptation from ZX Spectrum BASIC program "Funciones 3D", "RUN, Enciclopedia Práctica del Spectrum", nº 2, 1985`

// to Yabasic 2.78.0, by Galileo, 8/2017

clear screen

LET LRG=256 : LET ALT=192

open window LRG,ALT

window origin "lb" : REM Origin of the graphical coordinates: left bottom

print "Enter '(Q)uit' for exit the program"

do

LET XG=5: LET ZG=XG-2

LET CT=INT (LRG/XG/2)

LET PF=INT (ALT/ZG/3)

INPUT "F(X,Z)= " A$

LET A$=trim$(upper$(A$))

if left$(A$,1)="Q" exit

LET P=0

REM CALCULO GRAFICO

DIM P(CT,PF)

FOR A=-PF/2 TO PF/2

FOR B=-CT/2 TO CT/2

LET X=A*20/CT: LET Z=B*20/PF

LET Y=EVAL(A$)

//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

LET P((B+CT)/2,(A+PF)/2)=Y*ALT*(-1)

IF P=8 LET P=0

LET P=P+1

NEXT B

NEXT A

clear window

REM DIBUJO PLANO X-Y

FOR Z=1 TO PF

LET X1=XG*Z

LET Z1=ALT/2+Z*ZG+20*(-1)

new curve

FOR X=1 TO CT

LET XP=X1+X*XG

LET ZP=Z1-X*ZG-P(X,Z)

line to XP,ZP

NEXT X

NEXT Z

REM DIBUJO PLANO Z-Y

FOR X=1 TO CT

LET X1=XG*X+PF*XG

LET Z1=ALT/2-X*ZG+PF*ZG+20*(-1)

new curve

FOR Z=0 TO PF-1

LET XP=X1-Z*XG

LET ZP=Z1-Z*ZG-P(X,PF-Z)

line to XP,ZP

NEXT Z

NEXT X

loop

sub EVAL(c$)

static linea

linea=linea+1

c$="sub s"+str$(linea+1000000,"#######")+"():return "+c$+":end sub"

compile c$

return execute(mid$(c$,5,8))

end sub

18

Beauty, jbk.

19

Quote

What does "draining your cookie file" mean?

Brute force method of returning the contents of you browser cookie file. Didn't you find it strange seeing ads popping up based on sites you visited?

20

Besides the ads ProBoards floods you with, they put your PC to its knees draining your cookie file.

What does "draining your cookie file" mean?