Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Richard Frost

Pages: 1 2 [3] 4 5 ... 22
31
QB64 Discussion / Re: Forum outages
« on: December 06, 2021, 06:13:57 pm »
I use branchless programming a lot in critical sections of my chess program where the ultimate in speed is required. 
The problem with it is that it makes the code very, very ugly and hard to understand later.

Another way to get more speed is to avoid using strings.  Cut the strings and SET THE PUPPETS FREE!

32
Programs / Re: 🐠 Curious Fish
« on: December 02, 2021, 03:06:47 pm »
Cute.  Should have Don Ho's "Tiny Bubbles" playing in the background.

33
QB64 Discussion / Re: What's your digital signature look like?
« on: December 01, 2021, 02:54:17 pm »
What a unique idea! 

I want tuna, I want liver, I want chicken, please deliver.

34
QB64 Discussion / Re: Hey Jude
« on: November 24, 2021, 10:36:54 pm »
Code: QB64: [Select]
  1.     Print "Number 9....";
  2.  

35
QB64 Discussion / Re: QB64 Certification
« on: November 20, 2021, 07:09:00 pm »
Design and print your own certificate.  It should contain a picture of a dodo bird or Chia Pet.

Mine has this:

36
Programs / Re: Contour Plot
« on: November 20, 2021, 03:54:19 pm »
I've wanted code to do that for over 20 years.  I did ONE hill in a sad, 2D fashion.

Lovely stuff, slightly marred by using FONT 8, so I modified your code to use Liberati 9.

My feeble attempt:

Code: QB64: [Select]
  1. Dim distance(360), elevation(360), active(20), angle(20)
  2. Screen _NewImage(800, 600, 12)
  3. xc = _Width \ 2: yc = _Height \ 2
  4. asp! = yc / xc
  5.  
  6.     Cls
  7.     mind = 9999: maxd = -mind
  8.     mine = 9999: maxe = -mine
  9.  
  10.     distance(0) = 0
  11.     e0 = 300 + Rnd * 20
  12.     active(0) = 360
  13.     elevation(0) = e0
  14.     elevation(360) = e0
  15.     maxe = e0
  16.  
  17.     n = 8
  18.     genang:
  19.     For i = 1 To n
  20.         angle(i) = Rnd * 360
  21.     Next i
  22.     sort:
  23.     sorted = 1
  24.     For i = 1 To n - 1
  25.         If angle(i) > angle(i + 1) Then sorted = 0: Swap angle(i), angle(i + 1)
  26.     Next i
  27.     If sorted = 0 Then GoTo sort
  28.     For i = 1 To n - 1
  29.         If (angle(i + 1) - angle(i)) < 20 Then GoTo genang
  30.     Next i
  31.  
  32.     For i = 1 To n
  33.         angle = angle(i)
  34.         angle = (angle + 360) Mod 360
  35.         active(i) = angle Mod 360
  36.         distance = 50 + Rnd * 250
  37.         elevation = 100 + Rnd * 150
  38.         If distance > maxd Then maxd = distance
  39.         If distance < mind Then mind = distance
  40.         If elevation > maxe Then maxe = elevation
  41.         If elevation < mine Then mine = elevation
  42.         distance(angle) = distance
  43.         elevation(angle) = elevation
  44.     Next i
  45.     xm = xc / (maxd - mind)
  46.     ym = yc / (maxd - mind)
  47.     active(n + 1) = active(1) '                            repeat 1st coord
  48.     distance(active(n + 1)) = distance(active(1))
  49.     elevation(active(n + 1)) = elevation(active(1))
  50.  
  51.     For i = 1 To n + 1 '                                   approx missing data each degree
  52.         angle1 = active(i - 1)
  53.         angle2 = active(i)
  54.         ddif = distance(angle2) - distance(angle1)
  55.         edif = elevation(angle2) - elevation(angle1)
  56.         If i = (n + 1) Then angle2 = angle2 + 360
  57.         a = 0: ai = 90 / (angle2 - angle1) '               angle, angle increment
  58.         For z = Int(angle1) To angle2
  59.             na = z Mod 360 '                               ensure array bounds not exceeded
  60.             q = Sin(_D2R(a))
  61.             q = q * q '                                    smoothing
  62.             a = a + ai
  63.             distance(na) = distance(angle1) + ddif * q
  64.             elevation(na) = elevation(angle1) + edif * q
  65.         Next z
  66.     Next i
  67.     EndinEl = Int(maxe / q) * q
  68.     For el = -300 To EndinEl Step 5
  69.         col = 1
  70.         If (el Mod 20) = 0 Then col = 9
  71.         If (el Mod 40) = 0 Then col = 4
  72.         pf = 0 '                                           plot flag (move/draw)
  73.         For mangle = 0 To 360
  74.             angle = mangle Mod 360
  75.             distance = distance(angle)
  76.             elevation = elevation(angle)
  77.             epf = distance / (e0 - elevation)
  78.             d = distance - ((el - elevation) * epf)
  79.             x = xc + d * xm * Cos(_D2R(angle)) * asp!
  80.             y = yc - d * ym * Sin(_D2R(angle))
  81.             If pf = 1 Then Line -(x, y), col Else pf = 1: PSet (x, y), col
  82.         Next mangle
  83.     Next el
  84.  
  85.     For i = 0 To n
  86.         d = 0: e = e0
  87.         If i Then d = distance(i): e = elevation(angle(i))
  88.         x = xc + d * Cos(_D2R(angle(i))) * asp!
  89.         y = yc - d * Sin(_D2R(angle(i)))
  90.         Circle (x, y), 1, 15
  91.         _PrintString (x, y + 5), Str$(Int(e))
  92.     Next i
  93.     Sleep
  94.  

37
Programs / Re: Even Better Stars
« on: November 18, 2021, 07:05:37 pm »
It's what Dave would have seen in 2001 if Kubrick wasn't so much into realism - Dave
after a lollipop overdose.   The animation would fit well into The Big Lebowski too.  Super pretty.





38
I recommend my chess program as an example of accommodating Windows or Linux Mint -
the version in the Forums, not the outdated one in Games.

1) As I need to rename,delete, and edit files (saved games), I've defined variables
   for these commands and assign them in an "$IF WIN" block.  In the same block I
   also set a variable called minty to true for Linux, for later use.

2) Windows libraries don't work with Linux.  SMcNeill's getCPUload function is for
   Windows.  Under Linux I use the sensors command instead.

3) Linux really cares about file case.  For chess I've made all resource files
   lowercase, but can handle a user renaming a log file using upper or mixed case.

4) Linux uses / in pathnames.  Windows uses \ in pathnames.  So create a constant or
   variable called "slash".

5) Filename dates are a little different in Mint.  The year is not shown unless the
   file is older than 6 months.  Keep that in mind if you read directories and need
   that info.

6) I haven't gotten icons to work at all, with $EXEICON or _ICON.

I'm pretty new to Linux Mint too, having been given a machine containing it about 2
months ago and only working on getting my chess program fully compatible with it
for the past week.

There are likely a lot of other differences a compatible program should handle.  The
above are the problems I've had so far.

39
Programs / Re: Chess
« on: November 17, 2021, 09:07:03 pm »
Update:

1) full Linux compatibility (all files lowercase and uses sensors for temperature)
2) better throttling
3) nicer appearance
4) 3 clocks to choose from
5) blessed by a garden gnome in Walla Walla Washington

6) "Style" button to sequence thru 12 styles (colors, sets, clock type, etc)


40
Programs / Re: Ascii Plasma!
« on: November 11, 2021, 06:29:12 am »
Very impressive!

Now train 12,000 monkeys to hold up placards to accomplish the same.

41
Programs / Re: CLOCK.BAS
« on: November 08, 2021, 06:09:00 pm »
Ran yours - always nice to see unique clocks.  Since you mentioned the airport type:
 
Code: QB64: [Select]
  1. _Title " World Clock"
  2. Dim p$(30), zo(30), t$(30) '                     place, zone, time
  3. Screen _NewImage(800, 600, 32)
  4. For i = 1 To 30: Read p$(i), zo(i): Next i
  5. d = 35 '                                         diameter of clocks
  6.     Cls: t$ = Time$
  7.     h = (Val(Mid$(t$, 1, 2)) + 7) Mod 24 '       GMT = my time + 7
  8.     m = Val(Mid$(t$, 4, 2))
  9.     For i = 1 To 30 '                            actual time for each place
  10.         th = h + Int(zo(i))
  11.         z! = Abs(zo(i)) - Abs(Int(zo(i)))
  12.         tm = m + z! * 60 * Sgn(zo(i))
  13.         If tm < Val("00") Then tm = tm + 60: th = th - 1
  14.         If tm > Val("59") Then tm = tm - 60: th = th + 1
  15.         th = (th + 24) Mod 24
  16.         th$ = Right$("0" + LTrim$(Str$(th)), 2)
  17.         tm$ = Right$("0" + LTrim$(Str$(tm)), 2)
  18.         t$(i) = th$ + tm$
  19.     Next i
  20.     p = 0 '                                      place index
  21.     For yi = 0 To 4
  22.         For xi = 0 To 5
  23.             xc = xi * _Width \ 6 + (_Width \ 6) * .5
  24.             yc = yi * _Height / 5.4 + 60
  25.             p = p + 1 '                          place index
  26.             _PrintString (xc - _PrintWidth(p$(p)) \ 2, yc + d + 4), p$(p)
  27.             Circle (xc, yc), d + 2, Green
  28.             If Val(Left$(t$(p), 2)) < 12 Then Paint (xc, yc), Green, Green ' am/pm
  29.             For a = 0 To 330 Step 30 '           clock tick marks
  30.                 x1 = xc + (d - 3) * Cos(_D2R(a))
  31.                 y1 = yc + (d - 3) * Sin(_D2R(a))
  32.                 Circle (x1, y1), 1, White '      ticks
  33.             Next a
  34.             th = Val(Mid$(t$(p), 1, 2)) '        hour
  35.             tm = Val(Mid$(t$(p), 3, 2)) '        minute
  36.             ra = _D2R(tm * 6 - 90) '             minute hand
  37.             x(0) = xc + (d - 8) * Cos(ra)
  38.             y(0) = yc + (d - 8) * Sin(ra)
  39.             ra = _D2R((th + tm / 60) * 30 - 90) 'hour hand
  40.             x(1) = xc + (d - 16) * Cos(ra)
  41.             y(1) = yc + (d - 16) * Sin(ra)
  42.             For zz = 0 To 1 '                    draw hands
  43.                 For zx = -1 To 1
  44.                     For zy = -1 To 1
  45.                         Line (xc + zx, yc + zy)-(x(zz), y(zz)), White
  46.                     Next zy
  47.                 Next zx
  48.             Next zz
  49.         Next xi
  50.     Next yi
  51.     Do: _Limit 10 '                              wait for new minute
  52.         x = 20 + Val(Right$(Time$, 2)) / 60 * (_Width - 40)
  53.         Line (20, _Height - 20)-(x, _Height - 21), Green, B
  54.         _Display
  55.         If Len(InKey$) Then System '             any key exits
  56.     Loop Until Left$(t$, 5) <> Left$(Time$, 5)
  57.  
  58. Data Amsterdam,1
  59. Data Beijing,8
  60. Data Berlin,1
  61. Data Brasilia,-3
  62. Data Cairo,2
  63. Data Chicago,-6
  64. Data Delhi,5.5
  65. Data Denver,-7
  66. Data Detroit,-5
  67. Data Edmonton,-7
  68. Data Gander,-3.5
  69. Data Hawaii,-10
  70. Data Hong Kong,8
  71. Data Houston,-6
  72. Data Istanbul,2
  73. Data London,0
  74. Data Los Angeles,-9
  75. Data Madrid,1
  76. Data Mexico City,-6
  77. Data Moscow,3
  78. Data New York,-5
  79. Data Paris,1
  80. Data Perth,8
  81. Data Phoenix,-8
  82. Data Rome,1
  83. Data Seoul,9
  84. Data Singapore,8
  85. Data Sydney,10
  86. Data Tehran,3.5
  87. Data Tokyo,9
  88.  

42
Steve's extendedtimer function is the ultimate solution, but overkill for most situations.   An easier way to deal with crossing midnite is:


Code: QB64: [Select]
  1. start! = Timer
  2. Do: _Limit 100 '                                       _LIMIT helps prevent CPU overload
  3.     elapsed! = Timer - start!
  4.     If elapsed! < 0 Then elapsed! = elapsed! + 86400 ' must have crossed midnite, add a day
  5.     Locate 1, 1: Print Using "###.##"; elapsed! '      show elapsed time
  6. Loop Until Len(InKey$) '                               any key exits loop
  7. System '                                               return to watching cat videos
  8.  

43
QB64 Discussion / Re: Memory leak (revisited)
« on: September 16, 2021, 07:49:36 pm »
Load &  display an image 10,000 times with no _LIMIT or _DELAY? 
Are you using your CPU to toast bread?

44
QB64 Discussion / Re: Memory leak (revisited)
« on: September 16, 2021, 08:31:55 am »
Screens also count as images. 

My chess program toggles between 480*600 and 800*600, the larger screen
for displaying extra info like pieces captured, history, thinking, etc.

How I *was* doing that, simply SCREEN _NEWIMAGE(scx,scy,32) was creating
a memory leak.  The right way to do it is:

IF mscreen& < -1 THEN
   SCREEN 0
   _FREEIMAGE mscreen&
END IF

mscreen& = _NEWIMAGE(scx,scy,32)
SCREEN mscreen&

The variable mscreen& needs to be in a SUB declared with STATIC, or DIM
SHARED to preserve the value.

45
Programs / Re: Chess
« on: September 12, 2021, 12:54:53 am »
Sep 11, 2021

1) Downsized 2 chess sets, so they load much faster.
2) Lots of small graphics improvements.
3) More, but I forget.  Another price of being uncertain of how often    updates are ok here, when old
    code is never overwritten.



Pages: 1 2 [3] 4 5 ... 22