clamped zerg servival turn goal
This commit is contained in:
parent
21688aa11b
commit
6e5272e37d
7 changed files with 92 additions and 18 deletions
|
|
@ -62,6 +62,10 @@ var has_opponent = true;
|
||||||
var captured_pieces_this_turn: Array = []
|
var captured_pieces_this_turn: Array = []
|
||||||
var player_pieces_lost_this_turn: Array = []
|
var player_pieces_lost_this_turn: Array = []
|
||||||
var winConditionManager: WinConditionManager = null
|
var winConditionManager: WinConditionManager = null
|
||||||
|
var boss_type = null
|
||||||
|
var boss_turn_additional = null
|
||||||
|
var boss_turn_index = null
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Export parameters
|
# Export parameters
|
||||||
|
|
@ -108,6 +112,10 @@ func _on_new_game_requested(options = {}):
|
||||||
print("ChessGame received new_game_requested signal ", is_initialized)
|
print("ChessGame received new_game_requested signal ", is_initialized)
|
||||||
captured_pieces_this_turn = []
|
captured_pieces_this_turn = []
|
||||||
player_pieces_lost_this_turn = []
|
player_pieces_lost_this_turn = []
|
||||||
|
|
||||||
|
boss_type = null
|
||||||
|
boss_turn_additional = null
|
||||||
|
boss_turn_index = null
|
||||||
moveCount = 1
|
moveCount = 1
|
||||||
turnIndicator.visible = true
|
turnIndicator.visible = true
|
||||||
has_opponent = true
|
has_opponent = true
|
||||||
|
|
@ -118,6 +126,11 @@ func _on_new_game_requested(options = {}):
|
||||||
currentFen = options.metadata.fen
|
currentFen = options.metadata.fen
|
||||||
if "elo" in options.metadata:
|
if "elo" in options.metadata:
|
||||||
cpuElo = options.metadata.elo
|
cpuElo = options.metadata.elo
|
||||||
|
if "boss_type" in options.metadata:
|
||||||
|
boss_type = options.metadata.boss_type
|
||||||
|
if "boss_turn_additional" in options.metadata and options.metadata.boss_turn_additional != null:
|
||||||
|
boss_turn_additional = options.metadata.boss_turn_additional
|
||||||
|
boss_turn_index = 0
|
||||||
if "has_opponent" in options.metadata:
|
if "has_opponent" in options.metadata:
|
||||||
has_opponent = options.metadata.has_opponent
|
has_opponent = options.metadata.has_opponent
|
||||||
if winConditionManager == null:
|
if winConditionManager == null:
|
||||||
|
|
@ -521,7 +534,7 @@ func clearBoard() -> void:
|
||||||
child.remove_piece()
|
child.remove_piece()
|
||||||
|
|
||||||
func updateTurnIndicator():
|
func updateTurnIndicator():
|
||||||
if Turn == 0: # White's turn
|
if currentPlayer == WHITE: # White's turn
|
||||||
turnIndicator.color = Color(1, 1, 1, 1) # White
|
turnIndicator.color = Color(1, 1, 1, 1) # White
|
||||||
else: # Black's turn
|
else: # Black's turn
|
||||||
turnIndicator.color = Color(0, 0, 0, 1) # Black
|
turnIndicator.color = Color(0, 0, 0, 1) # Black
|
||||||
|
|
|
||||||
|
|
@ -186,6 +186,7 @@ func generate_map():
|
||||||
}
|
}
|
||||||
|
|
||||||
func _get_random_room_type(level, total_levels):
|
func _get_random_room_type(level, total_levels):
|
||||||
|
# return Utils.RoomType.BOSS
|
||||||
var boss_chance = 0.1 + (level / float(total_levels) * 0.1)
|
var boss_chance = 0.1 + (level / float(total_levels) * 0.1)
|
||||||
var shop_chance = 0.1 + (level / float(total_levels) * 0.05)
|
var shop_chance = 0.1 + (level / float(total_levels) * 0.05)
|
||||||
var event_chance = 0.05
|
var event_chance = 0.05
|
||||||
|
|
@ -251,7 +252,7 @@ func generate_node_data(node):
|
||||||
Utils.RoomType.BOSS:
|
Utils.RoomType.BOSS:
|
||||||
data.metadata = generate_boss_data(data)
|
data.metadata = generate_boss_data(data)
|
||||||
Utils.RoomType.FINAL:
|
Utils.RoomType.FINAL:
|
||||||
data.metadata = { "is_escape": true}
|
data.metadata = generate_chess_data(data)
|
||||||
Utils.RoomType.SHOP:
|
Utils.RoomType.SHOP:
|
||||||
data.metadata = generate_shop_data(data)
|
data.metadata = generate_shop_data(data)
|
||||||
Utils.RoomType.EVENT:
|
Utils.RoomType.EVENT:
|
||||||
|
|
@ -265,18 +266,27 @@ func generate_boss_data(node):
|
||||||
# level_unit_distribution
|
# level_unit_distribution
|
||||||
# current_max_level
|
# current_max_level
|
||||||
var rng = float(node.level) / int(current_max_level)
|
var rng = float(node.level) / int(current_max_level)
|
||||||
var game_type = "zerg"
|
var game_type = Utils.BossType.ZERG
|
||||||
var height = 6;
|
var height = 6;
|
||||||
# (current_value, min_value, max_value, min_index, max_index)
|
# (current_value, min_value, max_value, min_index, max_index)
|
||||||
var index = map_to_array_index(node.level, 2, current_max_level - 2, 1, level_unit_distribution.size() - 1);
|
var index = map_to_array_index(node.level, 2, current_max_level - 2, 1, level_unit_distribution.size() - 1);
|
||||||
if game_type == "zerg":
|
|
||||||
index = 7
|
|
||||||
height = 7
|
|
||||||
# if game_type == "zerg":
|
|
||||||
# index = map_to_array_index(node.level, 5, current_max_level - 2, 1, level_unit_distribution.size() - 1);
|
|
||||||
var unit_string = level_unit_distribution[index]
|
var unit_string = level_unit_distribution[index]
|
||||||
|
var special_unit = ""
|
||||||
var pawn_string = ""
|
var pawn_string = ""
|
||||||
var enemy_unit_depth = 3
|
var enemy_unit_depth = 3
|
||||||
|
if game_type == Utils.BossType.ZERG:
|
||||||
|
index = 7
|
||||||
|
height = 7
|
||||||
|
elif game_type == Utils.BossType.DOUBLETROUBLE:
|
||||||
|
index = 9
|
||||||
|
height = 9
|
||||||
|
elif game_type == Utils.BossType.WARLARD:
|
||||||
|
index = 10
|
||||||
|
height = 10
|
||||||
|
unit_string = "1rnbqkbnr1"
|
||||||
|
special_unit = "rnnnqkbbbr"
|
||||||
|
# if game_type == "zerg":
|
||||||
|
# index = map_to_array_index(node.level, 5, current_max_level - 2, 1, level_unit_distribution.size() - 1);
|
||||||
|
|
||||||
for x in unit_string.length():
|
for x in unit_string.length():
|
||||||
pawn_string += "p"
|
pawn_string += "p"
|
||||||
|
|
@ -304,23 +314,56 @@ func generate_boss_data(node):
|
||||||
fen += str(unit_string.length()) + "/"
|
fen += str(unit_string.length()) + "/"
|
||||||
|
|
||||||
|
|
||||||
if game_type == "zerg":
|
if game_type == Utils.BossType.ZERG:
|
||||||
for x in enemy_unit_depth - 1:
|
for x in enemy_unit_depth - 1:
|
||||||
fen += pawn_string.to_upper() + "/"
|
fen += pawn_string.to_upper() + "/"
|
||||||
fen += pawn_string.to_upper()
|
fen += pawn_string.to_upper()
|
||||||
|
elif game_type == Utils.BossType.WARLARD:
|
||||||
|
fen += pawn_string.to_upper() + "/" + special_unit.to_upper()
|
||||||
else:
|
else:
|
||||||
fen += pawn_string.to_upper() + "/" + unit_string.to_upper()
|
fen += pawn_string.to_upper() + "/" + unit_string.to_upper()
|
||||||
var fen_ending = " w KQkq - 0 1"
|
var fen_ending = " w KQkq - 0 1"
|
||||||
# print("generate_chess_data ", fen + fen_ending)
|
# print("generate_chess_data ", fen + fen_ending)
|
||||||
|
# change condition
|
||||||
|
|
||||||
|
var win_condition = Utils.WinConditionType.TURN_NUMBER
|
||||||
|
var win_target_turn = null
|
||||||
|
var loss_target_unit = null
|
||||||
|
var win_target_unit = null
|
||||||
|
var boss_turn_additional = null
|
||||||
|
var loss_condition = Utils.LossConditionType.UNIT_LOST
|
||||||
|
|
||||||
|
if game_type == Utils.BossType.ZERG:
|
||||||
|
win_condition = Utils.WinConditionType.TURN_NUMBER
|
||||||
|
# smallest board = 2 x 6 = 12
|
||||||
|
# largest board = 10 x 12 = 120
|
||||||
|
# smallest turn target 10
|
||||||
|
# largest turn target 50
|
||||||
|
var roomSize = height * unit_string.length()
|
||||||
|
var clamped_value = clamp(roomSize, 12, 120)
|
||||||
|
var percentage = (clamped_value - 12) / (120 - 12)
|
||||||
|
|
||||||
|
win_target_turn = 10 + percentage * (50 - 10)
|
||||||
|
loss_target_unit = "King"
|
||||||
|
loss_condition = Utils.LossConditionType.UNIT_LOST
|
||||||
|
elif game_type == Utils.BossType.DOUBLETROUBLE:
|
||||||
|
boss_turn_additional = 2
|
||||||
|
win_condition = Utils.WinConditionType.CAPTURE_UNIT
|
||||||
|
win_target_unit = "King"
|
||||||
|
loss_target_unit = "King"
|
||||||
|
loss_condition = Utils.LossConditionType.UNIT_LOST
|
||||||
return {
|
return {
|
||||||
"is_escape": node.metadata.is_escape if node.metadata.has("is_escape") else false,
|
"is_escape": node.metadata.is_escape if node.metadata.has("is_escape") else false,
|
||||||
"fen": fen + fen_ending,
|
"fen": fen + fen_ending,
|
||||||
"game_type": game_type,
|
"game_type": "chess",
|
||||||
"win_condition": Utils.WinConditionType.TURN_NUMBER,
|
"boss_type": game_type,
|
||||||
"win_target_turn": 30,
|
|
||||||
"has_opponent": true,
|
"has_opponent": true,
|
||||||
"loss_target_unit": "King",
|
"boss_turn_additional": boss_turn_additional,
|
||||||
"loss_condition": Utils.LossConditionType.UNIT_LOST,
|
"win_condition": win_condition,
|
||||||
|
"win_target_turn": win_target_turn,
|
||||||
|
"win_target_unit": win_target_unit,
|
||||||
|
"loss_target_unit": loss_target_unit,
|
||||||
|
"loss_condition": loss_condition,
|
||||||
"reward": {
|
"reward": {
|
||||||
"gold": 50 * node.level,
|
"gold": 50 * node.level,
|
||||||
"cards": [],
|
"cards": [],
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@ func load_condition_from_metadata(metadata: Dictionary):
|
||||||
if metadata.has("win_condition"):
|
if metadata.has("win_condition"):
|
||||||
match metadata["win_condition"]:
|
match metadata["win_condition"]:
|
||||||
Utils.WinConditionType.CAPTURE_UNIT:
|
Utils.WinConditionType.CAPTURE_UNIT:
|
||||||
set_win_condition(Utils.WinConditionType.CAPTURE_UNIT, {"unit": "King"})
|
set_win_condition(Utils.WinConditionType.CAPTURE_UNIT, {"unit": metadata.get("win_target_unit", "King")})
|
||||||
Utils.WinConditionType.TILE_REACHED:
|
Utils.WinConditionType.TILE_REACHED:
|
||||||
# Get target tiles from metadata if available
|
# Get target tiles from metadata if available
|
||||||
|
|
||||||
|
|
@ -241,7 +241,7 @@ func load_condition_from_metadata(metadata: Dictionary):
|
||||||
if metadata.has("loss_condition"):
|
if metadata.has("loss_condition"):
|
||||||
match metadata["loss_condition"]:
|
match metadata["loss_condition"]:
|
||||||
Utils.LossConditionType.UNIT_LOST:
|
Utils.LossConditionType.UNIT_LOST:
|
||||||
set_loss_condition(Utils.LossConditionType.UNIT_LOST, {"unit": "King"})
|
set_loss_condition(Utils.LossConditionType.UNIT_LOST, {"unit": metadata.get("loss_target_unit", "King")})
|
||||||
Utils.LossConditionType.TURN_NUMBER:
|
Utils.LossConditionType.TURN_NUMBER:
|
||||||
set_loss_condition(Utils.LossConditionType.TURN_NUMBER, {"turn_limit": metadata.get("loss_turn_limit", 50)})
|
set_loss_condition(Utils.LossConditionType.TURN_NUMBER, {"turn_limit": metadata.get("loss_turn_limit", 50)})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ func _ready() -> void:
|
||||||
func enter(_previous: String, _data := {}) -> void:
|
func enter(_previous: String, _data := {}) -> void:
|
||||||
print("ENTERING STATE ", Constants.BLACK_TURN)
|
print("ENTERING STATE ", Constants.BLACK_TURN)
|
||||||
game.currentPlayer = game.BLACK
|
game.currentPlayer = game.BLACK
|
||||||
|
game.updateTurnIndicator()
|
||||||
|
|
||||||
# Delay to avoid duplication during animation
|
# Delay to avoid duplication during animation
|
||||||
if game.stockfishController:
|
if game.stockfishController:
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,21 @@ extends "res://Systems/StateMachine/ChessGameState.gd"
|
||||||
func enter(_previous: String, data := {}) -> void:
|
func enter(_previous: String, data := {}) -> void:
|
||||||
print("ENTERING STATE ", Constants.CLEANUP, data)
|
print("ENTERING STATE ", Constants.CLEANUP, data)
|
||||||
|
|
||||||
game.moveCount += 1;
|
|
||||||
if "endCondition" in data:
|
if "endCondition" in data:
|
||||||
finished.emit(Constants.ROUND_END)
|
finished.emit(Constants.ROUND_END)
|
||||||
elif game.currentPlayer == game.WHITE and game.has_opponent:
|
return
|
||||||
|
game.moveCount += 1;
|
||||||
|
if game.boss_turn_additional != null and game.currentPlayer == game.BLACK:
|
||||||
|
if game.boss_turn_index < game.boss_turn_additional:
|
||||||
|
game.boss_turn_index += 1
|
||||||
|
finished.emit(Constants.BLACK_TURN)
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
game.boss_turn_index = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if game.currentPlayer == game.WHITE and game.has_opponent:
|
||||||
finished.emit(Constants.BLACK_TURN)
|
finished.emit(Constants.BLACK_TURN)
|
||||||
else:
|
else:
|
||||||
finished.emit(Constants.WHITE_TURN)
|
finished.emit(Constants.WHITE_TURN)
|
||||||
|
|
@ -3,4 +3,5 @@ extends "res://Systems/StateMachine/ChessGameState.gd"
|
||||||
func enter(_previous: String, _data := {}) -> void:
|
func enter(_previous: String, _data := {}) -> void:
|
||||||
print("ENTERING STATE ", Constants.WHITE_TURN)
|
print("ENTERING STATE ", Constants.WHITE_TURN)
|
||||||
game.currentPlayer = game.WHITE
|
game.currentPlayer = game.WHITE
|
||||||
|
game.updateTurnIndicator()
|
||||||
finished.emit(Constants.HAND_SETUP)
|
finished.emit(Constants.HAND_SETUP)
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,11 @@ enum RoomType {
|
||||||
EVENT
|
EVENT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum BossType {
|
||||||
|
ZERG,
|
||||||
|
DOUBLETROUBLE,
|
||||||
|
WARLARD,
|
||||||
|
}
|
||||||
enum WinConditionType {
|
enum WinConditionType {
|
||||||
CAPTURE_UNIT, # Default: King capture
|
CAPTURE_UNIT, # Default: King capture
|
||||||
BOARD_CLEARED, # Clear the board of all opponent pieces
|
BOARD_CLEARED, # Clear the board of all opponent pieces
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue