-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.cr
34 lines (31 loc) · 875 Bytes
/
base.cr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Abstract class of all strategies. They're all initialized with a *@context*
# and their entrypoint is the `#move` method
module Strategy
VALID_MOVES = ["up", "left", "down", "right"]
def self.build(name, context)
case name
when "random"
Strategy::Random.new(context)
when "random_valid"
Strategy::RandomValid.new(context)
when "blast_random_valid"
Strategy::BlastRandomValid.new(context)
when "chase_closest_food"
Strategy::ChaseClosestFood.new(context)
when "chase_random_food"
Strategy::ChaseClosestFood.new(context)
when "cautious_carol"
Strategy::CautiousCarol.new(context)
else
nil
end
end
abstract class Base
def initialize(@context : BattleSnake::Context)
end
# Returns the move (direction) to chose based on the *@context*
def move
"up"
end
end
end