473,804 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Now a tricky one ;-)

Consider this 3d vector:

const SIZE = 'some_size';
std::vector<std ::vector<std::v ector<char> > >GRID(SIZE,
std::vector<std ::vector<char> >(SIZE,
std::vector<cha r>(SIZE)));

It can be viewed as coords for SIZE^3 different points in a 3d space:
Now, instead of point consider Cubes.
They each have 6 sides:
front - z+
back - z-
top - y+
bottom - y-
rigth - x+
left - x-
(+/- being direction on the axis)

Each of the 6 sides can be turned on/off so you get like a 3d
labyrinth.

And now for the tricky part:
1.
No point/cube can be completely closed, i.e. the sum of the 6 bit
defining it must be < 6 or if you and the bits the result must be 0,
ect.
allso consider only using 3 bits to define each point/cube in the grid.
2.
There must be away from any given point/cube to another.
To help this the cube is infinite/finite, what i mean is best shown
with an example:

The Grid is the size of 16^3
Sudenly you find your self at point 17,17,17 (x,y,z) how ever it is no
problem bacause the point is allso defined as 1,1,1 (x,y,z)
Now only one question remains...
How to do it the easy way?
Hope to get some mindblowing ideas... ;-)

Feb 2 '06
14 2049
fe**********@ho tmail.com wrote:
Now nothing, thats all finish, fin, fini, i just need a way to build
this system and a way to hold the information, i have thought alot
about it and think its a pretty hard task.
So you are just interested in representing the data. What about:

struct Labyrinth {

unsinged Size = 16;

std::bitset< Size*Size*Size > xy_doors;
std::bitset< Size*Size*Size > xz_doors;
std::bitset< Size*Size*Size > yz_doors;

};

Here a bit in xy_doors at position Size*Size*a+Siz e*b+c represents a door in
horizontal position at location (a+0.5,b+0.5,c) , this is the midpoint of a
unit square. The rules for xz_doors and yz_doors are analogous.

This uses exactly one bit per door with little to no overhead from
std::bitset.
ofcourse i have other ideas
too, fx. what to use it for, but i dont think thats important right
know, just think about it as a big 3d labyrint.

Best

Kai-Uwe Bux
Feb 2 '06 #11
Geo

fe**********@ho tmail.com wrote:
I thought i did enough explaining,


No you haven't, are the 'walls' between adjacent cubes shared, or does
each cube have it's own wall. If the wall of one cube is missing, does
the adjacent wall need to be missing also ?

Feb 2 '06 #12
<fe**********@h otmail.com> wrote in message
news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
: Consider this 3d vector:
:
: const SIZE = 'some_size';
: std::vector<std ::vector<std::v ector<char> > >GRID(SIZE,
: std::vector<std ::vector<char> >(SIZE,
: std::vector<cha r>(SIZE)));
....
: Each of the 6 sides can be turned on/off so you get like a 3d
: labyrinth.
....
: How to do it the easy way?

First of all, pick a data structure that will avoid redundancies
and ease manipulation.
I would use 3 independent arrays for each 'communication face',
as suggested by Kai-Uwe, or a single 3D vector with a bit for
the x+, y+ and z+ faces (only) -- i.e. if you look for x- you
check the value of the neighboring face.
You probably don't need to bother compressing data to less
that a char per 'cell', in my opinion. Unless it is known
that memory usage is of essence, I would even use a struct.
<<radix omnia malorum prematurae optimisatia est>>

The labyrinth generation itself is a very classic problem.
It is easy enought to 'march' by opening doors from each
cell that is totally closed until you reach an existing 'cave'.
Generation strategies can vary, for example you may want
to have more or less 'branching' in your labyrinth.
Give it a search, or ask in a non-language specific newsgroup.

: Hope to get some mindblowing ideas... ;-)
The devil is in the details.
Give it a try and post some code to get feedback if you wish.

Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <> http://www.brainbench.com
Feb 2 '06 #13
fe**********@ho tmail.com wrote:
Now nothing, thats all finish, fin, fini, i just need a way to build
this system and a way to hold the information, i have thought alot
about it and think its a pretty hard task. ofcourse i have other ideas
too, fx. what to use it for, but i dont think thats important right
know, just think about it as a big 3d labyrint.


Please start quoting in a usenet standard manner, so you don't look
like a Google newbie idiot. See instructions below.

Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Feb 2 '06 #14
can't you realize He is a homework kiddie?

Feb 7 '06 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2163
by: Lars Plessmann | last post by:
Problem: I try to store data in a objects field and read it out again. Sounds easy, yeah. But its a bit tricky here.... ;-) This is the class Customer.php with some setter and getter functions to store customers data within an object. It works. Furthermore, it includes a synchronize method, which calls the individual setXXX function and takes the data from the $_POST or $_GET var.
0
595
by: dracolytch | last post by:
Good day all, Ok, I have a pretty tricky problem that I need some help with. I pass around search query information a fair amount (specifically WHERE statements). Normally, I just rawurlencode() the buggers, and pass them via the URL. I like having the where clauses in the URL, because then someone can just bookmark the URL, or send it to a friend, and I don't have to worry about a thing. If someone does a search that requires a LIKE...
1
13780
by: JZ | last post by:
Oracle 9iR2 I have a table: SQL> select * from test; A B C ------------------- ---------- ---------- 01/01/2004 10:00:00 1 1 01/01/2004 11:00:00 1 2
4
1913
by: Bung | last post by:
Hi, I have a tricky sql statment I have to write (tricky for me) and I am stuck. I'm having trouble with the following problem. Table1 (Column a, Column b, Column c) Table2 (Column a, Column b, Column c) Table3 (Column a, Column b, Column c) Table1 contains a row of value (1, 2, 3)
4
1478
by: Angel Cat | last post by:
I have 2 tables joined together by the IDs, People and the pets they own PEOPLE ID NAME 1 JohnSMith 2 JaneDoe PETS ID PET
25
3414
by: PyPK | last post by:
What possible tricky areas/questions could be asked in Python based Technical Interviews?
5
1637
by: Danny | last post by:
Hi there I need help with a tricky problem. I have a 2 dimensional array with qualities such as ball size, ball color, ball weight. Now I have to print out all the possible combinations of this. assume I have it stored as such i have two dimensional array ball:
8
1885
by: pras.vaidya | last post by:
Hi , below given question was asked to me during an interview and i figured it out little tricky . It would be a great help if anyone could solve it. Code : - main() { char *s1="abcd",*s2=NULL; /* From here you call a function copy which has return type void .
7
15096
by: NileshKorpe | last post by:
Can you please send me link of some c++ tricky (confusing) questions usually asked in the c++ technical interview. Thank You
1
1507
by: MorrganMail | last post by:
Or at least I find it tricky. :-) Assume we have three tables A, B and C. Table A contains a path and the distance for traveling that path: A (PathId, NodeId, Dist (from previous node)) 1, 1, 0 1, 2, 10 1, 3, 5
0
9711
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9593
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10335
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.