Skip to content

Commit 7566271

Browse files
committed
add ai
1 parent 475be08 commit 7566271

6 files changed

Lines changed: 933 additions & 29 deletions

File tree

347 Bytes
Loading
137 Bytes
Loading
176 Bytes
Loading

src/components/GameSetup.vue

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,29 @@
5959
</div>
6060
</div>
6161

62+
<!-- AI 风格设置(仅人机对战) -->
63+
<div v-if="gameMode === 'ai'" class="setup-section">
64+
<h3>AI 风格</h3>
65+
<div class="option-group">
66+
<label class="option-card" :class="{ active: aiStyle === 'balanced' }">
67+
<input v-model="aiStyle" type="radio" value="balanced" />
68+
<span>均衡</span>
69+
</label>
70+
<label class="option-card" :class="{ active: aiStyle === 'aggressive' }">
71+
<input v-model="aiStyle" type="radio" value="aggressive" />
72+
<span>进攻</span>
73+
</label>
74+
<label class="option-card" :class="{ active: aiStyle === 'defensive' }">
75+
<input v-model="aiStyle" type="radio" value="defensive" />
76+
<span>防守</span>
77+
</label>
78+
<label class="option-card" :class="{ active: aiStyle === 'unpredictable' }">
79+
<input v-model="aiStyle" type="radio" value="unpredictable" />
80+
<span>出其不意</span>
81+
</label>
82+
</div>
83+
</div>
84+
6285
<div class="setup-section">
6386
<h3>执棋方</h3>
6487
<div class="option-group">
@@ -94,6 +117,8 @@
94117
<script setup lang="ts">
95118
import { ref } from 'vue'
96119
120+
export type AIStyle = 'balanced' | 'aggressive' | 'defensive' | 'unpredictable'
121+
97122
export interface GameSetupConfig {
98123
boardMode: 'standard' | 'custom'
99124
fen: string
@@ -102,6 +127,7 @@ export interface GameSetupConfig {
102127
starter: 'black' | 'random' | 'white'
103128
gameMode: 'ai' | 'human' | 'remote'
104129
difficulty: number
130+
aiStyle: AIStyle
105131
}
106132
107133
const emit = defineEmits<{
@@ -112,6 +138,7 @@ const emit = defineEmits<{
112138
const screen = ref<'home' | 'setup'>('home')
113139
const gameMode = ref<'ai' | 'human' | 'remote'>('ai')
114140
const difficulty = ref(3)
141+
const aiStyle = ref<AIStyle>('balanced')
115142
116143
const boardMode = ref<'standard' | 'custom'>('standard')
117144
const fenInput = ref('')
@@ -154,6 +181,7 @@ const handleStart = () => {
154181
starter: starter.value,
155182
gameMode: gameMode.value,
156183
difficulty: difficulty.value,
184+
aiStyle: aiStyle.value,
157185
})
158186
}
159187
</script>

0 commit comments

Comments
 (0)