gemini1.5pro

简介: gemini1.5pro


生命的定义就是拥有明天。——冯骥才

google的gemini1.5pro免费用

https://aistudio.google.com/app/prompts/new_chat

非常好用,快赶上gpt4了

回答如下:

HTML 代码:

<!DOCTYPE html>
<html>
<head>
  <title>2048</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
<h1>2048</h1>
<div class="container">
  <div class="grid">
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
  </div>
</div>
<script src="main.js"></script>
</body>
</html>

content_copyUse code with caution.Html

CSS 代码(style.css):

body {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
}
h1 {
  text-align: center;
  margin-top: 50px;
}
.container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: calc(100vh - 100px);
}
.grid {
  display: grid;
  grid-template-columns: repeat(4, 100px);
  grid-template-rows: repeat(4, 100px);
  grid-gap: 20px;
}
.cell {
  width: 100px;
  height: 100px;
  border-radius: 5px;
  background-color: #ccc;
  font-size: 30px;
  text-align: center;
  line-height: 100px;
}

content_copyUse code with caution.Css

JavaScript 代码(main.js):

const grid = document.querySelector('.grid');
const cells = Array.from(document.querySelectorAll('.cell'));
let gridData = [
  [0, 0, 0, 0],
  [0, 0, 0, 0],
  [0, 0, 0, 0],
  [0, 0, 0, 0]
];
function generateRandomNumber() {
  return Math.random() < 0.9 ? 2 : 4;
}
function generateRandomCell() {
  const emptyCells = cells.filter(cell => cell.textContent === '');
  const randomIndex = Math.floor(Math.random() * emptyCells.length);
  emptyCells[randomIndex].textContent = generateRandomNumber();
}
function moveUp() {
  for (let col = 0; col < 4; col++) {
    for (let row = 1; row < 4; row++) {
      if (gridData[row][col] !== 0) {
        let currentRow = row;
        while (currentRow > 0 && gridData[currentRow - 1][col] === 0) {
          gridData[currentRow - 1][col] = gridData[currentRow][col];
          gridData[currentRow][col] = 0;
          currentRow--;
        }
      }
    }
  }
}
function moveDown() {
  for (let col = 0; col < 4; col++) {
    for (let row = 2; row >= 0; row--) {
      if (gridData[row][col] !== 0) {
        let currentRow = row;
        while (currentRow < 3 && gridData[currentRow + 1][col] === 0) {
          gridData[currentRow + 1][col] = gridData[currentRow][col];
          gridData[currentRow][col] = 0;
          currentRow++;
        }
      }
    }
  }
}
function moveLeft() {
  for (let row = 0; row < 4; row++) {
    for (let col = 1; col < 4; col++) {
      if (gridData[row][col] !== 0) {
        let currentCol = col;
        while (currentCol > 0 && gridData[row][currentCol - 1] === 0) {
          gridData[row][currentCol - 1] = gridData[row][currentCol];
          gridData[row][currentCol] = 0;
          currentCol--;
        }
      }
    }
  }
}
function moveRight() {
  for (let row = 0; row < 4; row++) {
    for (let col = 2; col >= 0; col--) {
      if (gridData[row][col] !== 0) {
        let currentCol = col;
        while (currentCol < 3 && gridData[row][currentCol + 1] === 0) {
          gridData[row][currentCol + 1] = gridData[row][currentCol];
          gridData[row][currentCol] = 0;
          currentCol++;
        }
      }
    }
  }
}
function updateGrid() {
  cells.forEach((cell, index) => {
    cell.textContent = gridData[Math.floor(index / 4)][index % 4];
  });
}
function handleKeyDown(e) {
  switch (e.key) {
    case 'ArrowUp':
      moveUp();
      break;
    case 'ArrowDown':
      moveDown();
      break;
    case 'ArrowLeft':
      moveLeft();
      break;
    case 'ArrowRight':
      moveRight();
      break;
  }
  generateRandomCell();
  updateGrid();
}
generateRandomCell();
generateRandomCell();
updateGrid();
document.addEventListener('keydown', handleKeyDown);

content_copyUse code with caution.JavaScript

使用方法:

  1. 将上面的代码保存为 HTML、CSS 和 JavaScript 文件。
  2. 在浏览器中打开 HTML 文件。
  3. 使用箭头键玩游戏。

注意:

  • 此代码是一个基本的 2048 游戏实现,你可以根据需要进行自定义。
  • 游戏的样式可以通过 CSS 代码进行调整。
相关文章
|
9月前
|
存储 人工智能 安全
科技云报到:“龙虾”OpenClaw狂欢之下,需要一针清醒剂
《科技云报到》原创深度观察:国产AI智能体OpenClaw(“龙虾”)爆火出圈,国内话题播放超数十亿,成“国民级”现象;但海外却反响寥寥——本质是市场阶段错位:国内填补“能落地AI”空白,硅谷已处红海。其“一键提效”背后实则门槛不低、安全隐忧突出。热潮之下,更需理性审视能力边界与数据风险。(239字)
439 1
|
设计模式 缓存 前端开发
一款清新优雅的中后台模板,内置丰富可配置的主题(强烈推荐)
Soybean Admin 是一个基于 Vue3、Vite3、TypeScript、NaiveUI、Pinia 和 UnoCSS 的清新优雅的中后台模版,它使用了最新的前端技术栈,内置丰富的主题配置,有着极高的代码规范,基于 mock 实现的动态权限路由,开箱即用的中后台前端解决方案,也可用于学习参考。
|
Kubernetes 容器
k8s集群—node节点的删除与添加
k8s集群—node节点的删除与添加
1568 0
|
3月前
|
人工智能 自然语言处理 安全
阿里云AI数智鉴密:AI 生成内容如何拿到一张"防篡改的身份证"
隐形水印 + C2PA签名:让AI生成内容“持证上岗”。
1634 0
Qoder CN在哪里购买?需要阿里云账号吗?个人版和企业版QoderCN订阅说明
Qoder CN购买需阿里云账号:个人版可在qoder.com.cn直接购(支持手机号自动注册);企业Teams版由采购人在阿里云控制台下单。原灵码版本则统一在阿里云Qoder CN官网订阅,全程使用阿里云账号。阿里云Qoder CN官网:https://t.aliyun.com/U/fEiOLV
|
5月前
|
运维 监控 网络协议
阿里云国际站代理商:DDoS高防配置后仍被攻击?
不少运维团队都遇到过同一个困惑:明明买了阿里云DDoS高防,策略也配好了,但攻击一来,业务照样中断,工单来回沟通却找不到根因。这类“阿里云DDoS高防配置后仍被攻击”的排查,核心往往不在高防本身,而在于源站真实IP的暴露以及回源链路的隐患。
|
缓存 Java 数据库连接
我们来说一下 Mybatis 的缓存机制
我是小假 期待与你的下一次相遇 ~
676 6
|
负载均衡 应用服务中间件 nginx
Nginx配置与命令
Nginx 是一款高性能的 HTTP 和反向代理服务器,其配置文件灵活且功能强大。本文介绍了 Nginx 配置的基础结构和常用指令,包括全局块、Events 块、HTTP 块及 Server 块的配置方法,以及静态资源服务、反向代理、负载均衡、HTTPS 和 URL 重写等功能实现。此外,还提供了常用的 Nginx 命令操作,如启动、停止、重载配置和日志管理等,帮助用户高效管理和优化服务器性能。
1521 14