js实现ai人机对战围棋游戏代码

代码语言:html

所属分类:游戏

代码描述:js实现ai人机对战围棋游戏代码,有详细的分析数据

代码标签: js ai 人机 对战 围棋 游戏 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>随机 • 围棋道场 × AI分析</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<!-- 增加了 Noto Serif SC 和 Noto Sans SC 以支持优美的中文显示 -->
<link href="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,500&family=Spline+Sans:wght@300;400;500;600;700&family=Noto+Serif+JP:wght@400;500;700;900&family=Noto+Serif+SC:wght@400;500;700;900&family=Noto+Sans+SC:wght@300;400;500;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
:root {
  --bg: #f1e7cd;
  --bg-2: #ebdfc0;
  --paper: #faf2dc;
  --paper-2: #f3e9cc;
  --paper-dark: #e6d9b5;
  --board: #d8aa6e;
  --board-dark: #b88a4f;
  --ink: #1f1410;
  --ink-2: #4a3220;
  --ink-3: #7a5a3a;
  --ink-light: #9c7e5a;
  --accent: #a52828;
  --accent-2: #c8a838;
  --accent-deep: #6b1818;
  --gold: #b8860b;
  --line: rgba(60, 35, 15, 0.18);
  --shadow: rgba(60, 35, 15, 0.18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

body {
  /* 优先使用中文无衬线字体 */
  font-family: 'Spline Sans', 'Noto Sans SC', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  background-image: 
    radial-gradient(at 8% 12%, rgba(165, 40, 40, 0.04) 0, transparent 35%),
    radial-gradient(at 92% 88%, rgba(120, 80, 40, 0.08) 0, transparent 40%),
    radial-gradient(at 50% 50%, rgba(220, 180, 120, 0.04) 0, transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.32 0 0 0 0 0.21 0 0 0 0 0.1 0 0 0 0.06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  overflow-x: hidden;
}

/* 中文衬线字体类 */
.font-serif { font-family: 'Cormorant Garamond', 'Noto Serif SC', serif; }
.font-jp { font-family: 'Noto Serif JP', 'Noto Serif SC', serif; }
.font-mono { font-family: 'JetBrains Mono', monospace; }

.app { max-width: 1480px; margin: 0 auto; padding: 20px 28px 100px; }

/* ============ HEADER ============ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 24px;
  position: relative;
}
.header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent) 50%, transparent);
  opacity: 0.5;
}

.brand { display: flex; align-items: center; gap: 16px; }
.brand .seal {
  width: 54px; height: 54px;
  background: var(--accent);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--paper);
  font-family: 'Noto Serif JP', 'Noto Serif SC', serif;
  font-weight: 900;
  font-size: 26px;
  letter-spacing: -0.05em;
  transform: rotate(-3deg);
  box-shadow: 0 4px 12px rgba(165, 40, 40, 0.3), inset 0 0 0 2px rgba(255,255,255,0.1);
  position: relative;
}
.brand .seal::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 3px;
}
.brand h1 {
  font-family: 'Cormorant Garamond', 'Noto Serif SC', serif;
  font-weight: 600;
  font-size: 38px;
  letter-spacing: 0.01em;
  margin: 0;
  line-height: 1;
  color: var(--ink);
}
.brand .tagline {
  font-size: 11px;
  color: var(--ink-light);
  letter-spacing: 0.15em; /* 调整字间距以适应中文 */
  font-weight: 500;
  margin-top: 4px;
}
.brand .tagline .dot { color: var(--accent); margin: 0 6px; }

/* Rank selector */
.rank-selector {
  display: flex;
  gap: 10px;
  align-items: center;
}
.rank-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 8px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  user-select: none;
}
.rank-badge:hover { transform: translateY(-2px); box-shadow: 0 8px 20px var(--shadow); }
.rank-badge.active { 
  background: var(--ink); 
  color: var(--paper);
  border-color: var(--ink);
  box-shadow: 0 8px 24px rgba(31, 20, 16, 0.3);
}
.rank-badge.active .label .meta { color: rgba(250, 242, 220, 0.6); }
.rank-badge .medal {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Noto Serif JP', 'Noto Serif SC', serif;
  font-weight: 700;
  font-size: 15px;
  color: white;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), inset 0 -2px 4px rgba(0,0,0,0.2), 0 2px 4px rgba(0,0,0,0.15);
  position: relative;
}
.rank-badge[data-level="1"] .medal {
  background: linear-gradient(135deg, #c0c0c8, #6a6a72);
  color: #f8f8fc;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}
.rank-badge[data-level="2"] .medal {
  background: linear-gradient(135deg, #d68b3c, #8b4513);
  color: #fff5e0;
}
.rank-badge[data-level="3"] .medal {
  background: linear-gradient(135deg, #ffd96b, #b8860b);
  color: #4a2a00;
}
.rank-badge .label {
  display: flex; flex-direction: column;
  line-height: 1.15;
}
.rank-badge .label .name { font-size: 13px; font-weight: 600; letter-spacing: 0.01em; }
.rank-badge .label .meta { font-size: 10px; color: var(--ink-light); letter-spacing: 0.05em; }

/* ============ MAIN GRID ============ */
.main-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: start;
}
@media (max-width: 1180px) {
  .main-grid { grid-template-columns: 260px 1fr; }
  .right-col { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
}
@media (max-width: 820px) {
  .main-grid { grid-template-columns: 1fr; }
  .right-col { grid-column: 1; grid-template-columns: 1fr; }
  .app { padding: 16px 16px 100px; }
  .brand h1 { font-size: 30px; }
}

/* ============ PANELS ============ */
.panel {
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 2px 10px rgba(60, 35, 15, 0.05), inset 0 1px 0 rgba(255,255,255,0.4);
  position: relative;
}
.panel + .panel { margin-top: 16px; }
.panel-title {
  font-family: 'Cormorant Garamond', 'Noto Serif SC', serif;
  font-weight: 600;
  font-size: 17px;
  color: var(--ink);
  margin: 0 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  letter-spacing: 0.01em;
}
.panel-title .panel-sub {
  font-family: 'Spline Sans', 'Noto Sans SC', sans-serif;
  font-size: 9.5px;
  font-weight: 500;
  color: var(--ink-light);
  background: var(--paper-dark);
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}
.panel-title .panel-sub.live::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 6px;
  animation: liveBlink 1.6s ease-in-out infinite;
}
@keyframes liveBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Info rows */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding: 5px 0;
}
.info-row + .info-row { border-top: 1px dashed var(--line); }
.info-row .label { color: var(--ink-3); letter-spacing: 0.02em; }
.info-row .value { font-weight: 600; color: var(--ink); }
.info-row .value.mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }

/* ============ BOARD ============ */
.board-section { min-width: 0; }
.board-wrap {
  background: linear-gradient(180deg, var(--paper) 0%, var(--paper-2) 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 18px 22px;
  box-shadow: 0 10px 30px var(--shadow);
  position: relative;
}
.board-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.player-tags { display: flex; gap: 10px; }
.player-tag {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px 7px 8px;
  background: var(--paper-dark);
  border-radius: 999px;
  font-size: 13px;
  color: var(--ink-2);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}
.player-tag.active { 
  background: var(--ink); 
  color: var(--paper);
  bor.........完整代码请登录后点击上方下载按钮下载查看

网友评论0