Number Cards Battle
Code Battle
한글로 보기

Game Rules

This is a card betting game where Player 1 and Player 2's code battle 1:1. The programming language is JAVASCRIPT.
Starting coins: 1000
Time limit: 20s
Up to 99 Sets
Cards: 1-20

After checking the game rules, writing the codes for Player 1 and Player 2, click the Start Game button to start the match.

1 Game consists of up to 99 Sets, and in 1 Set, the Round is repeated until all coins are used up. 1 Round means one hand, and Turns are repeated until both players' betting coins are equal or until one side gives up.

1 Game has a time limit of 20 seconds. If 20 seconds have passed at the end of the Set, the Game ends without proceeding further with the Set, and the player who wins more Rounds at that time wins the Game.

Code battle's lifecycle callback functions are onGameStart, onSetStart, onRoundStart, onTurnStart, onRoundEnd, onSetEnd, onGameEnd, and you have to implement your own logic on each function.(There is no onTurnEnd.)

Building a basic strategy of the game, analyzing your opponent's pattern and returning the best choice at onTurnStart is the key to winning.

Any attempt to cheat, such as affecting the opponent's code or delaying time, will result in defeat.

The game rules:

  • At the start of each Set, you start with 1000 coins.
  • At the start of each Round, both players bet 10 coins by default.
  • In each turn, you are given 2 of your cards, 1 of your opponent's cards, and the number of your opponent's betting coins, and you must return the number of your betting coins.
    • You must return a value greater than or equal to the number of coins your opponent bet, but less than or equal to the total number of coins you have.
    • If you return a number that does not meet the above conditions or -1, you will give up the round and the coins you bet until then will be transferred to your opponent.
    • If you return a value greater than the number of coins your opponent bet, it is the same as "raising" the game.
    • If it returns a value equal to the number of coins the opponent bet, it is the same as making a "call".
    • If your opponent's and your number of betting coins are equal, the win or loss is determined according to the card sequence listed below, and the winning side takes all the betting coins.
  • Number cards consist of numbers from 1 to 20, and the order of card pairs is as follows (sorted in descending order).
    • When two cards are 10 and 20
    • When two cards are 9 and 19
    • When two cards are 8 and 18
    • When two cards are 7 and 17
    • When two cards are 6 and 16
    • When two cards are 5 and 15
    • When two cards are 4 and 14
    • When two cards are 3 and 13
    • When two cards are 2 and 12
    • When two cards are 1 and 11
    • When the "units" number of the sum of two card is 9. (Ex: 5 and 14, or 3 and 6). If it's the same, compare the big cards. (Ex: ['5' and 4] < [3 and '6'])
    • When the "units" number of the sum of two card is 8
    • When the "units" number of the sum of two card is 7
    • When the "units" number of the sum of two card is 6
    • When the "units" number of the sum of two card is 5
    • When the "units" number of the sum of two card is 4
    • When the "units" number of the sum of two card is 3
    • When the "units" number of the sum of two card is 2
    • When the "units" number of the sum of two card is 1
    • When the "units" number of the sum of two card is 0

The screen since the round of 16 →

Player 1

Player 2

TURN
Player 1
Bet: -1
0
0
VS
Player 2
Bet: -1
0
0
ROUND (Coins)
Player 1
0
Player 2
0
SET (GAME)
Player 1
0 (0)
Player 2
0 (0)
If you or the opponent's screen is not visible, the communication speed will be slower.

Game Log

Recent logs are displayed at the top.