Skip to content

Commit 0e9ad6b

Browse files
committed
The bot is mush more clever now
1 parent 896cd49 commit 0e9ad6b

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

debug.log

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[0118/144727:ERROR:tcp_listen_socket.cc(76)] Could not bind socket to 127.0.0.1:6004
2+
[0118/144727:ERROR:node_debugger.cc(86)] Cannot start debugger server

index.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
<div id="field-outer">
1616
<div id="field">
1717
<div v-for="(r, rIndex) in rows" class="row">
18-
<div v-for="(c, cIndex) in cols" class="col" v-bind:class="{'selectable': selectedFigure && isColSelectable(rIndex, cIndex) && !selectedFigure.moveDirection}" v-on:click="selectCol(rIndex, cIndex)">
19-
<span style="color:white;background:black">r{{rIndex}} c{{cIndex}}</span>
18+
<div v-for="(c, cIndex) in cols" class="col"
19+
v-bind:class="{'selectable': selectedFigure && isColSelectable(rIndex, cIndex) && !selectedFigure.moveDirection}"
20+
v-bind:id="'col-r' + rIndex + '-c' + cIndex"
21+
v-on:click="selectCol(rIndex, cIndex)">
22+
<!--<span style="color:white;background:black">r{{rIndex}} c{{cIndex}}</span>-->
2023
<template v-for="(f, fIndex) in figures">
2124
<div v-if="f.coordination.r == rIndex && f.coordination.c == cIndex"
2225
v-bind:class="[{'active': currentFigure && currentFigure.id == f.id, 'focus': focusedFigure && focusedFigure.id == f.id }, 'team-' + f.team, 'orientation-' + f.orientation, 'move-' + f.moveDirection]"
@@ -64,10 +67,6 @@
6467
v-on:click="doAction(a)">
6568
{{a.id}}
6669
</button>
67-
68-
<button type="button" v-on:click="getClosestRivalFigure()">
69-
Choose closest rival figure
70-
</button>
7170
</div>
7271

7372
<template v-if="currentFigure && selectedAction && !showOrientationControls && !isMoving">

script/main.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ var bot = {
137137
}
138138

139139
setTimeout(function() {
140-
app.chooseOrientation("top");
140+
app.chooseOrientation(app.currentFigure.orientation);
141141
}, 1000);
142142
}
143143
};
@@ -259,6 +259,12 @@ var app = new Vue({
259259
var diffC = Math.abs(sC - cIndex);
260260

261261
var retVal = (diffR + diffC) <= app.selectedAction.range;
262+
if (retVal && app.selectedAction.id == "move") {
263+
retVal = !document.querySelector("#col-r" + rIndex + "-c" + cIndex + " .figure");
264+
}
265+
else if (retVal) {
266+
retVal = document.querySelector("#col-r" + rIndex + "-c" + cIndex + " .figure");
267+
}
262268
if (retVal) {
263269
data.selectedCols.push({r: rIndex, c: cIndex});
264270
}
@@ -518,6 +524,7 @@ var app = new Vue({
518524
document.removeEventListener("selectedOrientation", callback.orientationChange, false);
519525
if (isSubTurn || app.selectedAction.id == "wait") {
520526
// End turn and change figure
527+
app.focusFigure(app.focusedFigure);
521528
app.turn(figureIndex+1);
522529
}
523530
else {

script/teams.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var teams = {
22
teams: [
33
{
4-
id: "GoodBot",
4+
id: "Good",
55
color: "#52A7C6"
66
},
77
{

0 commit comments

Comments
 (0)