MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
IMyCaffeGymUiService.cs
1using MyCaffe.basecode;
2using System;
3using System.Collections.Generic;
4using System.Drawing;
5using System.Drawing.Imaging;
6using System.IO;
7using System.Linq;
8using System.Runtime.Serialization;
9using System.ServiceModel;
10using System.Text;
11
12namespace MyCaffe.gym
13{
18 [ServiceContract(SessionMode=SessionMode.Required, CallbackContract=typeof(IXMyCaffeGymUiCallback))]
19 public interface IXMyCaffeGymUiService
20 {
28 [OperationContract(IsOneWay = false)]
29 int OpenUi(string strName, int nId, bool bStartRecording = false);
34 [OperationContract(IsOneWay = true)]
35 void CloseUi(int nId);
41 [OperationContract(IsOneWay = true)]
42 void Render(int nId, Observation obs);
48 [OperationContract(IsOneWay = false)]
49 bool IsOpen(int nId);
50 }
51
55 public interface IXMyCaffeGymUiCallback
56 {
60 [OperationContract(IsOneWay=true)]
61 void Closing();
62 }
63
67 [DataContract]
68 public class Observation
69 {
70 double[] m_rgState;
71 double m_dfReward;
72 bool m_bDone;
73 Bitmap m_img;
74 Bitmap m_imgDisplay;
75 bool m_bRequireDisplayImage = false;
76
86 public Observation(Bitmap imgDisp, Bitmap img, bool bRequireDisplayImg, double[] rgState, double dfReward, bool bDone)
87 {
88 m_rgState = rgState;
89 m_dfReward = dfReward;
90 m_bDone = bDone;
91 m_img = img;
92 m_imgDisplay = imgDisp;
93 m_bRequireDisplayImage = bRequireDisplayImg;
94 }
95
101 {
102 Bitmap bmp = (m_img == null) ? null : new Bitmap(m_img);
103 Bitmap bmpDisp = (m_imgDisplay == null) ? null : new Bitmap(m_imgDisplay);
104 double[] rgState = new double[m_rgState.Length];
105 Array.Copy(m_rgState, rgState, rgState.Length);
106
107 return new Observation(bmpDisp, bmp, m_bRequireDisplayImage, rgState, m_dfReward, m_bDone);
108 }
109
113 [DataMember]
114 public double[] State
115 {
116 get { return m_rgState; }
117 set { m_rgState = value; }
118 }
119
123 [DataMember]
124 public Bitmap Image
125 {
126 get { return m_img; }
127 set { m_img = value; }
128 }
129
133 [DataMember]
134 public Bitmap ImageDisplay
135 {
136 get { return m_imgDisplay; }
137 set { m_imgDisplay = value; }
138 }
139
143 [DataMember]
145 {
146 get { return m_bRequireDisplayImage; }
147 set { m_bRequireDisplayImage = value; }
148 }
149
153 [DataMember]
154 public double Reward
155 {
156 get { return m_dfReward; }
157 set { m_dfReward = value; }
158 }
159
163 [DataMember]
164 public bool Done
165 {
166 get { return m_bDone; }
167 set { m_bDone = value; }
168 }
169 }
170}
The Observation contains data describing the Gym as it runs.
bool RequireDisplayImage
Get/set whether or not the image for display (ImageDisplay) is required.
Bitmap ImageDisplay
Get/set the image to display.
bool Done
Get/set the done state.
double Reward
Get/set the reward.
Observation(Bitmap imgDisp, Bitmap img, bool bRequireDisplayImg, double[] rgState, double dfReward, bool bDone)
The constructor.
Bitmap Image
Get/set the action image, if it exists.
Observation Clone()
Returns a copy of the Observation.
The State class defines an abstract base class for the state information and gym data.
Definition: Interfaces.cs:337
The IXMyCaffeGymUiCallback is used to interact with the user of the IXMyCaffeGymUiService interface.
void Closing()
The Closing method is called when closing the Gym user interface.
The IXMYCaffeGymUiService interface provides access to the MyCaffeGymUiService used to display the vi...
bool IsOpen(int nId)
Returns true when the visualization is open, false otherwise.
int OpenUi(string strName, int nId, bool bStartRecording=false)
Open the user interface of a Gym.
void Render(int nId, Observation obs)
Render an observation on the Gym user-interface.
void CloseUi(int nId)
Close the user interface of a Gym.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.gym namespace contains all classes related to the Gym's supported by MyCaffe.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12