From 8261f52e121dbda98bac9fd60cd0947fb5005fa4 Mon Sep 17 00:00:00 2001 From: Hugh Barney Date: Fri, 29 Sep 2023 19:43:29 +0100 Subject: [PATCH] oxofocus fixed issue with one of the corner moves --- apps/oxofocus/ChangeLog | 1 + apps/oxofocus/app.js | 15 ++++++++------- apps/oxofocus/metadata.json | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/oxofocus/ChangeLog b/apps/oxofocus/ChangeLog index 6728683c8..faeeb9de4 100644 --- a/apps/oxofocus/ChangeLog +++ b/apps/oxofocus/ChangeLog @@ -1 +1,2 @@ 0.01: first version +0.02: fixed issue with corner move, taking an occupied cell diff --git a/apps/oxofocus/app.js b/apps/oxofocus/app.js index 5b02116e6..eb820f0df 100644 --- a/apps/oxofocus/app.js +++ b/apps/oxofocus/app.js @@ -224,8 +224,9 @@ function computer_move() { if (win_count > 7) { if (player_has_corner_and_centre("X")) { - mv = get_a_corner_move(); - if (mv != -1) { + mvs = get_free_corner(); + if (mvs.length > 0) { + mv = select_random_move_from(mvs); make_my_move(mv); debug("RULE 7: compluter played a corner"); return; @@ -246,7 +247,7 @@ function computer_move() { // default rule mvs = get_free_cells(); mv = select_random_move_from(mvs); - debug("RULE 8: computer played a random cell"); + debug("RULE 9: computer played a random cell"); make_my_move(mv); } @@ -418,11 +419,11 @@ function get_free_sides() { function get_free_corner() { var frees = new Array(); - var sides = [1,3,7,9]; + var corners = [1,3,7,9]; - for (var i in sides) { - if (cell_is_free(sides[i])) - frees.push(sides[i]); + for (var i in corners) { + if (cell_is_free(corners[i])) + frees.push(corners[i]); } return frees; } diff --git a/apps/oxofocus/metadata.json b/apps/oxofocus/metadata.json index 6457fe76c..06b8be461 100644 --- a/apps/oxofocus/metadata.json +++ b/apps/oxofocus/metadata.json @@ -2,7 +2,7 @@ "name": "oxofocus", "shortName":"Oxo Focus", "icon": "app.png", - "version":"0.01", + "version":"0.02", "description": "Play the computer while it learns to play Naughts and Crosses!", "readme": "README.md", "tags": "game",