6 kyu

Atomic Chess

Description
Loading description...
Strings
Lists
  • Please sign in or sign up to leave a comment.
  • jkimbell Avatar

    Some solutions mutate position and while that doesn't break the meaning or the tests, it does feel "wrong."

  • PythonPro123 Avatar

    Hi, very nice kata, love it :)
    Please please please make a harder version (either normal chess or atomic chess or even both) (suggestions to make it harder below)\

    1. Instead of f3xe5 the input is a proper chess notation e.g. Nxe5 - this will allow move disambiguation (and of course double disambiguation!!!!)
    2. Allow pawn promotion, castling and en passant
    3. Verify whether a move is legal (especially for castling - cannot castle out of check, into check, or through check)
    4. Require the solution to output whether either side is in check or in checkmate
    • brodiemark Avatar

      Thanks for the comment. Much appreciated!

      There are some kata similar to what you suggest. Check out these:

      "Check and Mate?"

      "Is the King in check ?"

      "One line task: Is the King in check ?"

      "Explain the Algebraic Chess Notation"

      "Find the Final Position"

      Enjoy!

      Suggestion marked resolved by brodiemark 8 months ago
  • ahmet_popaj Avatar

    Great kata of the chess series.

  • Blind4Basics Avatar

    Hi,

    The sample tests aren't using the test framework

    Cheers

    (edit: numOftests shoudln't be hardcoded, but computed from the tests data, btw)

  • AlexUlanov32167 Avatar

    This comment has been hidden.

    • brodiemark Avatar

      Hi Alex,

      Can you give some examples of positions where your program doesn't pass the test? That would make it easier to provide assistance. Usually pasting a long piece of code is not so helpful.

      Regards,

      Mark

      Issue marked resolved by brodiemark 2 years ago
    • AlexUlanov32167 Avatar

      Hi, thanks for your attention. Results: Basic tests has all passed. Fixed tests Regular cases (22 of 22 Assertions) Corner cases (8 of 8 Assertions)

      Random tests Random target sets of 9 squares are filled with random pieces and then a random capture into the target is generated. Positions are not necessarily legal chess positions. (3 of 4 Assertions) Random legal board positions are generated. A random move is made. Some are captures, some not. (32 of 33 Assertions)

      Unexpected exception raised

      Traceback (most recent call last):

      File "/workspace/default/.venv/lib/python3.10/site-packages/codewars_test/test_framework.py", line 112, in wrapper func() File "/workspace/default/tests.py", line 557, in run_target_tests actual = make_atomic_move(copyOfBoard, move)

      File "/workspace/default/solution.py", line 228, in make_atomic_move if position[K_Y_after-1][K_X_after+1] != "p" and position[K_Y_after-1][K_X_after+1] != "P": # Верх Право

      IndexError: list index out of range

    • brodiemark Avatar

      It looks like one of your indexes, either K_Y_after-1 or K_X_after+1, is either <0 or >7, so position is going out bounds. To help figure out why this might happen, let me suggest that you include with the solution the following:

      def printBoard(board):
          print() 
          for i in range(8):
              for j in range(8):
                  print(board[i][j], end="")
              print()
      

      In the very first line of your function, do

      printBoard(position)

      When a test fails you should see the actual position printed out, which should help diagnose the issue.

    • AlexUlanov32167 Avatar

      Thanks for help, i found out solution! -)

    • brodiemark Avatar

      Well done!

      If you like chess problems, there are quite a few, although many of them don't have "chess" in the title. Probably the easiest way to find them is to type chess in the search box and then go to the Collections link (next to Library in the middle of the page.) People have compiled different collections of their favorite chess kata.

  • dfhwze Avatar

    What is Element [8][1] ? The error messages are not user friendly and introduce unspecified array indices.

    Element [8][1] should be R not .
    
  • Voile Avatar

    an "explosion" which destroys all pieces other than pawns in the 9 squares surrounding the capture

    There are only 8 squares surrounding the capture.