473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to write a c program to generate a self avoiding walk in 2-D?

a self-avoiding walk (SAW) is a sequence of random moves, on a
2-D lattice that does not visit the same point more than once.
program should be written to calculate the average of walks moved on 2-D lattice.
picture attaced shows the self avoiding walk in 2-D.
Attached Images
File Type: jpg 600px-Self_avoiding_walk_svg.jpg (467 Bytes, 768 views)
Jul 3 '10 #1
3 5283
weaknessforcats
9,208 Expert Mod 8TB
Exactly what is your question?
Jul 3 '10 #2
as we write a program to generate a random walk in 2D, here to write a program to generate a self avoiding walk in 2D.
i hope you know about self avoiding walk, its just a random walk for N(as required) steps but not to come to a point more than once.
and then calculate the average displacement in walking N steps.
please help me to write this program.
Jul 4 '10 #3
weaknessforcats
9,208 Expert Mod 8TB
Start by defining an array that maps your walking space.

When you walk to a location [x][y], mark the [x][y] location in your array. That way when you move you can check the array to see if you have been there before.

If your walking area is like a crossword puzzle with blacked out squares, then when the program starts you can initialize your array and mark locations where there are walls. You use a different value here so you can tell the squares where you have been from the walls and from the square you have not visited.

Then write a move function. You supply a start location and a direction. If the move is OK the function returns success. If you have reached the destination, the function returns finished. If a wall or you have been there before, the function returns blocked.

You should now be able to steer this function from inside a loop to navigate from a start location to an end location avoiding walls and squares already visited.
Jul 4 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Simon Wigzell | last post by:
I recently wrote a program with MS Visual Studio C++, sent it off to the client where it didn't run, after some probing I discover they are on a Mac! My program is a MSF interface that is really...
3
by: simon lee | last post by:
Dear all, I use VC++ to write a program for display a flash file "file.fla", However, for displaying flash file, it sometimes become black screen and sometimes cannot display the corresponding...
9
by: Kenneth McDonald | last post by:
I have a module I'd like to document using the same style... Thanks, Ken
22
by: Saurabh Saxena | last post by:
can we write the program to write no 1 to n without using switch,do,while,for,goto,if and conditional operator where n will be input by user.
0
by: Tom | last post by:
I am new to hardware programming. I need to write a program for reading data from Card Reader which connects to the PC windows 2000/XP OS through Interfacing The Serial / RS-232 Port / USB /...
2
by: shaveta | last post by:
The problem is like this:- A maze is a rectangular area, with m rows and n columns, with an entrance and an exit. The interior of the maze contains obstacles. The entrance is at the upper-left...
1
by: shilkigupta | last post by:
plz write a program to print 4 4 3 4 4 3 2 3 4 4 3 2 1 2 3 4 4 3 2 3 4 4 3 4 ...
1
by: Paul Lemelle | last post by:
I Am trying to output the os.path.walk to a file, but the writelines method complains.... Below is the code, any helpful suggestions would be appreciated. def visit(arg, dirnames, names):...
0
by: Jeff McNeil | last post by:
Your args are fine, that's just the way os.path.walk works. If you just need the absolute pathname of a directory when given a relative path, you can always use os.path.abspath, too. A couple...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.