Although GPT 4 is really good for programming, it's a shame that it doesn't master FreeBasic and other less popular languages with the same quality as Python or Javscript.
Of course, this is due to its popularity and the related use it has with said languages.
It would be great to be able to train a chatbot with enough FreeBasic examples so that it gives results just as good as with Python on the first try hehe.
ChatGPT
Re: ChatGPT
@Dr_D maybe you can use this
Code: Select all
/'
tiling subpixel sampler - 2023 Aug 5 - by dafhi
update
removed unused: min() and Tau
added image destroy in imvars.destructor
'/
#define flo(x) (((x)*2.0-0.5)shr 1) '' http://www.freebasic.net/forum/viewtopic.php?p=118633
#define sng as single
#define dbl as double
function modu( i as double, m as double = 1 ) as double
return i - m * flo( i / m )
end function
union uptrs
as any ptr a
as ubyte ptr b
as ushort ptr sho
as ulong ptr l
as ulongint ptr li
As Single Ptr s
as double ptr d
End Union
dim shared as uptrs gp
#Macro Alpha256(ret,back, fore, a256) '2017 Mar 26
ret=((_
(fore And &Hff00ff) * a256 + _
(back And &Hff00ff) * (256-a256) + &H800080) And &Hff00ff00 Or (_
(fore And &H00ff00) * a256 + _
(back And &H00ff00) * (256-a256) + &H008000) And &H00ff0000) Shr 8
#EndMacro
#Macro Alpha256_64(ret,back, fore, a256) '2023 Aug 4
ret=((_
(fore And &Hff00ff00FF00FF) * a256 + _
(back And &Hff00ff00FF00FF) * (256-a256) + &H0080008000800080) And &Hff00ff00ff00ff00 Or (_
(fore And &H00ff000000ff00) * a256 + _
(back And &H00ff000000ff00) * (256-a256) + &H0000800000008000) And &H00ff000000ff0000) Shr 8
#EndMacro
type imvars
declare constructor
declare constructor( byref as any ptr = 0 )
declare destructor '' update
declare sub get_info( byref p as any ptr = 0 )
declare sub _destroy '' update
as long w '' apparently imageinfo no longer likes integer
as long h
as long pitch,rate
as long bypp,bpp
as any ptr pixels
as any ptr im
as string driver_name
as long wm, hm
end type
constructor imvars
end constructor
constructor imvars( byref p as any ptr )
get_info p
end constructor
destructor imvars '' update
_destroy
end destructor
sub imvars._destroy '' update
if imageinfo(im)=0 then imagedestroy im: im=0
end sub
sub imvars.get_info( byref p as any ptr )
_destroy '' update
if p = 0 then
ScreenInfo w,h, bpp, bypp, pitch, rate, driver_name
pixels = screenptr
else
ImageInfo p, w, h, bypp, pitch, pixels
if bypp = 0 then p = 0
endif
im = p: wm = w-1: hm = h-1
end sub
namespace sample2d
dim as imvars src
sub source_image( i as any ptr )
src.get_info i
end sub
function pt( xa sng, ya sng ) as ulong '' 4 pixel sample
xa = modu( xa, src.w )
ya = modu( ya, src.h )
static sng xb: xb = modu( xa+1, src.w )
static sng yb: yb = modu( ya+1, src.h )
static as long ixa, ixb, iya: ixa = flo(xa): ixb = flo(xb): iya = flo(ya)
gp.a = src.pixels + iya*src.pitch
var pel64_top = gp.l[ixa] or gp.l[ixb] shl 32
gp.a = src.pixels + flo(yb)*src.pitch
var pel64_bot = gp.l[ixa] or gp.l[ixb] shl 32
iya = flo(256.499 * (ya-iya)) '' borrowing iya for alpha
Alpha256_64( pel64_bot, pel64_top, pel64_bot, iya )
iya = flo(256.499 * (xa-ixa))
Alpha256( pel64_bot, pel64_bot, pel64_bot shr 32, iya )
return pel64_bot
end function
end namespace
var w = 800, wm = w-1
var h = 600, hm = h-1
screenres w,h,32
sample2d.source_image imagecreate( 3,3, rgb(0,0,0) )
for y as long = 0 to sample2d.src.hm
for x as long = 0 to sample2d.src.wm
pset sample2d.src.im, (x,y), rgb(rnd*255,rnd*255,rnd*255)
next
next
for y as long = 0 to hm
for x as long = 0 to wm
var sx = x / wm * sample2d.src.wm
var sy = y / hm * sample2d.src.hm
pset(x,y), sample2d.pt( sx, sy )
next
next
sleep
Re: ChatGPT
I'm definitely interested to see what other people can get it to do. I've had very limited results. It's interesting how some of the theory behind what it does is solid, but it uses keywords wrong a lot. I was really surprised when it used peek and poke, for instance. I've hardly ever seen a real person use them. Just for the sake of the conversation, here's something else I requested of it. Most of us already have our own code for these sorts of utilities, but it's still interesting to see what pops out of the back box...
My input on this one...
"I asked you to write some code for a triangle rasterizer in freebasic previously. How about writing some code to determine if a point is inside a triangle in the cartesian plane?"
My input on this one...
"I asked you to write some code for a triangle rasterizer in freebasic previously. How about writing some code to determine if a point is inside a triangle in the cartesian plane?"
Code: Select all
function PointInTriangle(x as single, y as single, _
x1 as single, y1 as single, _
x2 as single, y2 as single, _
x3 as single, y3 as single) as integer
' Compute vectors
dim v0 as single = x3 - x1
dim v1 as single = x2 - x1
dim v2 as single = single(x) - x1
dim u0 as single = y3 - y1
dim u1 as single = y2 - y1
dim u2 as single = single(y) - y1
' Compute dot products
dim dot00 as single = v0 * v0 + u0 * u0
dim dot01 as single = v0 * v1 + u0 * u1
dim dot02 as single = v0 * v2 + u0 * u2
dim dot11 as single = v1 * v1 + u1 * u1
dim dot12 as single = v1 * v2 + u1 * u2
' Compute barycentric coordinates
dim invDenom as single = 1.0 / (dot00 * dot11 - dot01 * dot01)
dim u as single = (dot11 * dot02 - dot01 * dot12) * invDenom
dim v as single = (dot00 * dot12 - dot01 * dot02) * invDenom
' Check if point is in triangle
if (u >= 0) and (v >= 0) and (u + v <= 1) then
PointInTriangle = 1
else
PointInTriangle = 0
end if
end function
Re: ChatGPT
Thanks for posting you code. I wasn't necessarily looking for a solution this time, however. I was just toying with the chatbot to see what it is actually capable of. I have mixed opinions on it, but I think as a whole, it's just going to make people worse programmers. By and large, we've already grown lazy compared to the way things used to get done. Maybe that's too pessimistic though... lol
dafhi wrote: ↑Aug 06, 2023 3:27 @Dr_D maybe you can use thisCode: Select all
/' tiling subpixel sampler - 2023 Aug 5 - by dafhi update removed unused: min() and Tau added image destroy in imvars.destructor '/ #define flo(x) (((x)*2.0-0.5)shr 1) '' http://www.freebasic.net/forum/viewtopic.php?p=118633 #define sng as single #define dbl as double function modu( i as double, m as double = 1 ) as double return i - m * flo( i / m ) end function union uptrs as any ptr a as ubyte ptr b as ushort ptr sho as ulong ptr l as ulongint ptr li As Single Ptr s as double ptr d End Union dim shared as uptrs gp #Macro Alpha256(ret,back, fore, a256) '2017 Mar 26 ret=((_ (fore And &Hff00ff) * a256 + _ (back And &Hff00ff) * (256-a256) + &H800080) And &Hff00ff00 Or (_ (fore And &H00ff00) * a256 + _ (back And &H00ff00) * (256-a256) + &H008000) And &H00ff0000) Shr 8 #EndMacro #Macro Alpha256_64(ret,back, fore, a256) '2023 Aug 4 ret=((_ (fore And &Hff00ff00FF00FF) * a256 + _ (back And &Hff00ff00FF00FF) * (256-a256) + &H0080008000800080) And &Hff00ff00ff00ff00 Or (_ (fore And &H00ff000000ff00) * a256 + _ (back And &H00ff000000ff00) * (256-a256) + &H0000800000008000) And &H00ff000000ff0000) Shr 8 #EndMacro type imvars declare constructor declare constructor( byref as any ptr = 0 ) declare destructor '' update declare sub get_info( byref p as any ptr = 0 ) declare sub _destroy '' update as long w '' apparently imageinfo no longer likes integer as long h as long pitch,rate as long bypp,bpp as any ptr pixels as any ptr im as string driver_name as long wm, hm end type constructor imvars end constructor constructor imvars( byref p as any ptr ) get_info p end constructor destructor imvars '' update _destroy end destructor sub imvars._destroy '' update if imageinfo(im)=0 then imagedestroy im: im=0 end sub sub imvars.get_info( byref p as any ptr ) _destroy '' update if p = 0 then ScreenInfo w,h, bpp, bypp, pitch, rate, driver_name pixels = screenptr else ImageInfo p, w, h, bypp, pitch, pixels if bypp = 0 then p = 0 endif im = p: wm = w-1: hm = h-1 end sub namespace sample2d dim as imvars src sub source_image( i as any ptr ) src.get_info i end sub function pt( xa sng, ya sng ) as ulong '' 4 pixel sample xa = modu( xa, src.w ) ya = modu( ya, src.h ) static sng xb: xb = modu( xa+1, src.w ) static sng yb: yb = modu( ya+1, src.h ) static as long ixa, ixb, iya: ixa = flo(xa): ixb = flo(xb): iya = flo(ya) gp.a = src.pixels + iya*src.pitch var pel64_top = gp.l[ixa] or gp.l[ixb] shl 32 gp.a = src.pixels + flo(yb)*src.pitch var pel64_bot = gp.l[ixa] or gp.l[ixb] shl 32 iya = flo(256.499 * (ya-iya)) '' borrowing iya for alpha Alpha256_64( pel64_bot, pel64_top, pel64_bot, iya ) iya = flo(256.499 * (xa-ixa)) Alpha256( pel64_bot, pel64_bot, pel64_bot shr 32, iya ) return pel64_bot end function end namespace var w = 800, wm = w-1 var h = 600, hm = h-1 screenres w,h,32 sample2d.source_image imagecreate( 3,3, rgb(0,0,0) ) for y as long = 0 to sample2d.src.hm for x as long = 0 to sample2d.src.wm pset sample2d.src.im, (x,y), rgb(rnd*255,rnd*255,rnd*255) next next for y as long = 0 to hm for x as long = 0 to wm var sx = x / wm * sample2d.src.wm var sy = y / hm * sample2d.src.hm pset(x,y), sample2d.pt( sx, sy ) next next sleep
Re: ChatGPT
Interesting that it went directly to barycentric coordinates. Perhaps if you ask it for a ray-triangle intersection (3D) it will go for Möller-Trumbore as well?
Re: ChatGPT
Has anyone else read the terms of use for ChatGPT ?
One of the restrictions is that you don't use it to develop a competing [ A.I ] product to ChatGPT .
I'm inclined to query them about this .
One of the restrictions is that you don't use it to develop a competing [ A.I ] product to ChatGPT .
I'm inclined to query them about this .
Re: ChatGPT
Ask ChatGPT this :
can I use chat gpt to produce an app that competes with chat gpt
to receive an outdated and somewhat ambiguous answer; hinting
that you're allowed to do so .
can I use chat gpt to produce an app that competes with chat gpt
to receive an outdated and somewhat ambiguous answer; hinting
that you're allowed to do so .
Re: ChatGPT
Which has no legal standing whatsoever. So what you wanted to achieve by asking ChatGPT this, seems a mystery to me.
Re: ChatGPT
So what is the legal situation if I attempt to construct AI using ChatGPT,
that might eventually compete with it.
Assuming all other peripheral concerns are met.
There are alternatives to ChatGPT, some geared more towards coding;
in a variety of languages.
Are these more liberal in the terms of use and deployment of code.
that might eventually compete with it.
Assuming all other peripheral concerns are met.
There are alternatives to ChatGPT, some geared more towards coding;
in a variety of languages.
Are these more liberal in the terms of use and deployment of code.