• 大小: 399KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: C#
  • 标签: 2048  AI  

资源简介

具有90%概率达到2048,较大概率达到4096,C#语言写成,简洁的UI(开发工具VS2015)。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Forms;

namespace _2048_UI
{
    struct position
    {
        public int x;
        public int y;
    }
    struct cell
    {
        public int x;
        public int y;
        public double value;
        public cell(int x int y double value)
        {
            this.x = x;
            this.y = y;
            this.value = value;
        }
    }
    struct howMove
    {
        public int move;
        public double score;
        public int positions;
        public int cutoffs;
        public howMove(int direction double newScore int pos int cut)
        {
            move = direction;
            score = newScore;
            positions = pos;
            cutoffs = cut;
        }
    }

    class direction
    {
        position[] directions = new position[4];
        public position getDirection(int index)
        {
            return directions[index];
        }
        public direction()
        {
            directions[0].x = 0; directions[0].y = -1;//up
            directions[1].x = 1; directions[0].y = 0;//right
            directions[2].x = 0; directions[0].y = 1;//down
            directions[3].x = -1; directions[0].y = 0;//left
        }
    }
    class gameCode : ICloneable
    {
        public int[] arrayNumbers = new int[4 4];
        bool needSetRandom = false;
        public bool playerTurn = true;
        public howMove search(int depth double alpha double beta int position int cutoffs)
        {
            double bestScore;
            int bestMove = -1;
            howMove result = new howMove();

            if (this.playerTurn)
            {
                bestScore = alpha;
                for (int direction = 0; direction < 4; direction++)
                {
                    gameCode newGrid = (gameCode)this.Clone();
                    if (newGrid.fourMove(direction))
                    {
                        position++;
                        if (newGrid.isWin())
                            return new howMove(direction 10000 position cutoffs);
                        if (depth == 0)
                        {
                            result.move = direction; result.score = newGrid.eval();
                        }
                        else
                        {
                            result = newGrid.search(depth - 1 bestScore beta position cutoffs);
                            if (result.score > 9900)
                                result.score--;
                            position = result.positions;
                            cutoffs = result.cutoffs;
                        }
                        if (result.score > bestScore)
                        {
                            bestScore = result.score;
            

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     53760  2017-01-13 10:34  2048_UI - TEXT\.vs\2048_UI\v14\.suo

     文件       4106  2017-01-09 23:46  2048_UI - TEXT\2048_UI\2048_UI.csproj

     文件        189  2017-01-09 17:24  2048_UI - TEXT\2048_UI\App.config

     文件      30720  2017-01-10 15:32  2048_UI - TEXT\2048_UI\bin\Debug\2048_UI.exe

     文件        189  2017-01-09 17:24  2048_UI - TEXT\2048_UI\bin\Debug\2048_UI.exe.config

     文件      56832  2017-01-10 15:32  2048_UI - TEXT\2048_UI\bin\Debug\2048_UI.pdb

     文件      22696  2017-01-13 10:32  2048_UI - TEXT\2048_UI\bin\Debug\2048_UI.vshost.exe

     文件        189  2017-01-09 17:24  2048_UI - TEXT\2048_UI\bin\Debug\2048_UI.vshost.exe.config

     文件        490  2016-07-16 19:44  2048_UI - TEXT\2048_UI\bin\Debug\2048_UI.vshost.exe.manifest

     文件     200728  2016-02-19 22:28  2048_UI - TEXT\2048_UI\bin\Debug\Microsoft.VisualStudio.Threading.dll

     文件     346345  2016-02-19 22:28  2048_UI - TEXT\2048_UI\bin\Debug\Microsoft.VisualStudio.Threading.xml

     文件      28160  2017-01-10 15:32  2048_UI - TEXT\2048_UI\bin\Release\2048_UI.exe

     文件        189  2017-01-09 17:24  2048_UI - TEXT\2048_UI\bin\Release\2048_UI.exe.config

     文件      48640  2017-01-10 15:32  2048_UI - TEXT\2048_UI\bin\Release\2048_UI.pdb

     文件      22696  2017-01-10 15:30  2048_UI - TEXT\2048_UI\bin\Release\2048_UI.vshost.exe

     文件        189  2017-01-09 17:24  2048_UI - TEXT\2048_UI\bin\Release\2048_UI.vshost.exe.config

     文件        490  2016-07-16 19:44  2048_UI - TEXT\2048_UI\bin\Release\2048_UI.vshost.exe.manifest

     文件     200728  2016-02-19 22:28  2048_UI - TEXT\2048_UI\bin\Release\Microsoft.VisualStudio.Threading.dll

     文件     346345  2016-02-19 22:28  2048_UI - TEXT\2048_UI\bin\Release\Microsoft.VisualStudio.Threading.xml

     文件      28619  2017-01-10 15:32  2048_UI - TEXT\2048_UI\code.cs

     文件       6087  2017-01-10 11:40  2048_UI - TEXT\2048_UI\Form1.cs

     文件      17181  2017-01-10 11:40  2048_UI - TEXT\2048_UI\Form1.Designer.cs

     文件      15709  2017-01-10 11:40  2048_UI - TEXT\2048_UI\Form1.resx

     文件       1979  2017-01-13 10:32  2048_UI - TEXT\2048_UI\obj\Debug\2048_UI.csproj.FileListAbsolute.txt

     文件       1012  2017-01-10 11:40  2048_UI - TEXT\2048_UI\obj\Debug\2048_UI.csproj.GenerateResource.Cache

     文件      12046  2017-01-09 23:46  2048_UI - TEXT\2048_UI\obj\Debug\2048_UI.csprojResolveAssemblyReference.cache

     文件      30720  2017-01-10 15:32  2048_UI - TEXT\2048_UI\obj\Debug\2048_UI.exe

     文件      56832  2017-01-10 15:32  2048_UI - TEXT\2048_UI\obj\Debug\2048_UI.pdb

     文件       1464  2017-01-09 17:45  2048_UI - TEXT\2048_UI\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       7318  2017-01-11 23:29  2048_UI - TEXT\2048_UI\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

............此处省略41个文件信息

评论

共有 条评论