uglemat / matris Goto Github PK
View Code? Open in Web Editor NEWA clone of Tetris made using pygame
Home Page: http://www.pygame.org/project-MaTris-2827-4552.html
A clone of Tetris made using pygame
Home Page: http://www.pygame.org/project-MaTris-2827-4552.html
Hi Uglemat,
Sorry if this is the wrong place to post a question.
I'm trying to place Tetrominoes through an AI agent I'm creating for a project.
At the moment I'm just trying to implement a random placing of pieces) but I'm struggling to place them.
I've created my own representation of the board, which the agent uses to judge where is a placeable location.
Say the board already had the following block placed in the bottom corner:
[O,X,O]
[O,X,O]
[X,X,O]
And the block had been rotated once in the bottom corner, the board representation would show as the following:
[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, 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]
[1, 1, 1, 0, 0, 0, 0, 0, 0, 0]
My random agent then looks for potential valid placements and concludes that an 'S' block could be rotated twice to produce:
[0, 0, 0]
[0, 1, 1]
[1, 1, 0]
And concludes that it can be placed in column 5 at height 21 to produce the following board:
[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, 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, 1, 1, 0, 0]
[1, 1, 1, 0, 0, 1, 1, 0, 0, 0]
To try and get the board to place this here, I use the following commands:
(tetromino_placement[1],tetromino_placement[2])
self.tetromino_position = (y_axis_value,x_axis_value)
self.tetromino_rotation = 2
I was expecting this to work, however I get the following errors:
Traceback (most recent call last):
File "/home/JRINGRAM//.p2/pool/plugins/org.python.pydev.core_7.0.3.201811082356/pysrc/pydevd.py", line 1951, in <module>
main()
File "/home/JRINGRAM//.p2/pool/plugins/org.python.pydev.core_7.0.3.201811082356/pysrc/pydevd.py", line 1945, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/JRINGRAM//.p2/pool/plugins/org.python.pydev.core_7.0.3.201811082356/pysrc/pydevd.py", line 1305, in run
return self._exec(is_module, entry_point_fn, module_name, file, globals, locals)
File "/home/JRINGRAM//.p2/pool/plugins/org.python.pydev.core_7.0.3.201811082356/pysrc/pydevd.py", line 1312, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "/home/JRINGRAM//.p2/pool/plugins/org.python.pydev.core_7.0.3.201811082356/pysrc/_pydev_imps/_pydev_execfile.py", line 25, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/JRINGRAM//MaTris/matris.py", line 655, in <module>
Menu().main(screen)
File "/home/JRINGRAM//MaTris/matris.py", line 606, in main
menu.update(events, timepassed)
File "/home/JRINGRAM//MaTris/kezmenu/kezmenu.py", line 127, in update
self.options[self.option]['callable']()
File "/home/JRINGRAM//MaTris/matris.py", line 586, in <lambda>
['Play!', lambda: Game().main(screen)],
File "/home/JRINGRAM//MaTris/matris.py", line 500, in main
self.redraw()
File "/home/JRINGRAM//MaTris/matris.py", line 513, in redraw
self.matris.draw_surface()
File "/home/JRINGRAM//MaTris/matris.py", line 205, in draw_surface
if with_tetromino[(y,x)] is None:
TypeError: 'bool' object is not subscriptable
I don't suppose you have any idea what's causing this? I think it's an error with drawing the shadows, but I can't quite work out what exactly is causing it?
Do you know how other academic projects using this have controlled an agent placing the blocks?
Many thanks in advance!
hi
i want to learning this game. but i can't play this game.
ImportError: cannot import name 'KezMenu'
i have this error
pygame 2.0.3 (SDL 2.0.16, Python 3.5.2)
MacOS mojave
I'm able to play the game by clicking the top left button. But when I click any other button the game exits.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.