Squares

General FreeBASIC programming questions.
albert
Posts: 5916
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Postby albert » Aug 20, 2020 22:42

@Dodicat

I came up with a compression idea...

Using your factorial code... you output the number of 2's that make up the number , then output the extra as a string..

So if the input byte is "10" then you output "22222"
So if the input byte is "11" then you output "222221"

With al the 2's it might compress..???? It might make a compressible pattern out of the bytes??
MrSwiss
Posts: 3635
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: Squares

Postby MrSwiss » Aug 20, 2020 23:18

angros47 wrote:
coderJeff wrote:Hey man, every time you run a string of posts I get complaints. And when I try to address, I get complaints. Now, If I suspend your account *permanently* I'll probably get some hate mail for a while, but not forever. I'm thinking that works for me.

Sincerely, you would have all my support, for that. You have already showed much more tolerance and patience than is normally expected on a forum.

I can understand that albert might have his fans, but if they want to continue talking with him I suggest to do it in private. This forum cannot help albert with his issues.

I couldn't agree more. Albert simply seems to be incurable (see: last post below).
albert wrote:@Dodicat

I came up with a compression idea...

Using your factorial code... you output the number of 2's that make up the number , then output the extra as a string..

So if the input byte is "10" then you output "22222"
So if the input byte is "11" then you output "222221"

With al the 2's it might compress..???? It might make a compressible pattern out of the bytes??
deltarho[1859]
Posts: 2698
Joined: Jan 02, 2017 0:34
Location: UK

Re: Squares

Postby deltarho[1859] » Aug 21, 2020 0:48

albert on Aug 19, 2020 18:26 wrote:I'll stick to writing non-compression FB programs... Until i come up with a decompressor..

Well, that was a bit short-lived albert - just over 28 hours. Image

albert on Aug 20, 2020 22:42 wrote:I came up with a compression idea...

Of course that 28 hours may be due to time dilation which is what we get when we travel toward the event horizon of a black hole. Get too close and even Warp 9 will not get you out of trouble. You are at Warp 9? Ah, I won't bother putting the kettle on then.
albert
Posts: 5916
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Postby albert » Aug 21, 2020 1:09

I agree with you guys....

After years of formulas , I haven't found a compression formula that can be decompressed...
So I'll stop working on it....

I realize that it can't be done...

Random data , can't be compressed... I believe you guys....

========================================================================
There's a possibility , that a stand alone machine , running a counter could compress data...
where you could count for a specified time period..
A 2Ghz processor could count to 32 bits in 2 seconds.
So maybe the timing counter would be a single precision number..less than 32 bits...
You'd need a stand-alone machine that doesn't have an OS or threads..
A single run computer , that can only run a single program..
That stand-alone machine could plug into the USB port...to compress and decompress.. ???? Don't know if it would work or not..
========================================================================
deltarho[1859]
Posts: 2698
Joined: Jan 02, 2017 0:34
Location: UK

Re: Squares

Postby deltarho[1859] » Aug 21, 2020 1:37

albert wrote:Random data , can't be compressed... I believe you guys....

Image

That particle flying alongside you is Hawking radiation. The anti-particle fell in. You were very close, albert. Image
albert
Posts: 5916
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Postby albert » Aug 21, 2020 1:38

That stand-alone machine above gave me an idea....

Sort of like a CDROM..

You have two plastic plates sandwiching a sheet of shrink-wrap..
Then you burn holes in the shrink-wrap with a laser..

Then you have the reader.. that has a grid of photo-receivers.
The internal lighting shines through the holes in the inner shrink-wrap..
And is read by a grid of photo-diodes. or photo-transistors..

The laser goes back and forth , burning holes in the shrink-wrap
Then the reader is a backlit array of light readers..

It's not a RW "Read / Write" design , just a write only.

But it doesn't require a motor to spin a disk...
It just goes back & forth writing to the grid..
Then you read the sheet , by incrementing through the photo-grid array..

Not sure how many microns the laser could be, or how fine you could burn the holes for the shrink-wrap..
You might be able to get down to under a few microns...

But it wouldn't be heat stable.. if you left a disk on the dashboard of your car , it might get melted by the sun , and destroy the data????

The writing would be slow , moving to each point and Lasering the hole..
But the reading would be as fast as conventional memory.. Way faster than a CDROM..

Instead of a spinning motor , it would require an x axis motor and a y axis motor.. to Zig-Zag back & forth , burning the holes..
albert
Posts: 5916
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Postby albert » Aug 21, 2020 2:46

For the above Idea of a shrink-wrap CDROM

It would cost like a million dollars , to patent and make the initial device.. to peddle to Venture Capitalists.. to raise money to start a company..
It needs a photo-grid array, a 5 x 5 inch silicon etched chip of photo-diodes or photo-transistors for the read array..
That would cost like a million dollars to etch the initial chip...

So invented a societal order where it wouldn't cost anything to start a company..

====================================================================================================
I'm a confirmed communist.....

I don't like the communism of Russia or China..

My idea of communism is:

Everyone works and everything is free...

Free groceries
Free appliances
Free Jewelry
Free cars and trucks
Free houses

If you don't like your house , you can go to an architect and get a new design and have your house torn down and rebuilt..

We are at a stage of robotics , that most manufacturing can be done by all robots and machines..

For priceless artifacts and gems and paintings , they would all go to museums..

Every one works and everything is free... A society without a monetary system..

Anyone could start a business , and could encroach on patents of others , to give more options and choices for goods.. and create competition..
You just apply for a business license , and secure your land and have the architects and engineers design the plant , then hire workers to work at the plant..

There would be endless companies ; as anyone with an idea , could start a business to bring their idea to fruition..

Some say , communism would stifle competition , but pure communism would bolster competition and available products...

Anyone that can dream of a product , could start a business to make that dream come true and produce that product...
Capitalism stifles business as it costs money to start a business , and the money is scarce to most people with ideas for products...
With my idea of pure communism.. Any , and everyone with an idea , could start a business for free....

If anyone could start a company for free , there would be millions of companies world-wide... Making millions of products....

In a society of pure-communism , everyone would be spoiled and could have anything they want...

Space exploration would be common place , as governments don't need money to put satellites and rockets into space..
Countries could colonize space , the moon and other planets.... very quickly...

Everyone works and everything is free is the best societal order..... Like the TV show "Star-Trek"
Stonemonkey
Posts: 649
Joined: Jun 09, 2005 0:08

Re: Squares

Postby Stonemonkey » Aug 21, 2020 8:28

In a society of pure-communism , everyone would be spoiled and could have anything they want...

So someone who opens up a shop giving away pebbles for an hour a day is entitled to the same as someone who owns a construction company employing thousands of workers. I don't think people would be spoiled for long.
dodicat
Posts: 6726
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Squares

Postby dodicat » Aug 21, 2020 9:02

Probably Albert because we are what we have termed "primates".
Primates work on a hierarchical system where a leader and a pack roam around pillaging and bullying.
It is built into our genes.
Then a rotten leader appears and the pillaging and bullying becomes genocidal, we see it time and time again in our species.
If the dinosaur group had not disappeared I reckon we would have what you would like.
We have the birds ( dinosaurs relics), who have no leaders, they use the globe as their home.
If what comes round goes round, and it seems to do, they should inherit the earth in the final run.
Mother nature (Gaia) is fighting back now.
Most of the world primates are walking around just now wearing masks.
But still the destruction and dismantling of our planet (by us) goes on.
IMHO we are not the ones to establish communications with extra terrestrial life forms.
Anything out there with an jot of common sense would regard us as a nasty bloated virus to be avoided at any cost.
So I think the Star-Trek idea is a non starter.
I can make the stars twinkle though.

Code: Select all



Dim Shared As Integer xres,yres
Screenres 1280,1024,32,,64
Screeninfo xres,yres
Dim Shared As Ulong Pointer im
im=Imagecreate(xres,yres,rgb(0,0,50))
dim shared as string message
message="Use the arrow keys"

Type v2
    As Single x,y
End Type

#define Intrange(f,l) int(Rnd*((l+1)-(f))+(f))

Sub backdrop()
    #macro paintsketch(_function,minx,maxx,miny,maxy,r,g,b,alp)
    For x As Double=minx To maxx Step (maxx-minx)/10000
        Var x1=(xres)*(x-minx)/(maxx-minx)
        Var y1=(yres)*(_function-maxy)/(miny-maxy)
        gr=(lasty-y1)*1000
        lasty=y1
        If gr>g Then gr=g
        Line im,(x1,yres)-(x1,y1),Rgba(r,g-gr,b,alp)
    Next x
    #endmacro
    for n as long=0 to 500
        var x=intrange(0,xres),y=intrange(0,yres)
        pset im,(x,y)
        next n
    line im,(0,.8*yres)-(xres,yres),rgb(0,0,100),bf
    Dim As Double lasty,gr
    paintsketch(.8*yres+20*Sin(.01*(x-200)),xres,0,yres,0,50,100,0,255)
   ' trees()
End Sub

Sub rotateimage(Byref dest As Any Ptr=0,im As Any Ptr,angle As Single,shiftx As Long=0,shifty As Long=0,sc As Single=1,miss As Ulong=Rgb(255,0,255),fixedpivot As boolean=false)
    Static As Integer pitch,pitchs,xres,yres,runflag
    Static As Any Ptr row,rows
    Static As Integer ddx,ddy,resultx,resulty
    Imageinfo im,ddx,ddy,,pitch,row
    If dest=0 Then
    Screeninfo xres,yres,,,pitchS
    rowS=Screenptr
    Else
    If sc<>1 Then
        Dim As Integer x,y
        Imageinfo dest,x,y
    Imagedestroy dest:dest=0: dest=Imagecreate(x*sc,y*sc)
    End If
    Imageinfo dest, xres,yres,,pitchS,rows
    End If
    Dim As Long centreX=ddx\2,centreY=ddy\2
    Dim As Single sx=Sin(angle)
    Dim As Single cx=Cos(angle)
    Dim As Long mx=Iif(ddx>=ddy,ddx,ddy),shftx,shfty
    Var fx=sc*.7071067811865476,sc2=1/sc
    If fixedpivot=false Then
     shiftx+=centreX*sc-centrex
     shiftY+=centrey*sc-centrey
     End If
    For y As Long=centrey-fx*mx+1 To centrey+ fx*mx
        Dim As Single sxcy=Sx*(y-centrey),cxcy=Cx*(y-centrey)
        shfty=y+shifty
        For x As Long=centrex-mx*fx To centrex+mx*fx
                 If x+shiftx >=0 Then 'on the screen
                    If x+shiftx <xres Then
                        If shfty >=0 Then
                            If shfty<yres Then
            resultx=sc2*(Cx*(x-centrex)-Sxcy) +centrex:resulty=sc2*(Sx*(x-centrex)+Cxcy) +centrey
                If resultx >=0 Then 'on the image
                    If resultx<ddx Then
                        If resulty>=0 Then
                            If resulty<ddy Then
    Dim As Ulong u=*Cast(Ulong Ptr,row+pitch*((resultY))+((resultX)) Shl 2 ) 'point(image)
   If u<>miss Then *Cast(Ulong Ptr,rowS+pitchS*(y+shifty)+(x+shiftx) Shl 2)= u 'pset (screen)
                End If:End If:End If:End If
                End If:End If:End If:End If
        Next x
    Next y
End Sub
Sub move(byref sh as single,byref sv as single,byref a as single)
    static as long f
    #macro tendangle
    if a>0 then a-=.001 else a+=.001
    #endmacro
    If Multikey(75) Then f=1' r
    If Multikey(77) Then f=2' l
    If Multikey(80) Then f=3'up
    If Multikey(72) Then f=4'down
    if f=1 then sh+=1:a+=.001
    if f=2 then  sh-=1:a-=.001
    if f=3 then sv+=1:tendangle
    if f=4 then sv-=1:tendangle
    if f then message=""
End Sub

 Function Regulate(Byval MyFps As Long,Byref fps As Long=0) As Long
            Static As Double timervalue,_lastsleeptime,t3,frames
            Var t=Timer
            frames+=1
            If (t-t3)>=1 Then t3=t:fps=frames:frames=0
            Var sleeptime=_lastsleeptime+((1/myfps)-T+timervalue)*1000
            If sleeptime<1 Then sleeptime=1
            _lastsleeptime=sleeptime
            timervalue=T
            Return sleeptime
        End Function

backdrop

screen 19,32
dim as single sh,sv,startx=-400,starty=-500,a

do
    screenlock
    cls

move(sh,sv,a)
rotateimage(,im,a,startx+sh,starty+sv,1.2)
draw string(400,300),message
screenunlock
sleep regulate(60)
loop until inkey=chr(27)
sleep
Stonemonkey
Posts: 649
Joined: Jun 09, 2005 0:08

Re: Squares

Postby Stonemonkey » Aug 21, 2020 11:29

I think we're more somewhere between the Klingons and the ferengi than we are the humans of the star trek universe.
Who knows, perhaps musks martian settlements will break away from capitalism and division.
deltarho[1859]
Posts: 2698
Joined: Jan 02, 2017 0:34
Location: UK

Re: Squares

Postby deltarho[1859] » Aug 21, 2020 11:44

There is no such thing as pure-communism; we simply have communism. Russia and China employ manifestations of communism; political thought transformed into reality via politics as defined by one or more interpreters. There is no such thing as pure-fascism either; we simply have fascism.

So, albert, you are talking political thought and not politics. Star Trek is not one vision of our future - it is a TV show designed to make profit and has done quite well at doing just that.
albert
Posts: 5916
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Postby albert » Aug 21, 2020 21:07

With my idea for communism..

All you would have to do is go to work somewhere for 6 to 8 hours a day , and then you can have anything you want for free..

Free houses
Free cars
Free medical , dental , prescriptions etc..
Free appliances
Free furniture
Free college education
Free jewelry
Free vacations
Free hotel stays
Free air-fare

Start a business for free...

Pharma companies could develop medications for rare diseases.. It currently costs like 1 billion to develop a new drug or vaccine.
The U.S. govt has paid several ( 15 ) billion , to companies to develop a covid-19 vaccine...

You couldn't tell a pauper from a king... They both could have anything they want...

GM the big American car maker , has a plant in Cleveland Ohio.. It's all robots.. They build all the seats for all GM cars and trucks.
The robots build and sew the seats.. There are no employees except for the engineers and robot techs and plant maintainance..
So most companies would not need employees.. robot and machines could do all the labor..

Then humans would be pushed into other fields , rather than assemblers..
albert
Posts: 5916
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Postby albert » Aug 21, 2020 22:07

I came up with another idea...

Instead of solder on the circuit boards...

You use a nail-polish , embedded with a conductor , like lead or copper or gold..
Then you can easily remove the chip , by using a Q-Tip of nail-polish remover..

It would make installing surface-mount chips easy..
You just brush each contact with the nail-polish , then stick it on the board..

I'm an electronics tech.. And always had problems , with surface-mount chips.. soldering and de-soldering..

Start a company making conductive nail-polish!!!
It would replace lead based solder.
albert
Posts: 5916
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Postby albert » Aug 22, 2020 1:14

With my idea on communism..

There wouldn't be any monetary crimes... which accounts for most criminal prosecutions..
Credit card fraud , counterfeiting , check fraud , robberies.. no monetary crimes would exist..

Drug dealers could have any thing they want for free , so they wouldn't be dealing drugs..
No one has any money , so they couldn't buy drugs..
If everyone could have anything they want for free , there would be no bartering for drugs..
Drugs would be shared among confidants.. For free.. So there would still be drugs around but they would be sparse and free..

I don't know if there would be prostitution , as the women couldn't get paid.. so they wouldn't give up sex for free..

It would solve most of the earths problems...

There wouldn't be any civil lawyers or insurance companies or stock markets or banks..
No child support or alimony etc...
No lotteries or gambling..

All the crimes would be city or county , code violations.. rapes and assaults and murders..

Children can go online and order all the toys they want for free... So could their parents.. Everyone would be spoiled..
dodicat
Posts: 6726
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Squares

Postby dodicat » Aug 22, 2020 13:11

I think that was pretty much how America used to be before the European settlers arrived.
You would have made a good native American Albert.
You can resume your journey across America and settle down among folk of like mind.

There are loads of people across the world with similar ideas.
https://en.wikipedia.org/wiki/List_of_anarchist_communities

Return to “General”

Who is online

Users browsing this forum: No registered users and 11 guests