Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6330375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:51:32+00:00 2026-05-24T17:51:32+00:00

I would like to code a genetic algorithm that learns to play a game

  • 0

I would like to code a genetic algorithm that learns to play a game similar to Tetris.
The game itself is relatively simple; I have written the full behaviour of it below.

The game:

  • Grid based, 12×16.
  • You must clear blocks from the grid.
  • A row of new blocks is added every 5 ticks, to the bottom, pushing the blocks up.
  • You can only clear clusters of the same type block.
  • The number of types of block increases as the game goes on.
  • You can only clear clusters of 3 or above.
  • For every cluster cleared, (CLUSTER_SIZE - 3)^2 is added to BLOCK_SCORE.
  • After a cluster has been removed from the grid, blocks above slide down to fill the gaps, and if there are any horizontal gaps (On the bottom row) after this, the left side of the gap moves over to fill it.
  • The goal of this game is to survive as long as possible. Time is measured in ticks, or the number of moves that you have made.
  • Your score (or Fitness) is determined by (TIME_ALIVE * BLOCK_SCORE)
  • The game is over once a block reaches the top of the grid.

The score of this game incorporates both longevity and efficiency. The larger the clusters that you clear, the higher the fitness is.

I have coded a few GAs now, but they have been based on local competition, things like collection goals and the like, VS other individuals.
My problem is that I don’t know how to approach this problem. Each different individual of this new GA should have only the current grid to work on as input. (At least, that’s what I think would be needed)

How can I begin to code the GA for this? I cannot for the life of me work it out.

.

Thanks all,

Steffan ‘Ruirize’ James

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:51:34+00:00Added an answer on May 24, 2026 at 5:51 pm

    Each individual in your population would represent a game played to completion. The attributes of each individual would be parameters necessary to define a given strategy for placing the blocks down. I’m assuming you have a couple of different heuristics for placing a block. One example of a strategy would be to select a heuristic at random from the available strategies so your attributes would be a set of probabilities that a given heuristic is chosen. Can you provide more information on the block k placement heuristic you have?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like a code sample for a function that takes a tDateTime and
I have the following snippet where I would like to extract code between the
I would like to create (in code) tree of controls that would render as
I have some configuration data that I'd like to model in code as so:
I have written a module that has some generic, reusable code that I would
Hi i have the following code which i would like to convert to C#.
I have a method that returns byte[] but for now would like to avoid
I have a weighted choice algorithm that works, but I'd like to improve it
To help users, I would like my code to discover Oracle databases on the
in my code i would like boost::shared_ptr not to call delete but call ptr->deleteMe()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.