Skip to content

Commit

Permalink
switch to yuri ai
Browse files Browse the repository at this point in the history
  • Loading branch information
WermooZ committed Apr 18, 2018
1 parent 39b08ce commit 4c233db
Show file tree
Hide file tree
Showing 47 changed files with 95 additions and 1,200 deletions.
File renamed without changes.
57 changes: 0 additions & 57 deletions scripts/ai/actions/action.gd

This file was deleted.

38 changes: 0 additions & 38 deletions scripts/ai/actions/action_handler.gd

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends "res://scripts/yuri/actions/brains/building_brain.gd"
extends "res://scripts/ai/actions/brains/building_brain.gd"

func _initialize():
._initialize()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends "res://scripts/yuri/actions/brains/building_brain.gd"
extends "res://scripts/ai/actions/brains/building_brain.gd"


func _apply_amount_penalty(units):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends "res://scripts/yuri/actions/brains/base_brain.gd"
extends "res://scripts/ai/actions/brains/base_brain.gd"


var close_threshold = 4
Expand All @@ -12,7 +12,7 @@ var global_spawn_limit = 20


func _initialize():
self.actions_templates['spawn'] = preload("res://scripts/yuri/actions/types/spawn_unit_action.gd")
self.actions_templates['spawn'] = preload("res://scripts/ai/actions/types/spawn_unit_action.gd")


func get_actions(entity, enemies = {}, units = {}):
Expand All @@ -24,7 +24,7 @@ func get_actions(entity, enemies = {}, units = {}):
if entity.get_required_ap() > available_action_points:
return []

var spawn_limit = min(self.bag.yuri_ai.pathfinder.passable_field_count / 7, self.global_spawn_limit)
var spawn_limit = min(self.bag.ai.pathfinder.passable_field_count / 7, self.global_spawn_limit)
if units.size() >= spawn_limit:
return []

Expand All @@ -37,7 +37,7 @@ func get_actions(entity, enemies = {}, units = {}):
if enemies[position].type_name != "soldier":
continue

distance = self.bag.yuri_ai.pathfinder.get_distance(entity.position_on_map, position)
distance = self.bag.ai.pathfinder.get_distance(entity.position_on_map, position)
if distance <= self.close_threshold:
score = score + self.in_danger_score
break
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends "res://scripts/yuri/actions/brains/building_brain.gd"
extends "res://scripts/ai/actions/brains/building_brain.gd"

func _initialize():
._initialize()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends "res://scripts/yuri/actions/brains/unit_brain.gd"
extends "res://scripts/ai/actions/brains/unit_brain.gd"

func _initialize():
._initialize()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends "res://scripts/yuri/actions/brains/building_brain.gd"
extends "res://scripts/ai/actions/brains/building_brain.gd"

func _initialize():
._initialize()
Expand Down
1 change: 1 addition & 0 deletions scripts/ai/actions/brains/soldier_brain.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extends "res://scripts/ai/actions/brains/unit_brain.gd"
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends "res://scripts/yuri/actions/brains/unit_brain.gd"
extends "res://scripts/ai/actions/brains/unit_brain.gd"

func _initialize():
._initialize()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends "res://scripts/yuri/actions/brains/building_brain.gd"
extends "res://scripts/ai/actions/brains/building_brain.gd"

func get_actions(entity, enemies = {}, units = {}):
return []
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends "res://scripts/yuri/actions/brains/base_brain.gd"
extends "res://scripts/ai/actions/brains/base_brain.gd"

var preserve_ap = 1
var distance_penalty = 5
Expand All @@ -18,8 +18,8 @@ var hq_capture_bonus = 500


func _initialize():
self.actions_templates['attack'] = preload("res://scripts/yuri/actions/types/attack_action.gd")
self.actions_templates['capture'] = preload("res://scripts/yuri/actions/types/capture_action.gd")
self.actions_templates['attack'] = preload("res://scripts/ai/actions/types/attack_action.gd")
self.actions_templates['capture'] = preload("res://scripts/ai/actions/types/capture_action.gd")

func get_actions(entity, enemies = {}, buildings = {}, allies = {}, own_buildings = {}):
var attack_actions = []
Expand Down Expand Up @@ -70,15 +70,15 @@ func _get_attack_actions(entity, enemies, buildings, allies, own_buildings):
base_obstacles[building_position] = building_position
for building_position in own_buildings:
base_obstacles[building_position] = building_position
distance = self.bag.yuri_ai.pathfinder.get_distance(entity.position_on_map, building_position)
distance = self.bag.ai.pathfinder.get_distance(entity.position_on_map, building_position)
if distance <= 4:
protects_building = true
if own_buildings[building_position].get_building_name() == "HQ":
protects_hq = true
for ally_position in allies:
if ally_position != entity.position_on_map:
base_obstacles[ally_position] = ally_position
distance = self.bag.yuri_ai.pathfinder.get_distance(entity.position_on_map, ally_position)
distance = self.bag.ai.pathfinder.get_distance(entity.position_on_map, ally_position)
if distance <= 2:
has_backup += 1
for enemy_position in enemies:
Expand All @@ -90,7 +90,7 @@ func _get_attack_actions(entity, enemies, buildings, allies, own_buildings):
if not entity.can_attack_unit_type(enemy):
continue

distance = self.bag.yuri_ai.pathfinder.get_distance(entity.position_on_map, enemy.position_on_map)
distance = self.bag.ai.pathfinder.get_distance(entity.position_on_map, enemy.position_on_map)

if distance > entity.max_ap + self.aggression_range:
continue
Expand All @@ -100,9 +100,9 @@ func _get_attack_actions(entity, enemies, buildings, allies, own_buildings):

obstacles = base_obstacles.keys()
obstacles.erase(enemy.position_on_map)
self.bag.yuri_ai.pathfinder.set_obstacles(obstacles)
self.bag.ai.pathfinder.set_obstacles(obstacles)

path = self.bag.yuri_ai.pathfinder.path_search(entity.position_on_map, enemy.position_on_map)
path = self.bag.ai.pathfinder.path_search(entity.position_on_map, enemy.position_on_map)

if path.value == 0:
continue
Expand Down Expand Up @@ -165,9 +165,9 @@ func _get_capture_actions(entity, enemies, buildings, allies, own_buildings):

obstacles = base_obstacles.keys()
obstacles.erase(target.position_on_map)
self.bag.yuri_ai.pathfinder.set_obstacles(obstacles)
self.bag.ai.pathfinder.set_obstacles(obstacles)

path = self.bag.yuri_ai.pathfinder.path_search(entity.position_on_map, target.position_on_map)
path = self.bag.ai.pathfinder.path_search(entity.position_on_map, target.position_on_map)

if path.value == 0:
continue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
extends "res://scripts/bag_aware.gd"

var unit_brains = {
"soldier" : preload("res://scripts/yuri/actions/brains/soldier_brain.gd").new(),
"tank" : preload("res://scripts/yuri/actions/brains/tank_brain.gd").new(),
"heli" : preload("res://scripts/yuri/actions/brains/heli_brain.gd").new(),
"soldier" : preload("res://scripts/ai/actions/brains/soldier_brain.gd").new(),
"tank" : preload("res://scripts/ai/actions/brains/tank_brain.gd").new(),
"heli" : preload("res://scripts/ai/actions/brains/heli_brain.gd").new(),
}

var building_brains = {
"hq" : preload("res://scripts/yuri/actions/brains/hq_brain.gd").new(),
"barracks" : preload("res://scripts/yuri/actions/brains/barracks_brain.gd").new(),
"factory" : preload("res://scripts/yuri/actions/brains/factory_brain.gd").new(),
"airport" : preload("res://scripts/yuri/actions/brains/airport_brain.gd").new(),
"gsm tower" : preload("res://scripts/yuri/actions/brains/tower_brain.gd").new(),
"hq" : preload("res://scripts/ai/actions/brains/hq_brain.gd").new(),
"barracks" : preload("res://scripts/ai/actions/brains/barracks_brain.gd").new(),
"factory" : preload("res://scripts/ai/actions/brains/factory_brain.gd").new(),
"airport" : preload("res://scripts/ai/actions/brains/airport_brain.gd").new(),
"gsm tower" : preload("res://scripts/ai/actions/brains/tower_brain.gd").new(),
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
extends "res://scripts/bag_aware.gd"

var hands = {
"spawn" : preload("res://scripts/yuri/actions/hands/spawn_hand.gd").new(),
"move" : preload("res://scripts/yuri/actions/hands/move_hand.gd").new(),
"spawn" : preload("res://scripts/ai/actions/hands/spawn_hand.gd").new(),
"move" : preload("res://scripts/ai/actions/hands/move_hand.gd").new(),
}


Expand Down
22 changes: 0 additions & 22 deletions scripts/ai/actions/estimate.gd

This file was deleted.

49 changes: 0 additions & 49 deletions scripts/ai/actions/estimate_strategy.gd

This file was deleted.

Loading

0 comments on commit 4c233db

Please sign in to comment.