Page 1 of 2 12 LastLast
Results 1 to 10 of 17
  1. #1
    pas
    Member
    pas is offline

    Posts
    63

    Bilge Bot Logic [c++ source]

    Started writing a bilging solver in c++ yesterday.
    Feel free to take a look and use it and give feedback if you want (I am mainly looking for code style feedback, not performance).

    Here's the source which has a useful readme with it.

    https://github.com/ih1115/Bilger

    You can quite easily use this along with OpenForager's source ( https://github.com/pixelgriffin/OpenForager ) and some human mouse movement (google around) to put together a fully functional bilge bot.
    For example, (without HMM)
    Last edited by pas; 07-28-2017 at 11:37 PM.

  2. #2
    Senior Member
    TheRigger is offline

    Posts
    634
    y u no use Google Test?

  3. #3
    pas
    Member
    pas is offline

    Posts
    63
    Quote Originally Posted by TheRigger View Post
    y u no use Google Test?
    Good question, I've never used them and I should be soon since I'm soon going to be working with a code base that already uses it.

    I haven't got much code coverage as it is.
    Last edited by pas; 07-24-2017 at 08:10 PM.

  4. #4
    Senior Member
    TheRigger is offline

    Posts
    634
    Quote Originally Posted by pas View Post
    Good question, I've never used them and I should be soon since I'm soon going to be working with a code base that already uses it.

    I haven't got much code coverage as it is.
    Fair enough, it's always good to use tools that don't make you write it all yourself

  5. #5
    pas
    Member
    pas is offline

    Posts
    63
    Updated with google tests.

  6. #6
    Dan
    Bot Coder
    Dan is offline

    Posts
    217
    You used unit tests on a bot. My hero.

  7. #7
    SF Pleb
    jak8222 is offline

    Posts
    141
    What are unit test for?

    Edit: Looks nice though
    Last edited by jak8222; 07-25-2017 at 07:18 PM.

  8. #8
    Junior Member
    Fucknugget is offline

    Posts
    5
    Quote Originally Posted by jak8222 View Post
    What are unit test for?

    Edit: Looks nice though
    They ensure that when people make changes to code, that everything still works as expected. Sometimes changes can affect areas of code that you may not expect, or you make a change that's supposed to be the same functionally but perhaps is written more cleanly or without unnecessary code. Good unit tests are there as a safety net for you and any other developer working on your code. They're also a nice indication for when you've written some code poorly, if something can't be unit tested (and that's because of something within your control) it's not written well.

  9. #9
    Senior Member
    TheRigger is offline

    Posts
    634
    Looked over the tests, often it's best to use ASSERT_TRUE and ASSERT_FALSE instead of ASSERT_EQUALS for booleans.
    Looking at board_t, the definition as a vector<char> is a bit wonky but it's nice in that you can use the overloaded == for ASSERT_EQUALS comparisons
    otherwise looking good, you may want to use the following algo for moving pieces up instead:
    Code:
    scan over all c in columns
        scan over all places r in c
            if target to fill is set and r is not empty //second
                swap(r, target to fill) //first
                target to fill += BOARD_WIDTH //move target one down
            else if r is empty
                target to fill = r //first
                target to fill is set //second
        reset target to fill //or just define the scope properly
    for this target to fill should be pair_type<int_type r, bool set>
    disclaimer: disclaimed

  10. #10
    pas
    Member
    pas is offline

    Posts
    63
    Cool.
    Finished the tests and changed them accordingly.
    Also updated the shift method to have reduced (and I think optimal) complexity.

Page 1 of 2 12 LastLast

Posting Permissions

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