Java代做编程辅导:CITS1001 2048


2048 is a recent online computer game.


Play takes place on a 4×4 board of squares on which a sequence of tiles appears, each holding a number. 


现在提到了代写服务,肯定很多人都不会觉得陌生,就算是国内也是有着专业代写作业的服务行业的,能够为有需求的学生提供很多的帮助,不过其实代写机构在国外会更获得学生的支持,这是因为国外的学校对于平时的作业要求比较严格,为了获得更高的分数顺利毕业,不少留学生就会让代写机构帮忙完成作业,比较常见的作业代写类型,就是计算机专业了,因为对于留学生来说这个技术对于Machine Learning或者AI的代码编程要求更高,所以找代写机构完成作业会简单轻松很多,那么代写机构的水平,要怎么选择才会比较高?




作业的难度相信很多人都很熟悉,特别是对于AI深度学习或者是人工神经网络这种算法来说,因为要对SVM、Design Tree、线性回归以及编程有很高的要求,可以说作业的完成要求非常高,因此才会带动代写机构的发展,找专业的代写机构,一般都是会有专业的人员帮忙进行作业的完成,因为这类型的作业对专业要求比较高,因此代写机构也要具备专业能力才可以,否则很容易导致作业的完成出现问题,出现低分的评价。






Players move tiles around by sliding rows and columns, with the aim of combining identical tiles to make higher numbers.

The player’s score is determined largely by the tiles on the final board.
You can play 2048 online to get familiar with the game. In this project you will construct a computer player for a simplified version of 2048, and also an interface for a human player.

The rules of 2048


2048 is played on a 4×4 grid of squares. Each square is either empty, or it holds a tile holding a number in {2, 4, 8, 16, 32, 64, …}, i.e. a power of two. At the start of the game the board holds between one and
sixteen 2tiles.


The player makes a sequence of moves, each of which is Left, Right, Up, or Down. The description below is for Up moves probably you can translate for the other three possibilities, otherwise they are described here.
An Up move causes all columns on the board to attempt to slide upwards.

  • If no column can legally slide, nothing happens.
  • Otherwise all legal slides are implemented, and then a new 2-tile appears in the leftmost empty square of the bottom row.

Testing slides

A column’s attempt to slide upwards is deemed legal if either or both of the following apply.



A nonempty square in that column has an empty square above it.Two adjacent squares in that column hold identical tiles.
A column cannot slide upwards if it has X tiles at the top with no adjacent identical tiles, and 4X empty squares at the bottom.


Implementing slides

When a slide is implemented, the following occurs.

  • All squares slide to the top of the column, then
  • where there are two adjacent squares holding identical tiles K, those tiles combine into a single tile 2K on the higher square, and all lower tiles slide up again. A tile can participate in only one combination in a given move.

Game over

The game is over when no more successful (i.e. legal) moves are possible.


Each successful move gets one point, and each unsuccessful move loses one point so the score can go up or down as the game proceeds.



Each square on the board is represented by an object belonging to the class Square. The class records what value the square currently holds, with 0 representing an empty square; it also provides methods to interrogate this value, and to set or modify it safely. You are required to write the constructor for Square, and one public method.

  • public void setSquare(int x) throws Exception
    sets the square to the value x if it is 0 or a legal tile value, otherwise it throws a checked exception with a suitable error message.
  • public Square(int x)
    creates the square with the value x if it is 0 or a legal tile value, otherwise it creates an empty square.

The game state

The state of the game as it progresses is represented by an object belonging to the class GameState.
This records the current state of the board, and the current score. You are required to write two constructors for GameState, and the following public methods.

  • public GameState(String file) throws Exception
    sets up the board according to the contents of the file file, e.g. B1.txt. You may assume that the file format is exactly the same as in the example. If all squares are set to empty, the constructor throws a checked exception with a suitable error message.
  • public GameState(double p) throws Exception
    sets up the board with each square independently set to either 2 (with probability p) or empty. If all squares are set to empty, the constructor throws a checked exception with a suitable error message.
    public boolean forward(Square row)
    attempts to slide row towards the front of the array, in the manner described above. Based on the nine pictured examples, it would do the following.
    {0,0,0,0} is unchanged
    {2,8,4,0} is unchanged
    {0,2,0,4} turns into {2,4,0,0}
    {4,2,0,4} turns into {4,2,4,0}
    {2,2,0,0} turns into {4,0,0,0}
    {0,2,0,2} turns into {4,0,0,0}
    {2,2,4,4} turns into {4,8,0,0}
    {2,0,2,4} turns into {4,4,0,0}
    {2,2,2,2} turns into {4,4,0,0}
    If the method makes any changes to row, it returns true; otherwise it returns false.
  • public void left()
    attempts a Left move. Remember to include the placement of the new tile, if appropriate, and remember to update the score.
  • public void clockwise()
    rotates the board 90 degrees clockwise
  • public void anticlockwise()
    rotates the board 90 degrees anticlockwise,
  • public void right()
    attempts a Right move.
  • public void up()
    attempts an Up move.
  • public void down()
    attempts a Down move.
  • public boolean gameOver()
    returns true iff there are no legal moves available on the current board.

The game

The class Play2048 defines the code for actually playing 2048. You are required to write three constructors for 2048, and one public method.

  • public Play2048(String file)
    sets up a game using the file file, and displays the initial board.
  • public Play2048(double p)
    sets up a game using the probability p, and displays the initial board.
  • public Play2048()
    sets up a game using the probability 0.3, and displays the initial board.
  • public void play2048()
    makes the computer play a game of 2048, with each (attempted) move chosen uniformly randomly.
    Display the score as you go along, and display a “Game Over” message when no legal moves are available.

It will almost certainly help you to split up some of these methods, i.e. to write private helper methods.


Each link above gives you a skeleton of the required class, including instance variables, constructors, and methods. You are required to complete the methods and constructors whose bodies are marked with the comment TODO, in,, and Make sure you understand the connections between the classes, and where each method fits into the scheme described above.
I suggest you tackle these tasks in roughly the order above, although it may be helpful to write a constructor for Play2048 and a board display method early, to make testing easier. Here are some tips. If
I add to this list, I will update the document version number.

  • The move description on the main page is for an Up move; whereas the first move you are likely to implement is a Left move. Make sure that this discrepancy doesn’t cause you any problems!
  • When performing moves, you need to update the existing board. Creating new array(s) will not make the tester happy.
  • You may add instance variables to Play2048, although make sure that the information being stored really needs an instance variable. Do not add instance variables to the other classes.
  • Avoid repetitious code! There is much less work here than it may appear…


在此对LE PHUONG对本文所作的贡献表示诚挚感谢,她在山东大学完成了计算机科学与技术专业的硕士学位,专注数据分析、数据可视化、数据采集等。擅长Python、SQL、C/C++、HTML、CSS、VSCode、Linux、Jupyter Notebook。






This will close in 0 seconds