Results 1 to 9 of 9

Thread: tetris algorithms...

  1. #1
    Join Date
    Jun 2008
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default tetris algorithms...

    I'm making a tetris bot for neave tetris and I plan on using scar. I already have the code for finding pieces etc.
    The problem is that it's too stupid to get very many lines. I wrote a simulation in c++ and this is the best it can do:
    Code:
    game over
    lines: 2016
    board:
    .......00.
    00......0.
    00.....00.
    00000..000
    00.000..00
    0000000.0.
    000.000.00
    0000000.00
    000000.000
    0.00000000
    00.0000000
    .00.000.00
    .000000.00
    .00000..00
    00000..0.0
    000000.00.
    .000000000
    0.00000000
    heights: 17 17 15 15 15 14 13 18 18 15
    holes: 26
    The algorithm I'm using would probably run in scar with reasonable lag. Does anyone know a good way to make it more effective without causing scar to lag like mad? I need ideas!

  2. #2
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    I'm guessing from what you said your C script worked by detecting the spaces on board then assigning them in an 2dArray (probably boolean with it referring to blank/taken) and then checking the best option based on incoming shape (once again changing it to 2dArray).
    Using that method, it would be most effective, I think, to use a similar method. Prioritise searching with the most common holes first going down in order and only searching with small penetration at the beginning then getting deeper (referring to rows down from the top). It may also be more effective to only re-assess the board when a line is supposedly cleared by checking for full rows in Scar.
    Of course, those suggestions are only effective if I got the right gist of your script - would be much easier with some actual code or a small walkthrough on the idea behind it
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  3. #3
    Join Date
    Jun 2008
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well I implemented it in scar... and it turns out that scar is slow. VERY slow... I'm gonna have to rethink this.

  4. #4
    Join Date
    Jul 2008
    Location
    California
    Posts
    255
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    What's wrong with reworking the c++ code? Not only can c++ be more effective but c++ scripts can, from what I know, be compiled into a .exe file for distribution. SCAR is a fairly slow compiler, yes. But, in my opinion, SCAR contains code that is unbelievably easy to read and write. It's generalised for more simple scripts, I think, and probably will not do too well for more complex handlings.
    Unfortunately, no active scripts atm.

  5. #5
    Join Date
    Jun 2008
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yeah, I was thinking of maybe using c++ instead. The simplified bot I made for scar scored 400k though. o.O I think I'll leave it going overnight and see what happens...

  6. #6
    Join Date
    Jul 2007
    Location
    Ottawa, Canada
    Posts
    930
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    if you are having problems with slowness in scar, you could try making a plugin to speed things up a bit.
    ~ Metagen

  7. #7
    Join Date
    Jun 2008
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    If I can figure out plugins that would be great. This is usually what happens:
    http://img187.imageshack.us/img187/4...trisbottl5.png
    At level 50, the piece falls down about 4 squares before scar can finish processing it. If I put it into a plugin the bot could easily get on the first page of highscores.

  8. #8
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    You can make plugins in Delphi easiest though C++ isn't too hard as well if you understand the tuts on getting them to work. Once you get the plugin working, you call it just like any other procedure/function in Scar, so you can use it only for the most strenuous bit or all of it even and just have Scar call it, though that kind of defeats the point
    There's a couple of tutorials on Plugin's, but if you know a bit about dll's anyway, then there are a couple of example plugins in Scar's plugin folder that you could learn off.
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  9. #9
    Join Date
    Jun 2008
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    The cpptestplugin isn't working for me. I hope I can figure it out tonight. I improved the algorithm and ran a few games in my simulation:
    Code:
    lines: 7825
    lines: 110695
    lines: 64020
    lines: 7831
    lines: 18093
    lines: 9361
    lines: 96519
    lines: 21952
    lines: 16180
    lines: 2820
    lines: 1661
    lines: 19275
    So I don't need any help with that. Now I just need to get plugins to stop being weird...

    EDIT: Made a plugin and it works great. It's so good that I can't submit scores from my IP anymore (scored over 2 billion). Now I have to use tor lol >_>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Tetris BOT
    By 4chan in forum First Scripts
    Replies: 3
    Last Post: 07-30-2008, 02:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •