GithubHelp home page GithubHelp logo

ai_competition's People

Contributors

coolusahd avatar rafiarahim avatar susanne-throner avatar toddchavezz avatar tribly avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

ai_competition's Issues

Move with no figure is possible

Description

Sometimes when I run my agent, I got an error that on after checking if the move is a capture the moving figure doesnt match the figure names.
After further investiagation I found out that when my Quiesce function do recursivly moves without checking if the game is over, you can create a move with '--' as playing figure.

Code Changes:

With the addition in ChessEngine.py:800
if(self.pieceMoved == "--"): raise ValueError('moving a piece that is not on the board')

Error Output

I got the following console output:

Process Process-1:
Traceback (most recent call last):
  File "C:\Python39\lib\multiprocessing\process.py", line 315, in _bootstrap
    self.run()
  File "C:\Python39\lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Projekte\chess_ai\student_agents\template.py", line 107, in findBestMove
    score = self.alphaBeta(copyGS, self.currentDepth, -float('inf'), float('inf'), True)
  File "C:\Projekte\chess_ai\student_agents\template.py", line 284, in alphaBeta
    score = self.alphaBeta(copyGS, depth - 1, alpha, beta, False)
  File "C:\Projekte\chess_ai\student_agents\template.py", line 319, in alphaBeta
    score = self.alphaBeta(copyGS, depth - 1, alpha, beta, True)
  File "C:\Projekte\chess_ai\student_agents\template.py", line 264, in alphaBeta
    return self.Quiesce(gs,alpha,beta,depth)
  File "C:\Projekte\chess_ai\student_agents\template.py", line 388, in Quiesce
    score = -self.Quiesce(gs, -beta, -alpha ,depth)
  File "C:\Projekte\chess_ai\student_agents\template.py", line 388, in Quiesce
    score = -self.Quiesce(gs, -beta, -alpha ,depth)
  File "C:\Projekte\chess_ai\student_agents\template.py", line 388, in Quiesce
    score = -self.Quiesce(gs, -beta, -alpha ,depth)
  [Previous line repeated 1 more time]
  File "C:\Projekte\chess_ai\student_agents\template.py", line 384, in Quiesce
    validMoves = gs.getValidMoves()
  File "C:\Projekte\chess_ai\ChessEngine.py", line 300, in getValidMoves
    self.getKingMoves(kingRow, kingCol, moves)
  File "C:\Projekte\chess_ai\ChessEngine.py", line 688, in getKingMoves
    moves.append(Move((r, c), (endRow, endCol), self.board))
  File "C:\Projekte\chess_ai\ChessEngine.py", line 800, in __init__
    raise ValueError('moving a piece that is not on the board')
ValueError: moving a piece that is not on the board

There you can see that when you execute gs.getValidMoves() on a Board without a king it returns a move where '--' is the moving Figure

BUG: getValidMoves generates IndexError

Description

Sometimes the function getKingsideCastleMoves get called with index=35 and with

getKingsideCastleMoves in ChessEngine:732
if self.board[rc + 1] == "--":

it ends in an IndexError

Error Output:

  File "C:\Projekte\chess_ai\student_agents\template.py", line 313, in alphaBetaMin
    validMoves = gs.getValidMoves()
  File "C:\Projekte\chess_ai\ChessEngine.py", line 306, in getValidMoves
    self.getCastleMoves(kingRow, kingCol, moves)
  File "C:\Projekte\chess_ai\ChessEngine.py", line 708, in getCastleMoves
    self.getKingsideCastleMoves(r, c, moves)
  File "C:\Projekte\chess_ai\ChessEngine.py", line 732, in getKingsideCastleMoves
    if self.board[rc + 1] == "--":
IndexError: list index out of range

No Checkmate detection on pawn promotion

Checkmates are not detected if they happen within a pawn promotion move.

Situation:

Board:

-- bK -- -- -- --
-- -- -- wR wp --
-- -- -- -- -- --
-- -- -- -- -- --
-- -- -- -- -- --
-- -- wK -- -- --

White's turn.
Valid moves: ['Ra5', 'Rd2', 'Rc5', 'Kc2', 'e6', 'Rd1', 'Kd2', 'Rb5', 'Rd4', 'Kb1', 'Kd1', 'Rd3', 'Kb2', 'Rd6']
White makes move: 'e6'

Board:

-- bK -- -- wR --
-- -- -- wR -- --
-- -- -- -- -- --
-- -- -- -- -- --
-- -- -- -- -- --
-- -- wK -- -- --

Expected Behaviour:

Pawn gets promoted to Rook. Black King is in Checkmate (gameState.checkMate evaluates to True)

Actual Behaviour:

Pawn gets promoted to Rook. Black King is not in Checkmate (gameState.checkMate evaluates to False)

Own night takes own rook [getValidMoves returns invalid move]

Description

I run my agent and suddenly I saw this:
image

On the right bottom corner was my rook and now my own knight is there. That alone is defently not a valid move.
Furthermore you can see the last position of my knight as red dot. So there is also an unvalid move from there as knight.

Maybe there are some bugs in the Castle Right moves...

You can test that behavior with that code:

Code

        gs = GameState()

        gs.board = ['bR', 'bB', 'bK', 'bN', '--', 'bR',
                    'bp', 'bp', '--', '--', '--', 'bp',
                    '--', '--', '--', 'bp', '--', 'wp',
                    '--', '--', '--', '--', '--', '--',
                    'bB', 'wp', 'wp', 'wp', '--', '--',
                    'wR', 'wB', 'wK', 'wN', '--', 'wR']

        gs.whiteToMove = True

        moves = gs.getValidMoves()

Get KeyError on undoMove()

Description

it dont happen very often but when it happen I cannot found any problem in my code.
I'm using undo move like this in my code

gs.makeMove(move)
score = RekursiveFunktion(x,y)
gs.undoMove()

Error Output

Process Process-6:
Traceback (most recent call last):
  File "C:\Projekte\chess_ai\ChessEngine.py", line 177, in undoMove
    self.game_log[tuple(self.board)] -= 1
KeyError: ('--', 'bR', 'bN', 'bK', 'bB', 'bR', '--', 'bp', 'bp', '--', 'bp', 'bp', '--', 'bB', '--', 'bp', '--', '--', '--', '--', '--', 'wp', 'wp', 'wp', 'wp', 'wp', 'wp', '--', '--', 'wR', 'wR', 'wB', 'wN', 'wK', '--', 'wR')

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.