俄罗斯方块游戏的算法实现

已经实现的功能有:

地图功能

方块 向左向右向下移动

方块旋转90、180、270、360

向下移动到底了

向下移动到底,判断是否消除行

随机添加新的方块
游戏结束
 
//俄罗斯方块:_表示空白,role是正在活动的方块,roleMap是占用的空间位置,data表示地图数据
function BinaryBlockGame(width=10,height=14){
    this.role=null
    this.roleMap=null
    this.data=new Array(height)
    for(let i=0;i<height;i++){
        this.data[i]=new Array(width).fill('_')
    }
    //生成随机方块
    this.roleList=[
        [[0,0],[1,0],[2,0],[3,0]],
    
        [[0,0],[1,0],[2,0],[0,1]],
        [[0,0],[1,0],[2,0],[1,1]],
        [[0,0],[1,0],[2,0],[2,1]],
    
        [[0,0],[1,0],[1,1],[2,1]],
        [[0,1],[1,1],[1,0],[2,0]],
    
        [[0,0],[1,0],[0,1],[1,1]],
    ]
    this.angleList=[0,90,180,270]
}
BinaryBlockGame.prototype.sin=function(R){
   
    return Math.round(Math.sin((R)) * 1000000) / 1000000;
}
BinaryBlockGame.prototype.cos=function(R){
  
    return Math.round(Math.cos((R)) * 1000000) / 1000000;
}

//是否能添加方块
BinaryBlockGame.prototype.isCanAdd=function(role){
    const data=this.data
    let isOk=true
    for(let i=0;i<role.length;i++){
        const [x,y]=role[i]
        if(data[y][x]!=="_"){
            isOk=false
            break
        }
    }
    return isOk
}

//添加方块
BinaryBlockGame.prototype.addRole=function(role){
    console.log('start:添加方块\n')
   const isOk=this.isCanAdd(role)
   if(!isOk){
    console.log('end:不能添加方块,游戏结束')
    return
   }
    const data=this.data
    const temp={}
    role.forEach(function(pos){
        const key=pos.join(',')
        data[pos[1]][pos[0]]="#"
        temp[key]=1
    })
    this.roleMap=temp
    this.role=role

    console.log('ok:添加方块\n',this.toString())
}
//生成一个随机方块
BinaryBlockGame.prototype.getRandomRole=function(){
  
    const roleList=this.roleList
    //随机生成一个方块
    const randonN=0|Math.random()*roleList.length
    const randonC=0|Math.random()*roleList[randonN].length
    const randonA=0|Math.random()*4
    const rRole=roleList[randonN]
    const R=this.angleList[randonA]*Math.PI/180
    const role=[]

    const cx=rRole[randonC][0]
    const cy=rRole[randonC][1]
    const the=this
    let minX=0
    let minY=0
    const mid=(this.data[0].length>>1)-cx
    rRole.forEach(function(pos,i){
        const tx=pos[0]-cx;
        const ty=pos[1]-cy;

        const nx=tx*the.cos(R)-ty*the.sin(R)+cx
        const ny=tx*the.sin(R)+ty*the.cos(R)+cy
        if(nx<minX){
            minX=nx
        }
        if(ny<minY){
            minY=ny
        }
        if(i===randonC){
            role.unshift([nx,ny])
        }else{
            role.push([nx,ny])
        }
    })
    role.forEach(function(pos){
        pos[0]=pos[0]-minX+mid
        pos[1]=pos[1]-minY
    })
    return role
}
//随机添加一个方块
BinaryBlockGame.prototype.addNewRole=function(){
    const role=this.getRandomRole()
    console.log('addNewRole',role)
    this.addRole(role)
}
//R是弧度
BinaryBlockGame.prototype.isCanRotate=function(R){
    const data=this.data
    const roleMap=this.roleMap
    const role=this.role
    let isOk=true
    const cx=role[0][0]
    const cy=role[0][1]
    for(let i=1;i<role.length;i++){
        const tx=role[i][0]-cx;
        const ty=role[i][1]-cy;

        const nx=tx*this.cos(R)-ty*this.sin(R)+cx
        const ny=tx*this.sin(R)+ty*this.cos(R)+cy
        const key=[nx,ny].join(',')
        if(!(roleMap[key]||data[ny][nx]==='_')){
            isOk=false
            break
        }
    }
    return isOk
}
BinaryBlockGame.prototype.rotate=function(A){
   
    if(!this.role){console.log('不存在可旋转的方块');return}
    const R=Math.PI*A/180
    const isOk=this.isCanRotate(R)
    console.log('rotate->',A,isOk)
    if(isOk){
        const roleMap=this.roleMap
        const role=this.role
        const data=this.data
        role.forEach(function(pos){
            const key=pos.join(',')
            data[pos[1]][pos[0]]="_"
            roleMap[key]--
        })
        const cx=role[0][0]
        const cy=role[0][1]
        this.role.forEach((pos)=>{
            const tx=pos[0]-cx;
            const ty=pos[1]-cy;

            const nx=tx*this.cos(R)-ty*this.sin(R)+cx
            const ny=tx*this.sin(R)+ty*this.cos(R)+cy
            pos[0]=nx
            pos[1]=ny
            const nkey=pos.join(',')
            data[pos[1]][pos[0]]="#"
            if(!roleMap[nkey]){
                roleMap[nkey]=1
            }else{
                roleMap[nkey]++
            }
        })
        console.log(this.toString())
    }
   
}
BinaryBlockGame.prototype.isCanMove=function(x,y){
    const data=this.data
    const roleMap=this.roleMap
    const role=this.role
    let isOk=true
    for(let i=0;i<role.length;i++){
        const nx=role[i][0]+x
        const ny=role[i][1]+y
        const key=[nx,ny].join(',')
        if(!(roleMap[key]||data[ny]&&data[ny][nx]==='_')){
            isOk=false
            break
        }
    }
    return isOk
}
BinaryBlockGame.prototype.move=function(x,y){
   
    if(!this.role){console.log('不存在可移动的方块');return}
    const isOk=this.isCanMove(x,y)
    console.log('move->',x,y,isOk)
    if(isOk){
        const roleMap=this.roleMap
        const data=this.data
        const height=data.length
        const width=data[0].length
        this.role.forEach(function(pos){
            if(pos[1]>-1&&pos[0]>-1&&pos[1]<height&&pos[0]<width){
                const key=pos.join(',')
                data[pos[1]][pos[0]]="_"
                roleMap[key]--
            }
        })
        this.role.forEach(function(pos){
            pos[0]=pos[0]+x
            pos[1]=pos[1]+y
            if(pos[1]>-1&&pos[0]>-1&&pos[1]<height&&pos[0]<width){
                const nkey=pos.join(',')
                data[pos[1]][pos[0]]="#"
                if(!roleMap[nkey]){
                    roleMap[nkey]=1
                }else{
                    roleMap[nkey]++
                }
            }
        })
        console.log(this.toString())
    }else if(y===1){
        console.log('向下移动到底,判断是否消除行,以及随机添加新的方块')
        this.clearBlock()
        this.addNewRole()
    }
}
BinaryBlockGame.prototype.clearBlock=function(){
    const role=this.role
    const data=this.data
    const height=data.length
    const width=data[0].length
    const fArr=[]
    role.forEach(function(pos){
        const y=pos[1]
        if(fArr.indexOf(y)===-1){
            let isFill=true
            for(let i=0;i<data[y].length;i++){
                if(data[y][i]==='_'){
                    isFill=false
                    break;
                }
            }
            if(isFill){
                fArr.push(y)
            }
        }
    })
    this.role=null
    this.roleMap=null
    console.log('被消除掉的行有',fArr)
    if(fArr.length>0){
        let left=0
        let right=fArr.length
        for(let i=0;i<height;i++){
            if(fArr.indexOf(i)===-1){
                console.log('移动行',i,start)
                data[right]=data[i]
                right++
            }else{
                data[left]=new Array(width).fill('_')
                left++
            }
        }
        console.log(this.toString())
    }
}
BinaryBlockGame.prototype.down=function(){
    clearTimeout(this.inter)
    if(this.role){
        //向下移动
        this.move(0,1)
        this.inter=setTimeout(()=>{
           this.down()
       },1000)
    }else{
        console.log('游戏已结束')
    }
}
BinaryBlockGame.prototype.toString=function(){
    let str=''
    const data=this.data
    
    for(let i=0;i<data.length;i++){
        str=str+data[i].join(',')+'\n'
    }
    return str
    
}
const game=new BinaryBlockGame()


//添加方块
game.addNewRole()
//向左移动
game.move(-1,0)

//向右移动
game.move(1,0)

//向左移动
game.move(-1,0)
//旋转90度
game.rotate(90)
//向下移动
game.down()
View Code

C:\Program Files\nodejs\node.exe .\BinaryBlock.js
addNewRole (4) [Array(2), Array(2), Array(2), Array(2)]
start:添加方块
ok:添加方块
_,_,_,_,_,#,_,_,_,_
_,_,_,_,_,#,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
move-> -1 0 true
_,_,_,_,#,_,_,_,_,_
_,_,_,_,#,_,_,_,_,_
_,_,_,_,#,#,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,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_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 false
向下移动到底,判断是否消除行,以及随机添加新的方块
被消除掉的行有 (0) []
addNewRole (4) [Array(2), Array(2), Array(2), Array(2)]
start:添加方块
ok:添加方块
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 true
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 true
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 true
_,_,_,_,_,_,_,_,_,_
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_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 false
向下移动到底,判断是否消除行,以及随机添加新的方块
被消除掉的行有 (0) []
addNewRole (4) [Array(2), Array(2), Array(2), Array(2)]
start:添加方块
ok:添加方块
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 true
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 true
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,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_,_,_,_,_,#,_,_,_,_
move-> 0 1 true
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 false
向下移动到底,判断是否消除行,以及随机添加新的方块
被消除掉的行有 (0) []
addNewRole (4) [Array(2), Array(2), Array(2), Array(2)]
start:添加方块
ok:添加方块
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,_,_,#,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 true
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,_,_,#,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 true
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,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#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 true
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 false
向下移动到底,判断是否消除行,以及随机添加新的方块
被消除掉的行有 (0) []
addNewRole (4) [Array(2), Array(2), Array(2), Array(2)]
start:添加方块
ok:添加方块
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 true
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 true
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 true
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 true
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 false
向下移动到底,判断是否消除行,以及随机添加新的方块
被消除掉的行有 (0) []
addNewRole (4) [Array(2), Array(2), Array(2), Array(2)]
start:添加方块
ok:添加方块
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,#,_,_,_,_
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 true
_,_,_,_,_,_,_,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,#,_,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,_,#,_,_,_
_,_,_,_,_,#,#,_,_,_
_,_,_,_,_,_,#,#,_,_
_,_,_,_,_,#,#,#,_,_
_,_,_,_,_,#,_,_,_,_
move-> 0 1 false
向下移动到底,判断是否消除行,以及随机添加新的方块
被消除掉的行有 (0) []
addNewRole (4) [Array(2), Array(2), Array(2), Array(2)]
start:添加方块
fail:不能添加方块,游戏结束
游戏已结束

posted @ 2024-07-18 14:36  无工时代  阅读(10)  评论(0编辑  收藏  举报