だから私は土曜日に予定されているプロジェクトを持っています(私は先週の土曜日に始めました)。このプロジェクトはスポーツ予測プログラムです。
昨日は EPL (イングリッシュ プレミア リーグ) に関するすべての情報を調査して取得することに費やしたので、データベースにすべての結果と対戦カードがあります。現在の統計 (ゲームごとの平均ゴール数、合計勝敗数、リーグ ポイントなど)
私は現在、彼らが何勝したかを比較しています。それは、シーズン中の 2 試合のデータベースからデータを取得することです (サッカーを観ない人のために、各チームと 2 試合ずつ対戦します)。引き分けの場合は「1」、両方の試合の場合は「Man Utd」、各試合の場合は「Man Utd」と「Man City」などの名前を取得します。
誰が何を勝ったかでどのチームが勝つかを予測するロジックをどのように記述すればよいでしょうか? 例: マンチェスター・ユナイテッドがマン・シティに勝ち、マン・シティがマンチェスター・ユナイテッドに勝った場合、次の試合で 50-50 の確率ですが、マン・ユナイテッドはスウォンジーに 2 回勝ったため、次の試合でマン・ユナイテッドが勝つ可能性は 90% です。
これが私のコードです。これは常に「50-50」で表示されるため、どこが間違っているのかわかりません。
これは些細なことかもしれませんが、私にとってはそうではありません。スカウトがいる大学で学校を代表しているので、助けてください...
/**** get the result of the first game ****/
public String getGame1Result(String team1, String team2) throws SQLException{
String resultOfGame = null;
conn = DriverManager.getConnection(connection.conn_url, connection.conn_user, connection.conn_pass);
statement = conn.prepareStatement("SELECT games_winner, games_draw FROM games WHERE games_team1 = '" + team2 + "' AND games_team2 = '" + team1 + "'");
result = statement.executeQuery();
while(result.next()){
System.out.println(result.getString(1));
System.out.println(result.getString(2));
if(result.getString(1) == null){
resultOfGame = result.getString(2);
} else if(result.getString(2) == null) {
resultOfGame = result.getString(1);
} else {
resultOfGame = "Did not work";
}
}
return resultOfGame;
}
/**** get the result of the second game ****/
public String getGame2Result(String team1, String team2) throws SQLException{
String resultOfGame = null;
conn = DriverManager.getConnection(connection.conn_url, connection.conn_user, connection.conn_pass);
statement = conn.prepareStatement("SELECT games_winner, games_draw FROM games WHERE games_team1 = '" + team1 + "' AND games_team2 = '" + team2 + "'");
result = statement.executeQuery();
while(result.next()){
System.out.println(result.getString(1));
System.out.println(result.getString(2));
if(result.getString(1) == null){
resultOfGame = result.getString(2);
} else if(result.getString(2) == null) {
resultOfGame = result.getString(1);
} else {
resultOfGame = "Did not work";
}
}
return resultOfGame;
}
/**** compare the winner result ****/
private void compareGameWinnerResult(String game1Result, String game2Result, String team1, String team2) {
if((game1Result == "1") || (game2Result == "1")){ // checks for a draw
System.out.println("draw");
team1_winner_result = (float) 50;
team2_winner_result = (float) 50;
}
// } else if((game1Result.equals(team1)) && (game2Result.equals(team1))) { // checks for a winner of both games
// team1_winner_result = (float) 75;
// team2_winner_result = (float) 25;
// }
else if((game1Result.equals(team2)) && (game2Result.equals(team2))){ // checks for a winner of both games
team1_winner_result = (float) 25;
team2_winner_result = (float) 75;
} else if((game1Result.equals(team1) && (game2Result == null))){ // checks for a winner and a draw
team1_winner_result = (float) 75;
team2_winner_result = (float) 25;
} else if ((game1Result == null) && (game2Result.equals(team1))){ // checks for a winner and a draw
team1_winner_result = (float) 25;
team2_winner_result = (float) 75;
} else if((game1Result.equals(team2) && (game2Result == null))){ // checks for a winner and a draw
team1_winner_result = (float) 75;
team2_winner_result = (float) 25;
} else if ((game1Result == null) && (game2Result.equals(team2))){ // checks for a winner and a draw
team1_winner_result = (float) 25;
team2_winner_result = (float) 75;
}else { // last resort
team1_winner_result = (float) 50;
team2_winner_result = (float) 50;
}
System.out.println(team1 + " " + team1_winner_result);
System.out.println(team2 + " " + team2_winner_result);
}