猫史档案馆


MHC_冷靜的超人_FMN

MHC_冷靜的超人_FMN

Lv.1

最近被封号处理12个月。 迷你不买版权的原因找到了:迷你只会抄袭。 喜欢MC的一切 MC骨灰级玩家

获赞:144收藏:52浏览:3172作品收藏:67

签名:呼吸空气,吃喝拉撒睡。 喂迷你屎界吃屎! 扒迷你抄袭mc的证据! 玩mc零大陆 零大陆交流群: 红群:232224247 黄群:432219123

回复帖子评论
上一页3 页 / 共 3下一页

我的世界:教育版来中国啦!小学生以后上课也能玩MC了? 中回复

呵呵 想的太美了,你觉的一个游戏能改变中国5000年的教育制度???

2020-03-12T18:38:24 点赞:0

【MC不灭工作室】闲聊无事区 中回复

呃呃呃,我和你被禁言了。你要7天,我要至少10天半个月。+封号。。。

所以你帮我处理一下后事。。。

我可能一两个月说不了话了。...

so 我拼了老命搞了钢铁侠。

所以,拜拜

886

2020-03-12T22:35:09 点赞:0

【MC不灭工作室】闲聊无事区 中回复

后台太硬啦!

 

2020-03-12T22:41:52 点赞:0

OH MY GOD!!! 中回复

应该换成英语

2020-03-13T09:12:13 点赞:0

OH MY GOD!!! 中回复

英语如下:

"Gates, I'm so sorry! ! ! My Bill Gates Simulator 2.2, and I posted a https://shequ.codemao.cn/community/257350 that says I got a perfect score in fifth-grade Chinese. Sorry

2020-03-13T09:13:15 点赞:0

我有迷你编程网址 中回复

2020-03-20T14:47:38 点赞:0

关于那个人说果果是江湖派的事 中回复

饿哦饿哦饿哦饿哦饿哦饿哦饿哦饿哦饿哦额

2020-03-21T17:00:50 点赞:0

【Python作品分享】2048小游戏 中回复

emotion_编程猫_溜了溜了

2020-07-15T16:07:44 点赞:0

找徒弟!! 中回复

我要我要。

2020-07-23T07:53:59 点赞:0

找徒弟!! 中回复

我会Python。

2020-07-23T07:54:07 点赞:0

找徒弟!! 中回复

也会Java一点点。

2020-07-23T07:54:30 点赞:0

找徒弟!! 中回复

收我为徒吧。

2020-07-23T07:54:41 点赞:0

找徒弟!! 中回复

2048

#!/usr/bin/env python3
#coding: utf-8
import numpy
import numpy as np
import random
from random import choice


class Game2048(object):
    '''2048游戏的类'''
    '''
        属性:
            self.dimension
            self.matrix
        方法:
            judge_gameover(self)
            generate_num(self)
            left_2048(self)
            right_2048(self)
            down_2048(self)
            up_2048(self)
            print_(self)
            input_(self)
    '''

    def __init__(self, dimension=4):
        self.dimension = dimension  # 维数,决定要构建几维的矩阵
        # 创建一个全是0的n(n = dimension)维矩阵
        self.matrix = np.zeros((dimension, dimension))

    def judge_gameover(self):  # 判断是否游戏结束,如果游戏结束返回True,未结束则返回False
        '''如果水平方向上任意两个相邻的数字有相等的或者有为0的那么游戏未结束'''
        for a in range(0, self.dimension):
            for b in range(0, self.dimension-1):
                if self.matrix[a][b] == self.matrix[a][b+1] or self.matrix[a][b] == 0 or self.matrix[a][b+1] == 0:
                    return False
        '''如果垂直方向上任意两个相邻的数字有相等的或者有为0的那么游戏未结束'''
        self.matrix = np.transpose(
            self.matrix)  # 先转置垂直方向变作水平方向 eg:[[1,2],[3,4]]>>[[1,3],[2,4]]
        for a in range(0, self.dimension):
            for b in range(0, self.dimension-1):
                if self.matrix[a][b] == self.matrix[a][b+1] or self.matrix[a][b] == 0 or self.matrix[a][b+1] == 0:
                    return False
        return True

    def generate_num(self):  # 在随机的空白(为0)的位置替换为1个随机的2或者4
        '''在随机的空白(为0)的位置替换为1个随机的2或者4'''

        #判断矩阵内为零的数的位置,并将索引放入到list_0中
        list_0 = []
        for a in range(0, self.dimension):
            for b in range(0, self.dimension):
                if self.matrix[a, b] == 0:
                    list_0.append([a, b])

        #判断矩阵内为0的数的个数,如果为0,那么就不再生成新的数字
        if len(list_0) != 0:
            x = random.sample(list_0, 1)[0]  # 注意random.sample()函数返回值类型为列表
            self.matrix[x[0]][x[1]] = random.randrange(2, 5, 2)

    def left_2048(self):  # 向左平移合并
        '''数字向左平移'''
        for i in range(0, self.dimension):
            list_i = list(self.matrix[i])
            while 0 in list_i:
                list_i.remove(0)
            while len(list_i) != self.dimension:
                list_i.append(0)
            self.matrix[i] = list_i

        '''水平向左合并'''
        for a in range(0, self.dimension):
            for b in range(0, self.dimension-1):
                if self.matrix[a][b] != 0 and self.matrix[a][b] == self.matrix[a][b+1]:
                    self.matrix[a][b] = 2 * self.matrix[a][b]
                    self.matrix[a][b+1] = 0
                else:
                    pass

        '''数字向左平移'''
        for i in range(0, self.dimension):
            list_i = list(self.matrix[i])
            while 0 in list_i:
                list_i.remove(0)
            while len(list_i) != self.dimension:
                list_i.append(0)
            self.matrix[i] = list_i

    def right_2048(self):  # 向右平移合并
        # 将矩阵水平方向反转 eg:[[1,2],[3,4]]>>[[2,1],[4,3]]
        for i in range(0, self.dimension):
            self.matrix[i] = self.matrix[i][::-1]
        self.left_2048()  # 注意在类中内置函数互相调用前面要加self.,也注意不要循环调用
        for i in range(0, self.dimension):  # 再将矩阵水平方向反转回来
            self.matrix[i] = self.matrix[i][::-1]

    def down_2048(self):  # 向下平移合并
        # 先上下反转 eg:[[1,2],[3,4]]>>[[3,4],[1,2]]
        self.matrix = self.matrix[::-1]
        self.up_2048()
        # 再上下反转回来eg:[[3,4],[1,2]]>>[[1,2],[3,4]]
        self.matrix = self.matrix[::-1]

    def up_2048(self):  # 向上平移合并
        # 先转置 eg:[[1,2],[3,4]]>>[[1,3],[2,4]]
        self.matrix = np.transpose(self.matrix)
        self.left_2048()
        # 再转置回来 eg:[[1,3],[2,4]]>>[[1,2],[3,4]]
        self.matrix = np.transpose(self.matrix)

    def print_2048(self):  # 显示
        for i in self.matrix:
            print(i)

    def input_2048(self):  # 输入
        while True:
            s = input("w(↑) a(←) s(↓) d(右):")
            if s == "w":
                self.up_2048()
                break
            elif s == "a":
                self.left_2048()
                break
            elif s == "s":
                self.down_2048()
                break
            elif s == "d":
                self.right_2048()
                break
            else:
                print("输入有误请重新输入")
                continue


if __name__ == '__main__':  # 主程序
    g1 = Game2048()
    g1.generate_num()
    g1.generate_num()
    g1.generate_num()
    g1.print_2048()
    while True:
        g1.input_2048()
        g1.generate_num()
        g1.print_2048()
        if g1.judge_gameover() == True:
            print("Game over")
            break

2020-07-26T08:51:58 点赞:0

我玩到1.17了233 中回复

center_image

2021-06-11T12:38:43 点赞:0

我玩到1.17了233 中回复

center_image

2021-06-11T12:38:49 点赞:0