toilanvd_HSGS's blog

By toilanvd_HSGS, 10 years ago, In English

Today I would like to introduce my 4 board games that I designed and hope that help you to relax!

You could download the source codes and run them in your computer to enjoy (they can't be run in Ideone because they have command "System("cls")")!

First, the simplest game which I saw in my dream last night: Source code

When you run this source code, an exe file will appear:

You could read the rules and after read, follow the instruction to play.

These are examples of playing games:

There will be 2 kind of input to enter:

  1. Choose team/bit: Enter 0 or 1

  2. Choose your piece/cell: Enter row number and then column number (1-based)

With a 4x4 board, this game can be solved with Dynamic Programming in O(2^16 * 16^2), but in my opinion playing without DP is more fun.

Second, based on that game, I designed 3 more games, and I think that they can't be solved using simple Dynamic Programming:

Game 1

Game 2

Game 3- easy version and Game 3- hard version

You can adjust size of the board by replace another value of n in source code. Because of lacking of time, I have just used random tools for Computer's AI. You can play these game with your friends to have other experience.

I merely know to create simple programmes like that, so sorry if you feel uncomfortable when playing.

Thanks for reading, and glad to listen to any response of you!

(Update: Added Game 3- hard version)

  • Vote: I like it
  • +45
  • Vote: I do not like it

| Write comment?
»
10 years ago, # |
  Vote: I like it +8 Vote: I do not like it

Have you solved the game? Hint: second player wins.

  • »
    »
    10 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    No, I haven't. I think 4x4 board is quite small, but 6x6 is quite difficult to avoid a DRAW. Therefore it is merely an example for all my games.

    • »
      »
      »
      10 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Second player wins whenever both side lengths are divisible by 2 (and otherwise I'm not sure yet). So 6x6 is a second player win too.

      • »
        »
        »
        »
        10 years ago, # ^ |
          Vote: I like it +5 Vote: I do not like it

        I used DP for that game and realized that with a 4x4 board, if both player play optimally, then it will be a DRAW. See my code.

        Maybe you are thinking that player 2 plays symmetry to player 1, but it does not probably lead to a victory of player 2.

        • »
          »
          »
          »
          »
          10 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Oh wait, I just realized that if all pieces are picked up, the result is a draw. I thought if all pieces are picked up then the first player loses due to having no moves. I need to read things more carefully...

          Meanwhile, a drawing strategy for the second player (second player won't lose) whenever both side lengths are at least 4 and are even:

          A B E F I J
          C D G H K L
          B A F E J I
          D C H G L K
          
          A B C A B C
          D E F D E F
          G H I G H I
          J K L J K L
          

          Pick either side of the board. If its side length is divisible by 4 (that is, ), use the top part: you can tile the board by 4 × 2 rectangles, where in each rectangle you play a knight move away from the first player's move. If its side length is divisible by 2 but not 4 (that is, ), use the bottom part: divide the board in two and play on the same position as the first player's move in the other half.

          This guarantees that you will always have a move, so you won't lose. However, with correct play, the first player can clear the board against this strategy, which makes this not a winning strategy (at best drawing against a first player knowing this).

»
10 years ago, # |
Rev. 3   Vote: I like it +3 Vote: I do not like it

Minus of command system("cls") — that program will always blink.
I know a command that update only changed symbols.

COORD num={0,0};     
SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), num );

num — is position where symbol must be changed,
then just write cout, and it will overwrite

  • »
    »
    10 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks for your command you gave me! I will use it in my future games!