Skip to content

Commit

Permalink
implement difficult settings
Browse files Browse the repository at this point in the history
  • Loading branch information
CortezSMz committed Apr 11, 2022
1 parent 7d592d0 commit 53340e6
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 30 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@

# Connect Four

3D Connect Four game made with Three.js, TypeScript and Vue for UI. Play agains a minimax algorithm.
3D Connect Four game made with Three.js, TypeScript and Vue for UI. Play against a minimax algorithm.

## [Live demo](https://connectfour.alexandrecortez.dev/)

## To Do
- [ ] Minimax
- [x] Implement minimax to play as yellow
- [ ] Implement difficult settings (how many plays on the future does it see)
- [ ] Optimize algorithm
- [ ] Make it optional to play agains minimax - to control both discs and play locally
- [ ] Polish UI
- [ ] Include more animations
- [ ] Better ending screen

- [ ] Minimax
- [x] Implement minimax to play as yellow
- [x] Implement difficult settings (how many plays on the future does it see)
- [ ] Optimize algorithm
- [ ] Make it optional to play against minimax - to control both discs and play locally
- [ ] Polish UI
- [ ] Include more animations
- [ ] Better ending screen

## Inspiration

This app is inspired by [Areknawo's 2048](https://github.com/areknawo/2048).
70 changes: 51 additions & 19 deletions src/components/Controls.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<v-footer color="primary" app>
<v-row justify="center" align="center" class="footer-row text-center">
<!-- Github link -->
<v-col cols="2">
<v-btn
light
Expand All @@ -19,17 +20,30 @@
</v-btn>
</v-col>

<!-- Title -->
<v-col cols="8">
<strong>Connect Four</strong>
</v-col>

<!-- Controls -->
<v-col cols="2">
<v-bottom-sheet
v-model="controls"
:persistent="finished"
eager
overlay-opacity="0.05"
>
<template v-slot:activator="{ on, attrs }">
<v-btn light fab small v-bind="attrs" v-on="on">
<font-awesome-icon
icon="gear"
size="2x"
:style="{ color: 'var(--v-primary-base)' }"
/>
</v-btn>
</template>

<!-- Finish alert -->
<v-alert v-model="finished" class="text-center" color="primary">
{{
this.$parent.manager.state.finished
Expand All @@ -41,15 +55,8 @@
: ""
}}
</v-alert>
<template v-slot:activator="{ on, attrs }">
<v-btn light fab small v-bind="attrs" v-on="on">
<font-awesome-icon
icon="gear"
size="2x"
:style="{ color: 'var(--v-primary-base)' }"
/>
</v-btn>
</template>

<!-- Sheet -->
<v-sheet class="footer-sheet" color="primary">
<v-row align="center" justify="center">
<v-col cols="12">
Expand All @@ -59,7 +66,24 @@
horizontal, vertical, or diagonal line of four discs.
</p>
</v-col>
<v-col cols="12">
<v-col cols="10" lg="6">
<v-slider
:readonly="finished"
v-model="$parent.manager.minimax.depth"
color="secondary"
label="Difficult"
min="1"
max="8"
thumb-label="always"
persistent-hint
:hint="difficultHint"
>
<template v-slot:thumb-label="{ value }">
<span class="v-btn">{{ value }}</span>
</template>
</v-slider>
</v-col>
<v-col cols="auto">
<v-btn class="footer-btn" rounded light @click="resetCamera"
>Reset camera</v-btn
>
Expand All @@ -68,15 +92,6 @@
>
</v-col>
</v-row>
<v-row align="center" justify="center">
<v-btn class="footer-btn" small light fab v-if="false">
<font-awesome-icon
icon="save"
size="2x"
:style="{ color: 'var(--v-primary-base)' }"
/>
</v-btn>
</v-row>
</v-sheet>
</v-bottom-sheet>
</v-col>
Expand All @@ -96,6 +111,23 @@ import { Watch } from "vue-property-decorator";
finished() {
return this.$parent.manager.state.finished;
},
difficultHint() {
const difficult: Record<number, string> = {
1: "passive",
2: "passive",
3: "easy",
4: "easy",
5: "moderate",
6: "moderate",
7: "tougher",
8: "tougher",
};
return `AI will test ${
this.$parent.manager.minimax.depth
} plays in the future. (${
difficult[this.$parent.manager.minimax.depth]
})`;
},
},
})
export default class Controls extends Vue {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/vuetify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default new Vuetify({
themes: {
dark: {
primary: "#4e79f4",
secondary: "#FF0000",
secondary: "#FFFFFF",
},
},
},
Expand Down

0 comments on commit 53340e6

Please sign in to comment.