Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Anyone done any research into a self playing Tetris game?

Years of Service
User Offline
Joined: 5th Mar 2007
Posted: 14th May 2023 07:35
I have recently become interested in this. I am a pretty good tetris player, and it would be interesting to try and convert the skill of a person, into code !
Years of Service
User Offline
Joined: 5th Mar 2007
Posted: 20th May 2023 19:10
ChatGPT's idea lol... Master of stating the obvious !

As an AI language model, I am not capable of directly writing computer programs in a specific programming language, but I can provide a general outline of how a self-playing Tetris computer program could be created using BASIC language.

Initialize the game board with empty spaces and a score of zero.
Create a loop that will continue until the game is complete (i.e., when a block cannot fit onto the board).
Randomly generate a Tetris block and place it at the top of the board.
Create a nested loop to simulate the block falling. Move the block down one space at a time until it reaches the bottom of the board or collides with another block.
At each position of the Tetris block, simulate the placement to see if it fits on the board without colliding. If the block fits, keep track of the score and move to the next block.
If the block collides with another block or goes off the edge of the board, exit the nested loop and move to the next block.
Once all blocks have been placed on the board, end the game and display the final score.
This is just a basic outline, and there is much more detail that would need to be filled in. Additionally, BASIC language may not be the best choice for creating this type of program as it may lack some of the necessary functionality and control structures.
Derek Darkly
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 21st May 2023 18:21 Edited at: 21st May 2023 18:24
I find this sort of thing intriguing...
As far as the "thinking" part of the code, obviously it could be programmed to where the AI never lost, but if you're looking to include room for human-like error, I would consider how quickly the AI would be allowed to think.

Since the loops of a program happen very fast from a human perspective, the AI could be forced to "sit out" for a random number of milliseconds or loops in order to produce a delayed effect in its performance, as time is of the essence in a game like Tetris. You could also include a random roll to cause the AI to make mistakes, which combined with the time constraints could produce human-ish gameplay.
Send your parents to noisy sprite demo hell... enter the D-Zone
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 22nd May 2023 22:19
ChatGPT has just described what Tetris is., not the "Self-Playing" element... and did it seem to believe BASIC isn't "Good Enough" to make Tetris? Seem a little conceited.
In any case...

There are various approaches to mimicking Human Players.
Now as far as Tetris is concerned it's _actually_ a much to write an AI capable of playing "like" a Human.
This is because the decision variables are limited.

Move Block Left
Move Block Right
Rotate Block
Speed Up Block

And the course of action will be based upon an Nth Step in the Future... i.e. "I want this Block at X in Y orientation" then those moves are based upon reaction speed of the individual., which is going to be between 60 - 250ms per Move.
The hardest part would be analyzing the possible solutions (i.e. how you COULD potentially have the block land) then give each of those possible solutions a weight based upon "Most Adventageous"., ignoring under certain values depending on the "Player Skill" then performing a Fuzzy Logic Decision; that is to say, we build a common pattern array; which would trend towards a certain kind of solution... then perform a Wave Function Collapse between the two Solution Arrays.
What we'd be left with is a guaranteed solution based on "Personality" but would appear Randomised to an Observer.

This would echo Human-Like behaviour.
As noted, achieving this with Tetris is easier *because* it's simple and isn't based on a Second-by-Second Decision making process but instead like Chess you're looking X Moves ahead to the Solution *YOU* (or in this case the AI) wants.
By adding in the Reaction Speed, this adds to the apparent skill will also meaning various solutions despite being "Correct" or "Best" will be failed BECAUSE the Thinking-Reaction Time is too high to perform the necessary moves.
If we also add in that Moves can "Fail" (i.e. incorrect positioning) using a multi-pass randomisation using a sequence of varying value ranges (and if said ranges can't be multiplied or divided evenly the better) as this will give a sense of Human-Error.
The failure itself could also be random, be it moving too much, too little, over rotation or deciding the "2nd Choice" was a better option and then recalculating the movement for that.

In-fact arguably indecision about which move to make will add the most "Human" element to it., as every second a chance can be rolled for "Right Move?" as a second guessing; and should it ever pass moves on to the second highest option in the waveform.
Waveform Collapse Functions are exceptionally useful for Fuzzy Logic and Procedural Generation.

And you could over-time build a personality by storing past decisions and weighting them., as this would give "style" to how the AI will play in later games.
Years of Service
User Offline
Joined: 5th Mar 2007
Posted: 23rd May 2023 23:57
I think it was saying it couldn't write something in ANY specific language. Pity it couldn't write something in ANY language lol, not even my fave...pseudo code

Anyhoo thanks for those ideas, I just think it would be nice to have a self playing form of Tetris running.

Actually I don't intend it to be real, lines wont disappear and there will be no score or time limit(blocks wont drop on their own) Other than those things I am still considering it

Login to post a reply

Server time is: 2024-02-25 10:56:32
Your offset time is: 2024-02-25 10:56:32