Skip to content

Commit

Permalink
fix some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
aiueo-1234 committed Jun 18, 2023
1 parent fa6da88 commit 47e7fe2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using HackathonA.ChatGPTDatas;
using UnityEngine;

namespace HackathonA
{
public class EnemyBehaviour
public class EnemyAI
{
public int DefaultPhysicalAttack { get; set; } = 20;
public int DefaultMagicAttack { get; set; } = 20;
Expand All @@ -19,7 +18,7 @@ public class EnemyBehaviour
// ChatGPTに入力するメッセージのリスト(過去の内容も一緒に渡すためリスト)
private List<Message> _messages;

public EnemyBehaviour(string apiKey)
public EnemyAI(string apiKey)
{
_apiKey = apiKey;
_messages = new List<Message>()
Expand Down Expand Up @@ -66,9 +65,9 @@ public void Set(int physicalAttack, int mamgicAttack, int recoveryPoint)
/// <returns>アクションのタイプ(0-4)。エラー時にはDefaultActionOnErrorで設定した値が返ってくる</returns>
public async UniTask<int> GetEnemyActionAsync(int playerHP, int enemyHP)
{
string currentMessage = $"Currently, your HP is {enemyHP} and your opponent's HP is {playerHP}";
string currentMessage = $"Currently, your HP is {enemyHP} and your opponent's HP is {playerHP}.\nChoose from the options above and respond with the corresponding number.";
DebugLoger.Log(currentMessage);
_messages.Add(new Message() { role = "system", content = currentMessage });
_messages.Add(new Message() { role = "user", content = currentMessage });

using var request = _chatGPTConnection.CreateCompletionRequest(new RequestData() { messages = _messages });

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Assets/Scripts/SampleGameBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async void Start()
{
var config = Resources.Load("ApiKey") as TextAsset;
var _apiKey = config.text.Trim();
var enemyBehaviour = new EnemyBehaviour(_apiKey);
var enemyBehaviour = new EnemyAI(_apiKey);
DebugLoger.Log($"Enemy Action: {await enemyBehaviour.GetEnemyActionAsync(PlayerHP, EnemyHP)}");
}
}
Expand Down

0 comments on commit 47e7fe2

Please sign in to comment.