Search found 3824 matches

by BasicCoder2
Mar 12, 2024 22:23
Forum: Sources, Examples, Tips and Tricks
Topic: The Travelling Salesman Problem
Replies: 21
Views: 977

Re: The Travelling Salesman Problem

@dodicat I wondered how well you could figure out the shortest path by visual inspection. The human eye is very good at clustering. So I modified your code as I was too lazy to write my own version hope you don't mind. I added a function drawLine() so by clicking each point you could join them up wi...
by BasicCoder2
Mar 09, 2024 19:36
Forum: Sources, Examples, Tips and Tricks
Topic: The Travelling Salesman Problem
Replies: 21
Views: 977

Re: The Travelling Salesman Problem

Both the circle and nearest town algorithms get pretty good results.
by BasicCoder2
Mar 09, 2024 17:28
Forum: Sources, Examples, Tips and Tricks
Topic: The Travelling Salesman Problem
Replies: 21
Views: 977

Re: The Travelling Salesman Problem

@dodicat Many years ago (1984), my late wife and myself and our small dog took a long Summer break in our towing caravan. We ended up near London, and parked up in a site by the edge of Epping forest. My wife got a temporary job, at her trade as bookkeeper, in Woodford Green, I took a job as a milkm...
by BasicCoder2
Mar 09, 2024 0:03
Forum: Sources, Examples, Tips and Tricks
Topic: The Travelling Salesman Problem
Replies: 21
Views: 977

Re: The Travelling Salesman Problem

I have modified Lothar Schirm's code to having a fixed number of towns and when the program is exited the town locations are saved as data statements in townsData.bas to be copied pasted into another version which reads the locations rather than making a new random selection. This data set can be us...
by BasicCoder2
Mar 08, 2024 17:05
Forum: Sources, Examples, Tips and Tricks
Topic: The Travelling Salesman Problem
Replies: 21
Views: 977

Re: The Travelling Salesman Problem

Lothar Schirm A brute force approach rapidly becomes unsuitable as the number of cities increases. I was just curious what the current AI would generate. I asked for a fast good enough solution for the traveling salesman problem and it comes up with your nearest neighbor solution. I added the graphi...
by BasicCoder2
Mar 08, 2024 6:52
Forum: Sources, Examples, Tips and Tricks
Topic: The Travelling Salesman Problem
Replies: 21
Views: 977

Re: The Travelling Salesman Problem

Just for fun I asked AI to generate a solution. I had to modify the solution to make it work and add graphics to display the city layouts. 'MODIFIED CODE GENERATED BY https://deepai.org/chat 'This code generates random cities with x and y coordinates, computes the 'shortest path through all cities u...
by BasicCoder2
Mar 07, 2024 11:28
Forum: Sources, Examples, Tips and Tricks
Topic: The Travelling Salesman Problem
Replies: 21
Views: 977

Re: The Travelling Salesman Problem

Lothar Schirm Works ok for me? When I hit the space bar once I get the circles (towns). Hit the space bar again straight lines join up the towns from red to green circle. Hit the space bar again and another random number of towns at random positions appear. Hit the space bar again and they join up. ...
by BasicCoder2
Feb 04, 2024 21:48
Forum: Sources, Examples, Tips and Tricks
Topic: Free ChatGPT
Replies: 12
Views: 645

Re: Free ChatGPT

@neil Thanks for these links to ai chat it has been fun. I thought I would search for links on how these programs could write code from a description and then thought why not ask the AI :) It didn't actually explain how it was done in any detail only that it was done using predefined templates and a...
by BasicCoder2
Feb 04, 2024 8:18
Forum: Sources, Examples, Tips and Tricks
Topic: Free ChatGPT
Replies: 12
Views: 645

Re: Free ChatGPT

@neil It amazes me. Until now I haven't really tried it myself as you had to sign up first. Although its responses may only be something to work from it seems promising in the future. I asked it for code for another problem without mentioning the language and it gave me a Python example. I read that...
by BasicCoder2
Feb 04, 2024 7:25
Forum: Sources, Examples, Tips and Tricks
Topic: Free ChatGPT
Replies: 12
Views: 645

Re: Free ChatGPT

How is it able to do that? !!! This is what it gave me, #include "fbgfx.bi" #include "math.bi" const SCREEN_WIDTH = 800 const SCREEN_HEIGHT = 600 dim as integer asteroid_size = 10 dim as integer asteroid_x = SCREEN_WIDTH / 2 dim as integer asteroid_y = SCREEN_HEIGHT / 2 dim as i...
by BasicCoder2
Jan 24, 2024 23:49
Forum: Sources, Examples, Tips and Tricks
Topic: ANT SIMULATIONS
Replies: 3
Views: 336

Re: ANT SIMULATIONS

@badidea When I watched real ants in the foraging mode (going around and around an area) I marked their paths and saw squiggles. it seems a probability thing where the most probable is forward and varying degrees of veering left or right but the sharper the turn the less likely it happens. When my s...
by BasicCoder2
Jan 24, 2024 19:12
Forum: Sources, Examples, Tips and Tricks
Topic: ANT SIMULATIONS
Replies: 3
Views: 336

ANT SIMULATIONS

Simulating an ant colony first requires learning about how real ants behave. Ants have different behaviors but here I have started with a simple version of a foraging behavior. When foraging for food ants don't just walk randomly they meander (like a river) in a systematic way. To simulate this I ma...
by BasicCoder2
Jan 22, 2024 5:36
Forum: Sources, Examples, Tips and Tricks
Topic: Fish aquarium
Replies: 18
Views: 1168

Re: Fish aquarium

@neil So are you interested in writing some computer game? I played around with bits and pieces required to write computer games but it was more of a puzzle solving exercise then any real outcome. I don't actually play computer games myself. In my day it was the C64 not the Atari. I did some game li...
by BasicCoder2
Jan 22, 2024 0:15
Forum: Sources, Examples, Tips and Tricks
Topic: Fish aquarium
Replies: 18
Views: 1168

Re: Fish aquarium

Sprites do have an advantage in that they look nice, animation is simpler and overlap is easier to implement. Here is my take on using the graphic commands to draw the fish. I have drawn the collision rectangle around each fish however this can be commented out. 'some useful defines Const Pi = 4 * A...
by BasicCoder2
Jan 21, 2024 9:53
Forum: Sources, Examples, Tips and Tricks
Topic: Fish aquarium
Replies: 18
Views: 1168

Re: Fish aquarium

neil wrote: How could the code be changed so the fish can't swim backwards? You need two drawings, one for a fish moving left and one for a fish moving right. FreeBasic allows you to make use of bitmaps so you could use images. Here is a program that creates two images, one with a fish looking right...