Transcribed TextTranscribed Text

Arti ficial Intelligence Problem: 2048 Puzzle Have you ever played 2048 puzzle? If not, give it a try! The 2048 puzzle is played on a simple gray 44 grid, with numbered tiles that slide smoothly when a player moves them using the four arrow keys.Every turn, a new tile will randomly appear in an empty spot on the board with a value of either 2 or 4. Tiles slide as far as possible in the chosen direction until they are stopped by either another tile or the edge of the grid. If two tiles of the same number collide while moving, they will merge into a tile with the total value of the two tiles that collided. The resulting tile cannot merge with another tile again in the same move. Higher-scoring tiles emit a soft glow. In this assignment, you are to implement the AIs programs for this game. Unlike some chess games, two players in this game (computer and human) take di erent actions in their turn. But adversarial search can be applied to this game as well. Have fun! 1 Implementation Detail To simplify your work, a skeleton code is provided to help you test you program on your own machine. This code includes: 1. - Read-only. This module will load your AIs and have it compete automatically. 2. - Read-only. This module provides Grid object with some useful operations - move, getAvaliable- Cells, insertTile and clone (some of them may not be ecient enough). You may use these operations in your AI code directly. However, to get a better performance, you are encouraged to write your own code which can ONLY be used in your AI internally. (This means your AI's getMove function still takes a Grid object as parameter, but it does not matter whether you use those provided operations or not.) 3. - Read-only. All your AIs should inherit from this module and implement getMove function which takes Grid as parameter, return a move (di erent move for di erent player). 4. - Read-only. Inherited from BaseAI, returns a computer action which is a tuple (x, y) indicating the place you want to place a tile. 1 5. - Writable! Inherited from BaseAI, returns a number which indicates the player's action (0 - > UP, 1 - > DOWN, 2 - > LEFT, 3 - > RIGHT). You NEED to modify this file to make it as intelligent as possible.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

# python

from random import randint
from BaseAI import BaseAI
import math

class PlayerAI(BaseAI):

       # Algorithm Heuristic
       def heuristic(self, grid):
                score = 0
                adj = 0
                paths = [1]
                # Compute Cell Value scoring
                for x in range(4):
                        for y in range(4):
                               cell =[y][x]
                               if cell != 0:
                                        score += (cell/2 - 1)
                                        # Give a bonus adjacency score for being
                                        # next to equivalent cells
                                        if x > 0 and cell...

By purchasing this solution you'll be able to access the following files: and README.txt.

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats