Skip to content

Submit robot

keywet06 edited this page Aug 6, 2020 · 3 revisions

The way to submit a robot to auto2048

Warning:

  • You must submit a c++ file
  • Don't submit code can only play under than 3000 score.

Example

  • This is the example of AI
#include "api.hpp"
namespace robotname {
int solve(int data[4][4]) { /* some code */ }
} // namespace robotname

Declartion

  • The declaration of the main function you should write is:
int robotname::solve(int data[4][4]);
  • The namespace robotname should be named with your robot's name
  • The array data is the numbers on 2048
  • (int)(1) is refered to 2; (int)(2) is refered to 4; ...; (int)(n) is refered to (1 << n); ...
  • The return type is: 0->up, 1->right, 2->down, 3->left.

Function

  • Auto2048 provides some functions for you to call(the functions in api.hpp):
void solve(int x, int data[4][4], int &score);
int test(int x);
int test();
int step(int x, int data[4][4]);
  1. The function to run the step

    void solve(int x, int data[4][4], int &score);
    1. int x: the direction you give
    2. int data[4][4]: the data you give
    3. int &score: add the score you get
  2. The function to test a direction

    int test(int x);
    1. int x: the direction on 2048
    2. return int: if the data changed
  3. The function to test all directions

    int test();
    1. return int: if it has a direction can make data change
  4. The function to test the step

    int step(int x, int data[4][4]);
    1. return int & 1: if it has the direction can make data change
    2. return int & ~1: the score added
Clone this wiki locally