feature updates
This commit is contained in:
71
scripts/game/ai/EasyAI.gd
Normal file
71
scripts/game/ai/EasyAI.gd
Normal file
@@ -0,0 +1,71 @@
|
||||
class_name EasyAI
|
||||
extends AIStrategy
|
||||
|
||||
## Easy AI - Makes suboptimal choices, sometimes skips good plays
|
||||
## Good for beginners learning the game
|
||||
|
||||
|
||||
func _init(p_player_index: int) -> void:
|
||||
super._init(Difficulty.EASY, p_player_index)
|
||||
|
||||
|
||||
func decide_main_phase_action() -> Dictionary:
|
||||
var playable := get_playable_cards()
|
||||
|
||||
if playable.is_empty():
|
||||
return { "action": "pass" }
|
||||
|
||||
# 30% chance to just pass even if we have playable cards
|
||||
if randf() < 0.3:
|
||||
return { "action": "pass" }
|
||||
|
||||
# Pick a random playable card (not optimal)
|
||||
var card: CardInstance = playable[randi() % playable.size()]
|
||||
return { "action": "play", "card": card }
|
||||
|
||||
|
||||
func decide_cp_generation(needed_cp: Dictionary) -> Dictionary:
|
||||
var player := get_player()
|
||||
|
||||
# Prefer dulling backups first (Easy AI doesn't optimize)
|
||||
for backup in player.field_backups.get_cards():
|
||||
if backup.state == Enums.CardState.ACTIVE:
|
||||
return { "action": "dull_backup", "card": backup }
|
||||
|
||||
# Discard a random card from hand
|
||||
var hand_cards := player.hand.get_cards()
|
||||
if not hand_cards.is_empty():
|
||||
var card: CardInstance = hand_cards[randi() % hand_cards.size()]
|
||||
return { "action": "discard", "card": card }
|
||||
|
||||
return {}
|
||||
|
||||
|
||||
func decide_attack_action() -> Dictionary:
|
||||
var attackers := get_attackable_forwards()
|
||||
|
||||
if attackers.is_empty():
|
||||
return { "action": "end_attacks" }
|
||||
|
||||
# 40% chance to not attack even if we can
|
||||
if randf() < 0.4:
|
||||
return { "action": "end_attacks" }
|
||||
|
||||
# Pick a random attacker
|
||||
var attacker: CardInstance = attackers[randi() % attackers.size()]
|
||||
return { "action": "attack", "card": attacker }
|
||||
|
||||
|
||||
func decide_block_action(attacker: CardInstance) -> Dictionary:
|
||||
var blockers := get_blockable_forwards()
|
||||
|
||||
if blockers.is_empty():
|
||||
return { "action": "skip" }
|
||||
|
||||
# 50% chance to skip blocking even when possible
|
||||
if randf() < 0.5:
|
||||
return { "action": "skip" }
|
||||
|
||||
# Pick a random blocker (might not be optimal)
|
||||
var blocker: CardInstance = blockers[randi() % blockers.size()]
|
||||
return { "action": "block", "card": blocker }
|
||||
Reference in New Issue
Block a user