Skip to content

Commit

Permalink
randomize the narrowing down process
Browse files Browse the repository at this point in the history
makes the ai a little smarter, for example, placing all of your ships in
vertical orientations no longer improves your chances (since the ai no
longer defaults to right, left, up, down order of searching)
  • Loading branch information
jschomay committed May 20, 2018
1 parent 8074706 commit 2b7a855
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/ai.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@ defmodule AI do
defstruct [:bt, :target_basis, :current_target, hit_streak: []]

def new() do
check_adjacent =
Node.select([
check_horizontal =
Node.random([
Node.select([:right, :left]),
Node.select([:up, :down])
Node.select([:left, :right])
])

check_vertical =
Node.random([
Node.select([:up, :down]),
Node.select([:down, :up])
])

check_adjacent =
Node.random([
Node.select([check_horizontal, check_vertical]),
Node.select([check_vertical, check_horizontal])
])

bt =
Expand Down

0 comments on commit 2b7a855

Please sign in to comment.