Skip to content

Commit

Permalink
Merge pull request #7 from CLSFramework/args_modif
Browse files Browse the repository at this point in the history
refactor args name
  • Loading branch information
naderzare authored Sep 2, 2024
2 parents 7cd1762 + 940fd02 commit cdf543d
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 93 deletions.
11 changes: 11 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# ChangeLog

## [0.1.3] - 2024-09-02

### Added
-

### Fixed
- bug fixed in start files (by [NaderZare](https://github.com/naderzare), [ArefSayareh](https://github.com/Arefsa78))

### Changed
- change input arguments names in start files (by [NaderZare](https://github.com/naderzare), [ArefSayareh](https://github.com/Arefsa78))

## [0.1.2] - 2024-09-01

### Added
Expand Down
8 changes: 4 additions & 4 deletions src/coach/main_coach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ main( int argc, char **argv )
std::string rpc_type = "thrift";

for (int i = 0; i < argc; ++i) {
if (std::string(argv[i]) == "--g-port") {
if (std::string(argv[i]) == "--rpc-port") {
grpc_port = std::stoi(argv[i+1]);
}
if (std::string(argv[i]) == "--diff-g-port") {
if (std::string(argv[i]) == "--rpc-port-step") {
use_same_grpc_port = false;
}
if (std::string(argv[i]) == "--gp20") {
if (std::string(argv[i]) == "--rpc-add-20-to-port-for-right") {
add_20_to_grpc_port_if_right_side = true;
}
if (std::string(argv[i]) == "--g-ip") {
if (std::string(argv[i]) == "--rpc-host") {
grpc_ip = argv[i+1];
}
if (std::string(argv[i]) == "--rpc-type") {
Expand Down
8 changes: 4 additions & 4 deletions src/player/main_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ main( int argc, char **argv )
std::string rpc_type = "thrift";

for (int i = 0; i < argc; ++i) {
if (std::string(argv[i]) == "--g-port") {
if (std::string(argv[i]) == "--rpc-port") {
grpc_port = std::stoi(argv[i+1]);
}
if (std::string(argv[i]) == "--diff-g-port") {
if (std::string(argv[i]) == "--rpc-port-step") {
use_same_grpc_port = false;
}
if (std::string(argv[i]) == "--gp20") {
if (std::string(argv[i]) == "--rpc-add-20-to-port-for-right") {
add_20_to_grpc_port_if_right_side = true;
}
if (std::string(argv[i]) == "--g-ip") {
if (std::string(argv[i]) == "--rpc-host") {
grpc_ip = argv[i+1];
}
if (std::string(argv[i]) == "--rpc-type") {
Expand Down
56 changes: 28 additions & 28 deletions src/start-agent.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ coach="${DIR}/sample_coach"
teamname="SSP"
host="localhost"
port=6000
g_ip="localhost"
g_port=50051
diff_g_port="false"
gp20="false"
rpc_host="localhost"
rpc_port=50051
rpc_port_step="false"
rpc_add_20_to_port_for_right="false"
rpc_type="thrift"
coach_port=""
debug_server_host=""
Expand Down Expand Up @@ -82,10 +82,10 @@ usage()
echo " --log-dir DIRECTORY specifies debug log directory (default: /tmp)"
echo " --debug-log-ext EXTENSION specifies debug log file extension (default: .log)"
echo " --fullstate FULLSTATE_TYPE specifies fullstate model handling"
echo " --g-ip GRPC IP specifies grpc IP (default: localhost)"
echo " --g-port GRPC PORT specifies grpc port (default: 50051)"
echo " --diff-g-port specifies different grpc port for each player (default: false)"
echo " --gp20 add 20 to GRPC Port if team run on right side (default: false)"
echo " --rpc-host RPC host specifies rpc host (default: localhost)"
echo " --rpc-port RPC PORT specifies rpc port (default: 50051)"
echo " --rpc-port-step specifies different rpc port for each player (default: false)"
echo " --rpc-add-20-to-port-for-right add 20 to RPC Port if team run on right side (default: false)"
echo " --rpc-type type of rpc framework (default: thrift) or grpc"
echo " --goalie specifies to run as a goalie"
echo " --player specifies to run as a player"
Expand All @@ -101,27 +101,27 @@ do
usage
exit 0
;;
--g-ip)
--rpc-host)
if [ $# -lt 2 ]; then
usage
exit 1
fi
g_ip="${2}"
rpc_host="${2}"
shift 1
;;
--g-port)
--rpc-port)
if [ $# -lt 2 ]; then
usage
exit 1
fi
g_port="${2}"
rpc_port="${2}"
shift 1
;;
--diff-g-port)
diff_g_port="true"
--rpc-port-step)
rpc_port_step="true"
;;
--gp20)
gp20="true"
--rpc-add-20-to-port-for-right)
rpc_add_20_to_port_for_right="true"
;;
--rpc-type)
if [ $# -lt 2 ]; then
Expand Down Expand Up @@ -344,14 +344,14 @@ opt="${opt} --debug_server_host ${debug_server_host}"
opt="${opt} --debug_server_port ${debug_server_port}"
opt="${opt} ${offline_logging}"
opt="${opt} ${debugopt}"
opt="${opt} --g-ip ${g_ip}"
opt="${opt} --g-port ${g_port}"
opt="${opt} --rpc-host ${rpc_host}"
opt="${opt} --rpc-port ${rpc_port}"
opt="${opt} --rpc-type ${rpc_type}"
if [ "${same_g_port}" = "true" ]; then
opt="${opt} --diff-g-port"
if [ "${rpc_port_step}" = "true" ]; then
opt="${opt} --rpc-port-step"
fi
if [ "${gp20}" = "true" ]; then
opt="${opt} --gp20"
if [ "${rpc_add_20_to_port_for_right}" = "true" ]; then
opt="${opt} --rpc-add-20-to-port-for-right"
fi

ping -c 1 $host
Expand All @@ -374,14 +374,14 @@ if [ "${is_coach}" = "true" ]; then
coachopt="${coachopt} --debug_server_port ${debug_server_port}"
coachopt="${coachopt} ${offline_logging}"
coachopt="${coachopt} ${debugopt}"
coachopt="${coachopt} --g-ip ${g_ip}"
coachopt="${coachopt} --g-port ${g_port}"
coachopt="${coachopt} --rpc-host ${rpc_host}"
coachopt="${coachopt} --rpc-port ${rpc_port}"
coachopt="${coachopt} --rpc-type ${rpc_type}"
if [ "${same_g_port}" = "true" ]; then
coachopt="${coachopt} --diff-g-port"
if [ "${rpc_port_step}" = "true" ]; then
coachopt="${coachopt} --rpc-port-step"
fi
if [ "${gp20}" = "true" ]; then
coachopt="${coachopt} --gp20"
if [ "${rpc_add_20_to_port_for_right}" = "true" ]; then
coachopt="${coachopt} --rpc-add-20-to-port-for-right"
fi
$coach ${coachopt} &
fi
56 changes: 28 additions & 28 deletions src/start.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ coach="${DIR}/sample_coach"
teamname="SSP"
host="localhost"
port=6000
g_ip="localhost"
g_port=50051
diff_g_port="false"
gp20="false"
rpc_host="localhost"
rpc_port=50051
rpc_port_step="false"
rpc_add_20_to_port_for_right="false"
rpc_type="thrift"
coach_port=""
debug_server_host=""
Expand Down Expand Up @@ -84,10 +84,10 @@ usage()
echo " --log-dir DIRECTORY specifies debug log directory (default: /tmp)"
echo " --debug-log-ext EXTENSION specifies debug log file extension (default: .log)"
echo " --fullstate FULLSTATE_TYPE specifies fullstate model handling"
echo " --g-ip GRPC IP specifies grpc IP (default: localhost)"
echo " --g-port GRPC PORT specifies grpc port (default: 50051)"
echo " --diff-g-port specifies different grpc port for each player (default: false)"
echo " --gp20 add 20 to GRPC Port if team run on right side (default: false)"
echo " --rpc-host RPC host specifies rpc host (default: localhost)"
echo " --rpc-port RPC PORT specifies rpc port (default: 50051)"
echo " --rpc-port-step specifies different rpc port for each player (default: false)"
echo " --rpc-add-20-to-port-for-right add 20 to RPC Port if team run on right side (default: false)"
echo " --rpc-type type of rpc framework (default: thrift) or grpc"
echo " FULLSTATE_TYPE is one of [ignore|reference|override].") 1>&2
}
Expand All @@ -100,27 +100,27 @@ do
usage
exit 0
;;
--g-ip)
--rpc-host)
if [ $# -lt 2 ]; then
usage
exit 1
fi
g_ip="${2}"
rpc_host="${2}"
shift 1
;;
--g-port)
--rpc-port)
if [ $# -lt 2 ]; then
usage
exit 1
fi
g_port="${2}"
rpc_port="${2}"
shift 1
;;
--diff-g-port)
diff_g_port="true"
--rpc-port-step)
rpc_port_step="true"
;;
--gp20)
gp20="true"
--rpc-add-20-to-port-for-right)
rpc_add_20_to_port_for_right="true"
;;
--rpc-type)
if [ $# -lt 2 ]; then
Expand Down Expand Up @@ -351,14 +351,14 @@ opt="${opt} --debug_server_host ${debug_server_host}"
opt="${opt} --debug_server_port ${debug_server_port}"
opt="${opt} ${offline_logging}"
opt="${opt} ${debugopt}"
opt="${opt} --g-ip ${g_ip}"
opt="${opt} --g-port ${g_port}"
opt="${opt} --rpc-host ${rpc_host}"
opt="${opt} --rpc-port ${rpc_port}"
opt="${opt} --rpc-type ${rpc_type}"
if [ "${same_g_port}" = "true" ]; then
opt="${opt} --diff-g-port"
if [ "${rpc_port_step}" = "true" ]; then
opt="${opt} --rpc-port-step"
fi
if [ "${gp20}" = "true" ]; then
opt="${opt} --gp20"
if [ "${rpc_add_20_to_port_for_right}" = "true" ]; then
opt="${opt} --rpc-add-20-to-port-for-right"
fi

ping -c 1 $host
Expand Down Expand Up @@ -408,14 +408,14 @@ if [ "${usecoach}" = "true" ]; then
coachopt="${coachopt} --debug_server_port ${debug_server_port}"
coachopt="${coachopt} ${offline_logging}"
coachopt="${coachopt} ${debugopt}"
coachopt="${coachopt} --g-ip ${g_ip}"
coachopt="${coachopt} --g-port ${g_port}"
coachopt="${coachopt} --rpc-host ${rpc_host}"
coachopt="${coachopt} --rpc-port ${rpc_port}"
coachopt="${coachopt} --rpc-type ${rpc_type}"
if [ "${same_g_port}" = "true" ]; then
coachopt="${coachopt} --diff-g-port"
if [ "${rpc_port_step}" = "true" ]; then
coachopt="${coachopt} --rpc-port-step"
fi
if [ "${gp20}" = "true" ]; then
coachopt="${coachopt} --gp20"
if [ "${rpc_add_20_to_port_for_right}" = "true" ]; then
coachopt="${coachopt} --rpc-add-20-to-port-for-right"
fi

if [ X"${offline_mode}" != X'' ]; then
Expand Down
52 changes: 28 additions & 24 deletions src/train.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ coach="${DIR}/sample_coach"
trainer="${DIR}/sample_trainer"
teamname="TRAINER_MODE"
host="localhost"
g_port=50051
diff_g_port="false"
gp20="false"
rpc_host="localhost"
rpc_port=50051
rpc_port_step="false"
rpc_add_20_to_port_for_right="false"
rpc_type="thrift"
config="${DIR}/player.conf"
config_dir="${DIR}/formations-dt"
Expand All @@ -40,9 +41,10 @@ usage()
echo "Possible options are:"
echo " --help print this"
echo " -h, --host HOST specifies server host"
echo " --g_port GRPC PORT specifies grpc port (default: 50051)"
echo " --diff_g_port specifies different grpc port for each player (default: false)"
echo " --gp20 add 20 to GRPC Port if team run on right side (default: false)"
echo " --rpc-host RPC host specifies rpc host (default: localhost)"
echo " --rpc-port RPC PORT specifies rpc port (default: 50051)"
echo " --rpc-port-step specifies different rpc port for each player (default: false)"
echo " --rpc-add-20-to-port-for-right add 20 to RPC Port if team run on right side (default: false)"
echo " --rpc-type type of rpc framework (default: thrift) or grpc"
echo " -t, --teamname TEAMNAME specifies team name") 1>&2
}
Expand Down Expand Up @@ -73,27 +75,27 @@ do
teamname=$2
shift 1
;;
--g-ip)
--rpc-host)
if [ $# -lt 2 ]; then
usage
exit 1
fi
g_ip="${2}"
rpc_host="${2}"
shift 1
;;
--g-port)
--rpc-port)
if [ $# -lt 2 ]; then
usage
exit 1
fi
g_port="${2}"
rpc_port="${2}"
shift 1
;;
--diff-g-port)
diff_g_port="true"
--rpc-port-step)
rpc_port_step="true"
;;
--gp20)
gp20="true"
--rpc-add-20-to-port-for-right)
rpc_add_20_to_port_for_right="true"
;;
--rpc-type)
if [ $# -lt 2 ]; then
Expand All @@ -115,13 +117,14 @@ done
OPT="-h ${host} -t ${teamname}"
OPT="${OPT} --player-config ${config} --config_dir ${config_dir}"
OPT="${OPT} ${debugopt}"
opt="${opt} --g-port ${g_port}"
opt="${opt} --rpc-host ${rpc_host}"
opt="${opt} --rpc-port ${rpc_port}"
opt="${opt} --rpc-type ${rpc_type}"
if [ "${same_g_port}" = "true" ]; then
OPT="${OPT} --diff-g-port"
if [ "${rpc_port_step}" = "true" ]; then
opt="${opt} --rpc-port-step"
fi
if [ "${gp20}" = "true" ]; then
OPT="${OPT} --gp20"
if [ "${rpc_add_20_to_port_for_right}" = "true" ]; then
opt="${opt} --rpc-add-20-to-port-for-right"
fi
#if [ $number -gt 0 ]; then
# $player ${OPT} -g &
Expand All @@ -138,12 +141,13 @@ fi
$player ${OPT} -n 1 --rpc-type ${rpc_type} &
$sleepprog $sleeptime
trainer_opt="-h $host -t $teamname"
trainer_opt="${trainer_opt} --g-port ${g_port}"
trainer_opt="${trainer_opt} --rpc-host ${rpc_host}"
trainer_opt="${trainer_opt} --rpc-port ${rpc_port}"
trainer_opt="${trainer_opt} --rpc-type ${rpc_type}"
if [ "${same_g_port}" = "true" ]; then
trainer_opt="${trainer_opt} --diff-g-port"
if [ "${rpc_port_step}" = "true" ]; then
trainer_opt="${trainer_opt} --rpc-port-step"
fi
if [ "${gp20}" = "true" ]; then
trainer_opt="${trainer_opt} --gp20"
if [ "${rpc_add_20_to_port_for_right}" = "true" ]; then
trainer_opt="${trainer_opt} --rpc-add-20-to-port-for-right"
fi
$trainer $trainer_opt &
Loading

0 comments on commit cdf543d

Please sign in to comment.