Seeking Assistance: Resource Configuration and Individual Movement Challenges

I need help for a project in which I don’t know how to proceed, I’ll show you what I’m trying to do and the problem as well as the code.

Game board:
The game board is a matrix, of NxM positions.
Individuals and resources occupy a position in the matrix.
A position in the matrix can have 3 resources and a maximum of 3 individuals at a time. If at any time there are more than 3 individuals in a cell, those with the lowest number of life turns left will die until there are 3 individuals left.
Individuals:
The individuals in the game occupy a single square, and have as parameters:
• Individual Identification: A unique number that identifies the individual.
• Generation of the individual: Obtained according to the turn in which it was created.
• Turns of life left: Number of turns where you can continue developing.
• Probability of reproduction: If 2 individuals occupy the same position in the matrix, they either reproduce, generating another individual, or both die.
• Probability of cloning. At each step, an individual can clone themselves, and the clone will appear at the same position on the map.
• Probability of death = (1-Probability of reproduction).
The initial values ​​of the “type individual” must be parameterizable for the game.
We will have 3 types of individuals:

  1. Basic type: moves randomly.
  2. Normal type: moves in a straight line towards a resource in the environment (selected
    randomly from those available).
  3. Advanced type: is able to make routes to the position of resources and select the resource they want to go to (the closest one that is not in the individual’s current position).
    About individuals and reproduction:
    • The reproduction of two individuals of the same type gives rise to another individual of that type.
    • Reproduction of individuals of different types gives rise to another individual of the highest type at X percentage of game population improvement.
    On each turn, the individual will be modified as follows:
    Life goes down 1 turn.
    The probability of reproduction drops by 10% of what the individual has at that moment.
    The probability of mutation drops by 10% of what the individual has at that moment.
    In a turn an individual MUST move.
    Environment/resources
    The environment models how the resources in it allow an individual to alter the values ​​of its parameters. The environment is associated with static positions on the game board.
    We will have 6 types of environment elements (at least).
  4. Water, 2. Food, 3. Mountain, 4. Treasure, 5. Library, 6. Well
    To simulate an evolving environment, each element of the environment has a spawn time when it will be active and visible on the map. Each position on the map can have a maximum of 3 resources at a given time: If a position has less than 3 resources, a new one can appear each turn with probability Z, parameterizable for each resource with probability V, adjustable in each game.
    (Example: on turn 3 the position (4,5) has a Water resource, with an appearance time of 3. On that turn it is evaluated if a new resource can appear, to choose from the 6 possible. The calculation will use the probability Z to know if a new resource should appear or not, and if the result is positive, then the probabilities V of each type of resource will be used to choose the one that will finally appear.)
    These elements of the environment will act as modifiers to the individual’s parameters: For example, Water will add 2 turns of life to the individual, Food 10 turns of life, and Mountain will decrease 2 turns of life, Treasure will increase the reproduction probability of the individual. individual by X%, while the Library will increase the cloning chance by Y% and increase the individual’s type, with the Well being instant death.
    All values ​​must be parameterizable for the game.

Control loop:
The control loop will perform the game operations in order:

  1. For each individual, their lifespan is updated, and if applicable it is eliminated if they have died.
  2. For each resource, it will evaluate whether it is still active or should be deleted (due to its appearance time).
  3. The movement of each individual will be executed (always mandatory).
  4. For each individual, the improvements obtained by the different resources found in their new position will be evaluated.
  5. For each position, it will evaluate whether there is reproduction or not.
  6. For each individual, it will evaluate whether cloning exists or not.
  7. For each position on the board in which there are several individuals, it will be evaluated whether some should disappear.
  8. For each position on the board, it will be evaluated whether new resources should appear.
    Termination condition:
    Only one individual remains alive or the user decides to end the simulation.
    After the game:
    The breeding tree of the winning item(s) (if such items exist) should be displayed, showing their family tree.

I have several problems: I can’t configure it so that only 3 resources appear in a cell, and no more than 1 of the same type.
Only individuals of type 1 make the correct movement, but not those of type 2 and type 3.

New contributor

Pepito Ruiz is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật