Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ help code: C++ task: implement Conways Game of Life using vector basics. The grid is then transformed at regular intervals with each cells state

C++ help code: C++ task: implement Conways Game of Life using vector basics. The grid is then transformed at regular intervals with each cells state being updated according to the following set of simple rules:

  1. If a live cell has fewer than 2 neighbors, it dies (underpopulation).
  2. If a live cell has more than 3 neighbors, it dies (overpopulation).
  3. If a dead cell has exactly 3 neighbors, it becomes alive (reproduction).

I would like some help with this. can you tell me how to make a vector of a world and change it base on these rules? not really understanding the codes for vector basics.

I got this code to start out the world but im not sure if this is a easy way of doing it or what.

vector > world = { {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0}, {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} };

am i suppose to apply the rules to the vector, write the result to standard output? if so how am i suppose to do it? and explanation would help

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions