Pointに追加した高さからID○○番目の数値を取得する方法
レシピブック12のA star探索アルゴリズムを参考に複数の避難所のうち最も近い避難所に逃げる避難シミュレーションを行っています。 前回、回答して頂いた内容からPointに変数「高さ」を追加する作業、目的地を示す「TargetPointAgt」の他に一つ前のPointを取得する作業ができました。 その次の作業の「高さ」からPersonが今いるPointのIDと次のPointのIDそれぞれの高さの数値を取得する方法が分からない為ご教授お願い致します。 以下にコードの一部を記載します。 Dim TargetPointAgt As Agt Dim distance As Double Dim targetpointID As Integer Dim lastpointID As Integer//追加 Dim PointAgt As Agt Dim PointAgtID As Integer Dim lastPointAgt as Agt//追加 Dim TargetPointAgt.high As Double//追加 Dim LastPointAgt.high As Double //追加 Universe.ct=Universe.count Universe.ct2=Universe.count2 Universe.ct3=Universe.count3 Universe.ct4=Universe.count4 PointAgtID=CInt(GetToken(My.RouteArray,My.RouteCount)) PointAgt=GetUniqueID(Universe.Map.Point,PointAgtID) If My.RouteCount<CountToken(My.RouteArray) then TargetpointID=CInt(GetToken(My.RouteArray,My.RouteCount)) TargetPointAgt=Universe.Map.Point(CInt(GetToken(My.RouteArray,My.RouteCount))) distance=Pursue(targetPointAgt,My.speed*My.SpeedRate) LastpointID=CInt(GetToken(My.RouteArray,My.RouteCount-1))//追加 LastPointAgt=Universe.Map.Point(CInt(GetToken(My.RouteArray,My.RouteCount-1)))//追加 TargetPointAgt.high=GetHistory(Universe.Map.Point.high,TargetPointID)//分からない部分❔ LastPointAgt.high=GetHistory(Universe.Map.Point.high,TargetPointId-1)//分からない部分❔ If targetPointAgt.high > lastPointAgt.high+1 then //追加 My.SpeedRate=0.1 //追加 Else //追加 My.SpeedRate=1.0 //追加 end if //追加 If Distance>0 then //Pointに到着した時 My.RouteCount=My.RouteCount+1 If CountToken(My.RouteArray)>My.RouteCount then //余剰分,次のPointへ向かう TargetPointAgt=Universe.Map.Point(CInt(GetToken(My.RouteArray,My.RouteCount))) Pursue(TargetPointAgt,distance) Else
レシピブック12のA star探索アルゴリズムを参考に複数の避難所のうち最も近い避難所に逃げる避難シミュレーションを行っています。 前回、回答して頂いた内容からPointに変数「高さ」を追加する作業、目的地を示す「TargetPointAgt」の他に一つ前のPointを取得する作業ができました。 その次の作業の「高さ」からPersonが今いるPointのIDと次のPointのIDそれぞれの高さの数値を取得する方法が分からない為ご教授お願い致します。 以下にコードの一部を記載します。 Dim TargetPointAgt As Agt Dim distance As Double Dim targetpointID As Integer Dim lastpointID As Integer//追加 Dim PointAgt As Agt Dim PointAgtID As Integer Dim lastPointAgt as Agt//追加 Dim TargetPointAgt.high As Double//追加 Dim LastPointAgt.high As Double //追加 Universe.ct=Universe.count Universe.ct2=Universe.count2 Universe.ct3=Universe.count3 Universe.ct4=Universe.count4 PointAgtID=CInt(GetToken(My.RouteArray,My.RouteCount)) PointAgt=GetUniqueID(Universe.Map.Point,PointAgtID) If My.RouteCount<CountToken(My.RouteArray) then TargetpointID=CInt(GetToken(My.RouteArray,My.RouteCount)) TargetPointAgt=Universe.Map.Point(CInt(GetToken(My.RouteArray,My.RouteCount))) distance=Pursue(targetPointAgt,My.speed*My.SpeedRate) LastpointID=CInt(GetToken(My.RouteArray,My.RouteCount-1))//追加 LastPointAgt=Universe.Map.Point(CInt(GetToken(My.RouteArray,My.RouteCount-1)))//追加 TargetPointAgt.high=GetHistory(Universe.Map.Point.high,TargetPointID)//分からない部分❔ LastPointAgt.high=GetHistory(Universe.Map.Point.high,TargetPointId-1)//分からない部分❔ If targetPointAgt.high > lastPointAgt.high+1 then //追加 My.SpeedRate=0.1 //追加 Else //追加 My.SpeedRate=1.0 //追加 end if //追加 If Distance>0 then //Pointに到着した時 My.RouteCount=My.RouteCount+1 If CountToken(My.RouteArray)>My.RouteCount then //余剰分,次のPointへ向かう TargetPointAgt=Universe.Map.Point(CInt(GetToken(My.RouteArray,My.RouteCount))) Pursue(TargetPointAgt,distance) Else
