Skip to content

Commit b4e34d4

Browse files
committed
listo jugada inicial 3 niveles
1 parent e7196b9 commit b4e34d4

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

AppHex.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import problemContainer from './modelHex/problemContainer';
1515
import {HexAgent, HexAgentRandom} from './modelHex/HexAgent';
1616

1717
problemContainer.addAgent("1", HexAgent, { play: true });
18-
problemContainer.addAgent("2", HexAgentRandom, { play: false });
18+
problemContainer.addAgent("2", HexAgent, { play: false });
1919

2020
const App = observer(class App extends Component {
2121
constructor(props) {

modelHex/HexAgent.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,28 @@ class HexAgent extends Agent {
3232
};
3333
send() {
3434
//error raro
35-
var t0 = performance.now();
35+
//var t0 = performance.now();
3636
var board = this.perception.map(function (arr) { return arr.slice(); })
37-
console.log(board)
37+
let size = board.length;
38+
let available = getEmptyHex(board);
39+
let nTurn = size * size - available.length;
40+
if (nTurn == 0) { // First move
41+
return [Math.floor(size / 2) - 1, Math.floor(size / 2) + 1 ];
42+
}
43+
if(nTurn == 1){
44+
return [Math.floor(size / 2) + 1, Math.floor(size / 2) - 1 ];
45+
}
3846
//const board = this.perception;
3947
//console.log(this.perception)
4048
//console.log("costo del padre")
4149
//console.log(dummyNode)
4250
let depth = 3;
4351
let max_player = true;
44-
console.log("entra a minimax")
52+
//console.log("entra a minimax")
4553
let bestValue = this.minimax(board, depth, max_player);
46-
var t1 = performance.now();
47-
console.log("BESTVALUE", bestValue);
48-
console.log("tiempo ms", t1 - t0);
54+
//var t1 = performance.now();
55+
//console.log("BESTVALUE", bestValue);
56+
//console.log("tiempo ms", t1 - t0);
4957
return [Math.floor(bestValue / board.length), bestValue % board.length];
5058
}
5159
/**minimax */
@@ -97,6 +105,7 @@ class HexAgent extends Agent {
97105
var babyNodeAlphaOne = new Node(babyboardAlphaOne, dummyNode.idAgent, childNodeBetaOne, 99);//yo
98106
//console.log("dijkstra babynodealphaone")
99107
babyNodeAlphaOne.calculateHeuristic(babyNodeAlphaOne.idAgent,babyNodeAlphaOne.board);
108+
//console.log("nivel 3")
100109
//if (primerNivel === 1){
101110
//console.log("tercer nivel, hijos: ", moveChild, "h: ", babyNodeAlphaOne.heuristic)
102111
//}
@@ -121,12 +130,12 @@ class HexAgent extends Agent {
121130
break;
122131
}
123132
}
124-
console.log("beta one move:",move, "heu", betaOne.heuristic)
133+
//console.log("beta one move:",move, "heu", betaOne.heuristic)
125134
if (betaOne.heuristic > dummyNode.heuristic) {
126135
//console.log("dummy antes", dummyNode.heuristic)
127136
dummyNode.heuristic = betaOne.heuristic;
128137
choice = move;
129-
console.log("choice", choice, ":", dummyNode.heuristic)
138+
//console.log("choice", choice, ":", dummyNode.heuristic)
130139
//console.log("choice", choice, "heuristica ,", betaOne.heuristic);
131140
}
132141
}

0 commit comments

Comments
 (0)