Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Recommended Posts

Posted (edited)

Here’s a live demo of the once-popular game named Breakout. This is automated - you can’t play it yourself.

 

But... possibly you can meditate while watching the ball(s) moves? :)

 

At the end of the file, in onInit(), there are parameters you can set:

- board length (I don’t recommend changing the width)

- maximum number of balls (hitting gold and orchid bricks releases more balls)

- brick size

- three parameters for the paddle AI

Game looks funny when you set border = 1...

But Pre-defined parameters woks well.

 

HTML displaying the game field is - let's say - RLE compressed (empty rows) and uses cache per row. It's really fast!

On a lightly loaded HC3 with a 40×40 board, it can generate up to 80 frames per second (each "tick" game image is completely rebuilt!). With a smaller board, even more. The speed is adjustable from 10-140 FPS by buttons. Further optimisations is possible - as simple as separate image refresh from overall game speed.

Efforts to make paddle “AI” very smart didn’t fully succeed. Algorithm predicts the ball’s trajectory and avoids unnecessary movement - that part works. It's is based on predicting of a triangular wave, with a deliberate error added to simulate human-like behaviour. There’s also a rule to prioritize saving more balls - for example, if three balls are in a tight group and one ball is flying separately, the paddle should sacrifice the single ball and save the three. This is based on evaluating a “penalty” associated with saving each ball. It doesn’t always work; I don’t know why - that’s a task for more skilled.

It’s quite possible for the game of this kind  to fall into stasis - 1-2 blocks remains and can’t be hit. There’s an anti-stall mechanism that perturbs the reflection angle after a given stall time, but it’s not perfect either.

 

Making games, even so simple, seems not to be simple...

This QA is meant to be seen, smiled at - and deleted. Enjoy!

Please login or register to see this attachment.

Edited by Łukasz997
  • Like 3

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...