GithubHelp home page GithubHelp logo

innoviox / bredon Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 1.0 583 KB

AI for the game Tak in python

Home Page: https://github.com/Innoviox/bredon

License: GNU General Public License v3.0

Python 100.00%
ai mvvm tak

bredon's People

Contributors

dependabot-support avatar innoviox avatar

Watchers

 avatar

Forkers

fossabot

bredon's Issues

White doesn't block at ply 8a

    1     2         3     4
a         W{F}B{F}        B{F}W{F}
b   W{F}  W{F}      W{F}
c   W{F}                  B{F}
d   B{F}  B{F}      B{F}  B{F}
1. a1 d4 
2. b2 d2 
3. a2 c4 
4. a3 a4 
5. 1a3+ a3 
6. 1a1> 1a3- 
7. c1 d3 
8. b3 d1 
B won!

Also the return beta/-beta fix slows it down considerably -- data coming soon.

Make ptn and tps classes

If it's enhancement:

  1. Why would this be a good addition?
    This would be good because right now the ptn adders are complex and not written for readability. A ptn class would be fun for all!
  2. Sample pseudocode
    None
    Add it to a milestone if applicable.

Refactor __init__.py

I've selected init.py for refactoring, which is a module of 361 lines of code and 12 incoming calls. Addressing this will make our codebase more maintainable and improve Better Code Hub's Separate Concerns in Modules guideline rating! 👍

Here's the gist of this guideline:

  • Definition 📖
    Avoid large modules with high fan-in (nr. of incoming calls).
  • Why
    This keeps the codebase loosely coupled which makes it easier to minimize the consequences of changes.
  • How 🔧
    Identify and extract responsibilities of large modules into smaller ones and hide implementation details behind interfaces. Target having modules that have no more than 10 incoming calls.

You can find more info about this guideline in Building Maintainable Software. 📖


ℹ️ To know how many other refactoring candidates need addressing to get a guideline compliant, select some by clicking on the 🔲 next to them. The risk profile below the candidates signals (✅) when it's enough! 🏁


Good luck and happy coding! :shipit: ✨ 💯

Complete tps

Input bar on view
Implement turn & player in tps algorithm

Weird things happen after tps

If it's a bug:

  1. Steps to reproduce
  2. Goal of code
  3. Did this work at a previous commit?

If it's enhancement:

  1. Why would this be a good addition?
  2. Sample pseudocode
    Add it to a milestone if applicable.

Standing stones flatten

Excerpt from output of python3.6 main.py -w ai:3

4.283537149429321
    WHITE    BLACK
 1  Cb2
    1    2            3    4    5
a   @a1  @a2          @a3  @a4  @a5
b   @b1  BLACK{C}@b2  @b3  @b4  @b5
c   @c1  @c2          @c3  @c4  @c5
d   @d1  @d2          @d3  @d4  @d5
e   @e1  @e2          @e3  @e4  @e5
3.645015001296997
    WHITE    BLACK
 1  Cb2      Ca3
    1    2            3            4    5
a   @a1  @a2          WHITE{C}@a3  @a4  @a5
b   @b1  BLACK{C}@b2  @b3          @b4  @b5
c   @c1  @c2          @c3          @c4  @c5
d   @d1  @d2          @d3          @d4  @d5
e   @e1  @e2          @e3          @e4  @e5
1.839872121810913
    WHITE    BLACK
 1  Cb2      Ca3
 2  Sa2
    1    2            3            4    5
a   @a1  WHITE{S}@a2  WHITE{C}@a3  @a4  @a5
b   @b1  BLACK{C}@b2  @b3          @b4  @b5
c   @c1  @c2          @c3          @c4  @c5
d   @d1  @d2          @d3          @d4  @d5
e   @e1  @e2          @e3          @e4  @e5
1.8416838645935059
    WHITE    BLACK
 1  Cb2      Ca3
 2  Sa2      b1
    1            2            3            4    5
a   @a1          WHITE{F}@a2  WHITE{C}@a3  @a4  @a5
b   BLACK{F}@b1  BLACK{C}@b2  @b3          @b4  @b5
c   @c1          @c2          @c3          @c4  @c5
d   @d1          @d2          @d3          @d4  @d5
e   @e1          @e2          @e3          @e4  @e5

Note that in ply 2a, White makes the rather nonsensical move Sa2, which is correctly translated in the board. But by ply 2b, it's flat, which makes more sense.

AI doesn’t retaliate

Enter move: >? a1
1. a1 
    1     2    3    4
a   W{F}
b
c
d
Enter move: >? d4
1. a1 d4 
    1     2    3    4
a   W{F}
b
c
d                   B{F}

First entered moves.

1. a1 d4 
2. b2 
    1     2     3    4
a   W{F}
b         W{F}
c
d                    B{F}
1. a1 d4 
2. b2 d2 
    1     2     3    4
a   W{F}
b         W{F}
c
d         B{F}       B{F}

Kind of weird openers, but ok.

1. a1 d4 
2. b2 d2 
3. a2 
    1     2     3    4
a   W{F}  W{F}
b         W{F}
c
d         B{F}       B{F}
1. a1 d4 
2. b2 d2 
3. a2 c4 
    1     2     3    4
a   W{F}  W{F}
b         W{F}
c                    B{F}
d         B{F}       B{F}

Super strange attacks.

1. a1 d4 
2. b2 d2 
3. a2 c4 
4. a3 
    1     2     3     4
a   W{F}  W{F}  W{F}
b         W{F}
c                     B{F}
d         B{F}        B{F}
1. a1 d4 
2. b2 d2 
3. a2 c4 
4. a3 a4 
    1     2     3     4
a   W{F}  W{F}  W{F}  B{F}
b         W{F}
c                     B{F}
d         B{F}        B{F}

A more normal attack-and-block.

1. a1 d4 
2. b2 d2 
3. a2 c4 
4. a3 a4 
5. b4 
    1     2     3     4
a   W{F}  W{F}  W{F}  B{F}
b         W{F}        W{F}
c                     B{F}
d         B{F}        B{F}
1. a1 d4 
2. b2 d2 
3. a2 c4 
4. a3 a4 
5. b4 d3 
    1     2     3     4
a   W{F}  W{F}  W{F}  B{F}
b         W{F}        W{F}
c                     B{F}
d         B{F}  B{F}  B{F}

White re-attacks, forcing a a3-b>:a road fork. Black's only option here is a4<, but instead it goes for d3, to flesh out its attack plan. But White recaptures and wins with b4+.
What led black to this fatal mistake?

Instantaneous Win

If it's a bug:

  1. Steps to reproduce
    Run main.py
  2. Goal of code
    Should not win and exit instantaneously.
  3. Did this work at a previous commit?
    Worked at fixed 22.

Make color and stone and dir enums

If it's enhancement:

  1. Why would this be a good addition?
    Nice readablity and also enums are cool.
  2. Sample pseudocode
    enum {stuff}
    Add it to a milestone if applicable.

Make next (obj) to remove code duplication

Currently Square.next and Tile.next are implemented the same. I propose a global next method, like so:

def next(obj):
if obj is a square or tile:
{default next implementation}
raise type error

Alternatively, a class "positionable" with a next method that both square and tile inherit from, but this seems a little weird.

Road glitches & Ss

A standard 4x4 depth a1/d4 led to this:

1. a1 d4 
2. d2 b2 
3. d3 Sd1 
4. c3 a2 
5. c4 1a1> 
6. c1 Sc2 
7. a4 Sb4 
8. b3 1b2+ 
9. a1 2b3>11 
10. 2c3> Sb3 
11. 3d3< 1b3< 
12. 1a1+ 1b1< 
13. 1c3< 1a1+ 
14. b1 1c2+ 
15. b2 
W won!

Notes:

  • White didn't win
  • Black places down lots of standing stones
  • Black's play style seems completely illogical

Rename controller args

white_types => white
black_types => black

Game(white=HUMAN, black=AI(3)) looks better i think

Column labels are misaligned

If it's a bug:

  1. Run viewtest.py
  2. Align column labels
  3. Did this work at a previous commit?
  • it worked before the buttons were added. the buttons screwed up the grid

Board class ideas

Board should have a list of players
Board should have a .do_move and .undo that advances its state instead of having players act upon it
Board should generate based on its state

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.