Hi to everyone...
I am told to code a Schelling's Segregation Model simulation in C++ . This is about agent simulation and let me explain shortly what it is wanted:

* There is a place like the chessboard (8*8)
* there are 2 kind of people , the X and the O
* place randomly 20 X and 20 O , with no overlapping.
* there is no runaway from the board. (i mean, at the end, still will be 40 people and 24 empty cells.
* Then you should move someone to somewhere randomly, that at least there will be 3 agents with the same type (x or O).
* I mean, a agent will be happy if it has at least 2 neighnours. else, it will change its position till it can found a place with at least 2 other neighbours.
* the program will just run and print to a file.

I coded nearly all the needed things, but confused what to do next when i come to deciding of the moving process.

Now, I look at the [0][0] th cell, if there is an agent there, then I look to its neighbours. just like Linked lists, a data called m_pNext is used in the class of agent. It will mimic like list, and will show its next agent. I set something to next, but i dont know how i will decide this for all of the agents.

plz give me a way about this confusion. Which way can be the sortest?
I run this code in mingw developer studio, known as a g++ compiler.

code is attached, and one result text file.

Thanks

Recommended Answers

All 2 Replies

Member Avatar for iamthwee

Looks like the game of life, of some sort. Personally, I'd say you're over complicating this with linked list.

Basic arrays is all you need.

Looks like the game of life, of some sort. Personally, I'd say you're over complicating this with linked list.

Basic arrays is all you need.

sure an array is enouhg but, this is what is wanted.

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.