├── .github └── workflows │ └── main.yml ├── .gitignore ├── Chapter01 ├── 01-building-environment-and-reward-mechanism-for-training-rl-agents.md ├── 06_neural_evolutionary_agent.ipynb ├── 06_neural_evolutionary_agent.py ├── envs │ ├── __init__.py │ └── gridworld.py └── index.md ├── Chapter02 ├── 2_value_based_rl.ipynb ├── 2_value_based_rl.py ├── 3_temporal_difference_learning.ipynb ├── 3_temporal_difference_learning.py ├── 4_monte_carlo_prediction_and_control_rl.ipynb ├── 4_monte_carlo_prediction_and_control_rl.py ├── 5_sarsa_sarsa_lambda.ipynb ├── 5_sarsa_sarsa_lambda.py ├── 6_q_learning.ipynb ├── 6_q_learning.py ├── 7_policy_gradients.ipynb ├── 7_policy_gradients.py ├── 8_actor_critic_agent.ipynb ├── 8_actor_critic_agent.py ├── README.md ├── envs │ ├── __init__.py │ ├── gridworldv2.py │ └── maze.py └── value_function_utils.py ├── Chapter03 ├── 1_double_dqn.ipynb ├── 1_double_dqn.py ├── 1_dqn.ipynb ├── 1_dqn.py ├── 2_dueling_dqn.ipynb ├── 2_dueling_dqn.py ├── 3_dueling_double_dqn.ipynb ├── 3_dueling_double_dqn.py ├── 4_drqn.ipynb ├── 4_drqn.py ├── 5_a3c_continuous.ipynb ├── 5_a3c_continuous.py ├── 6_ppo_continuous.ipynb ├── 6_ppo_continuous.py ├── 7_ddpg.ipynb ├── 7_ddpg.py └── README.md ├── Chapter04 ├── README.md ├── crypto_trading_continuous_env.ipynb ├── crypto_trading_continuous_env.py ├── crypto_trading_env.ipynb ├── crypto_trading_env.py ├── crypto_trading_visual_continuous_env.ipynb ├── crypto_trading_visual_continuous_env.py ├── crypto_trading_visual_env.ipynb ├── crypto_trading_visual_env.py ├── data │ ├── Gemini_BTCUSD_d.csv │ └── Gemini_ETHUSD_d.csv ├── sac_agent.ipynb ├── sac_agent.py ├── trading_utils.ipynb └── trading_utils.py ├── Chapter05 ├── README.md ├── data │ ├── MSFT.csv │ └── TSLA.csv ├── sac_agent.ipynb ├── sac_agent.py ├── stock_trading_continuous_env.ipynb ├── stock_trading_continuous_env.py ├── stock_trading_env.ipynb ├── stock_trading_env.py ├── stock_trading_visual_continuous_env.ipynb ├── stock_trading_visual_continuous_env.py ├── stock_trading_visual_env.ipynb ├── stock_trading_visual_env.py ├── trading_utils.ipynb └── trading_utils.py ├── Chapter06 ├── 2_call_to_action_agent.py ├── 3_login_agent.py ├── 4_flight_booking_agent.py ├── 4_flight_booking_ddpg_agent.py ├── 5_important_emails_manager_agent.py ├── 6_social_media_like_reply_agent.py ├── 6_social_media_like_reply_ddpg_agent.py ├── 7_social_media_mute_user_agent.py ├── 7_social_media_mute_user_ppo_agent.py ├── README.md ├── setup.sh └── webgym │ ├── __init__.py │ ├── envs.py │ ├── miniwob │ ├── __init__.py │ ├── action.py │ ├── environment.py │ ├── fields.py │ ├── html │ │ ├── .gitignore │ │ ├── common │ │ │ ├── shapes.js │ │ │ ├── special │ │ │ │ ├── book-flight │ │ │ │ │ └── domestic.js │ │ │ │ ├── checkbox-numbers │ │ │ │ │ ├── ch_0.png │ │ │ │ │ ├── ch_1.png │ │ │ │ │ ├── ch_2.png │ │ │ │ │ ├── ch_3.png │ │ │ │ │ ├── ch_4.png │ │ │ │ │ ├── ch_5.png │ │ │ │ │ ├── ch_6.png │ │ │ │ │ ├── ch_7.png │ │ │ │ │ ├── ch_8.png │ │ │ │ │ └── ch_9.png │ │ │ │ ├── click-pie │ │ │ │ │ ├── raphael.icons.min.js │ │ │ │ │ ├── raphael.min.js │ │ │ │ │ └── wheelnav.min.js │ │ │ │ ├── drag-cube │ │ │ │ │ ├── blank.png │ │ │ │ │ ├── cube.css │ │ │ │ │ └── cube.js │ │ │ │ ├── email-inbox-nl │ │ │ │ │ └── templates.js │ │ │ │ ├── email-inbox │ │ │ │ │ ├── delete.png │ │ │ │ │ ├── email-inbox.css │ │ │ │ │ ├── forward.png │ │ │ │ │ ├── left-arrow-white.png │ │ │ │ │ ├── left-arrow.png │ │ │ │ │ ├── reply.png │ │ │ │ │ ├── search.png │ │ │ │ │ ├── send.png │ │ │ │ │ ├── star-clicked.png │ │ │ │ │ └── star.png │ │ │ │ ├── navigate-tree │ │ │ │ │ ├── images │ │ │ │ │ │ ├── ajax-loader.gif │ │ │ │ │ │ ├── file.gif │ │ │ │ │ │ ├── folder-closed.gif │ │ │ │ │ │ ├── folder.gif │ │ │ │ │ │ ├── minus.gif │ │ │ │ │ │ ├── plus.gif │ │ │ │ │ │ ├── treeview-black-line.gif │ │ │ │ │ │ ├── treeview-black.gif │ │ │ │ │ │ ├── treeview-default-line.gif │ │ │ │ │ │ ├── treeview-default.gif │ │ │ │ │ │ ├── treeview-famfamfam-line.gif │ │ │ │ │ │ ├── treeview-famfamfam.gif │ │ │ │ │ │ ├── treeview-gray-line.gif │ │ │ │ │ │ ├── treeview-gray.gif │ │ │ │ │ │ ├── treeview-red-line.gif │ │ │ │ │ │ └── treeview-red.gif │ │ │ │ │ ├── jquery.treeview.css │ │ │ │ │ └── jquery.treeview.min.js │ │ │ │ ├── search-engine │ │ │ │ │ └── jquery.twbsPagination.min.js │ │ │ │ ├── social-media │ │ │ │ │ ├── like-hover.png │ │ │ │ │ ├── like.png │ │ │ │ │ ├── more-hover.png │ │ │ │ │ ├── more.png │ │ │ │ │ ├── reply-hover.png │ │ │ │ │ ├── reply.png │ │ │ │ │ ├── retweet-hover.png │ │ │ │ │ ├── retweet.png │ │ │ │ │ ├── share-hover.png │ │ │ │ │ └── share.png │ │ │ │ ├── text-editor │ │ │ │ │ ├── quill.min.js │ │ │ │ │ └── quill.snow.css │ │ │ │ └── tic-tac-toe │ │ │ │ │ ├── o.png │ │ │ │ │ └── x.png │ │ │ └── ui_utils.js │ │ ├── core │ │ │ ├── core.css │ │ │ ├── core.js │ │ │ ├── d3.v3.min.js │ │ │ ├── jquery-ui │ │ │ │ ├── external │ │ │ │ │ └── jquery │ │ │ │ │ │ └── jquery.js │ │ │ │ ├── images │ │ │ │ │ ├── ui-icons_444444_256x240.png │ │ │ │ │ ├── ui-icons_555555_256x240.png │ │ │ │ │ ├── ui-icons_777620_256x240.png │ │ │ │ │ ├── ui-icons_777777_256x240.png │ │ │ │ │ ├── ui-icons_cc0000_256x240.png │ │ │ │ │ └── ui-icons_ffffff_256x240.png │ │ │ │ ├── jquery-ui.min.css │ │ │ │ ├── jquery-ui.min.js │ │ │ │ ├── jquery-ui.structure.min.css │ │ │ │ └── jquery-ui.theme.min.css │ │ │ ├── jscolor.min.js │ │ │ └── record.js │ │ ├── flight │ │ │ ├── AA │ │ │ │ ├── apps │ │ │ │ │ └── common │ │ │ │ │ │ └── js │ │ │ │ │ │ ├── aacom.js │ │ │ │ │ │ ├── aacomDevice.js │ │ │ │ │ │ ├── airportcode.js │ │ │ │ │ │ ├── cookieconsent.js │ │ │ │ │ │ ├── jquery │ │ │ │ │ │ └── aacom │ │ │ │ │ │ │ ├── plugins │ │ │ │ │ │ │ ├── aaAirportAutoComplete.js │ │ │ │ │ │ │ ├── aaCache.js │ │ │ │ │ │ │ ├── aaCookie.js │ │ │ │ │ │ │ ├── aaCountryLanSelect.js │ │ │ │ │ │ │ ├── aaDropdownPanel.js │ │ │ │ │ │ │ ├── aaFooterAds.js │ │ │ │ │ │ │ └── aaTextBoxMessage.js │ │ │ │ │ │ │ └── utilities │ │ │ │ │ │ │ ├── aaUtilities-2.1.js │ │ │ │ │ │ │ └── aaUtils.js │ │ │ │ │ │ └── wa.js │ │ │ │ ├── content │ │ │ │ │ ├── common │ │ │ │ │ │ └── css │ │ │ │ │ │ │ └── v3 │ │ │ │ │ │ │ ├── core.css │ │ │ │ │ │ │ ├── jquery-ui-1.10-aa.css │ │ │ │ │ │ │ ├── reservation │ │ │ │ │ │ │ └── findFlights │ │ │ │ │ │ │ │ └── mobile │ │ │ │ │ │ │ │ └── findFlights.css │ │ │ │ │ │ │ └── responsive.css │ │ │ │ │ ├── fonts │ │ │ │ │ │ ├── american-v2 │ │ │ │ │ │ │ ├── americansans-bold.woff │ │ │ │ │ │ │ ├── americansans-light.woff │ │ │ │ │ │ │ ├── americansans-medium.woff │ │ │ │ │ │ │ └── americansans-regular.woff │ │ │ │ │ │ └── icons │ │ │ │ │ │ │ └── american-icons-v4-4.woff │ │ │ │ │ └── images │ │ │ │ │ │ ├── chrome │ │ │ │ │ │ ├── icons │ │ │ │ │ │ │ └── loading.gif │ │ │ │ │ │ └── rebrand │ │ │ │ │ │ │ ├── aa-flight-icon.png │ │ │ │ │ │ │ ├── aa-icons-flags-sprite.png │ │ │ │ │ │ │ ├── aa-logo.png │ │ │ │ │ │ │ ├── down-arrow.png │ │ │ │ │ │ │ ├── favicon.png │ │ │ │ │ │ │ ├── oneworld.png │ │ │ │ │ │ │ ├── shadow-down.png │ │ │ │ │ │ │ ├── shadow-vertical-150.png │ │ │ │ │ │ │ ├── shadow12-down.png │ │ │ │ │ │ │ ├── shadow12-up.png │ │ │ │ │ │ │ └── shadow3-down.png │ │ │ │ │ │ └── graphics │ │ │ │ │ │ └── icons │ │ │ │ │ │ └── aa-jqueryUIicons-sprite.png │ │ │ │ ├── dataset-AA.js │ │ │ │ ├── index.html │ │ │ │ ├── js │ │ │ │ │ ├── aa │ │ │ │ │ │ ├── common │ │ │ │ │ │ │ ├── aa-utility-menu.js │ │ │ │ │ │ │ ├── aacom-ui-1.0.0.js │ │ │ │ │ │ │ └── core-2.0.0.js │ │ │ │ │ │ ├── modules │ │ │ │ │ │ │ ├── airportLookup.js │ │ │ │ │ │ │ ├── ajax.js │ │ │ │ │ │ │ ├── browserdetect.js │ │ │ │ │ │ │ ├── commonsetup.js │ │ │ │ │ │ │ ├── mobileDatePicker.js │ │ │ │ │ │ │ ├── utilities.js │ │ │ │ │ │ │ └── widgets.js │ │ │ │ │ │ ├── plugins │ │ │ │ │ │ │ └── noBounce.js │ │ │ │ │ │ └── shopping │ │ │ │ │ │ │ └── mobileSearchFlights.js │ │ │ │ │ └── libs │ │ │ │ │ │ ├── jquery │ │ │ │ │ │ ├── jquery-1.11.1.min.js │ │ │ │ │ │ ├── jquery-migrate-1.2.1.min.js │ │ │ │ │ │ └── ui │ │ │ │ │ │ │ └── 1.10 │ │ │ │ │ │ │ ├── i18n │ │ │ │ │ │ │ └── jquery.ui.datepicker-en-aa.js │ │ │ │ │ │ │ └── jquery-ui.min.js │ │ │ │ │ │ └── modernizr-2.8.1.js │ │ │ │ ├── original.html │ │ │ │ ├── surrogate │ │ │ │ │ ├── airportLookup.js │ │ │ │ │ └── airports.json │ │ │ │ └── wrapper.html │ │ │ ├── Alaska-auto-medium │ │ │ │ ├── images │ │ │ │ │ ├── aura.png │ │ │ │ │ ├── cal3.png │ │ │ │ │ ├── chkboxes3.png │ │ │ │ │ ├── clear_text2.png │ │ │ │ │ ├── collapse.png │ │ │ │ │ ├── expand.png │ │ │ │ │ ├── flight_arrow.png │ │ │ │ │ ├── geo.png │ │ │ │ │ ├── home.png │ │ │ │ │ ├── info2.png │ │ │ │ │ ├── leftright.png │ │ │ │ │ ├── logo2.png │ │ │ │ │ └── logos │ │ │ │ │ │ ├── AA.png │ │ │ │ │ │ ├── AS.png │ │ │ │ │ │ ├── DL.png │ │ │ │ │ │ └── VX.png │ │ │ │ ├── index.html │ │ │ │ ├── mobileweb-v3-28-6227-21813.css │ │ │ │ ├── scripts │ │ │ │ │ ├── datepickr.js │ │ │ │ │ ├── main.js │ │ │ │ │ └── shopbook.js │ │ │ │ ├── stylesheets │ │ │ │ │ └── circular │ │ │ │ │ │ ├── ASCircularWeb-Bold.woff │ │ │ │ │ │ └── ASCircularWeb-Book.woff │ │ │ │ ├── surrogate │ │ │ │ │ ├── airportLookup.js │ │ │ │ │ └── airports.json │ │ │ │ └── wrapper.html │ │ │ ├── Alaska-auto │ │ │ │ ├── images │ │ │ │ │ ├── aura.png │ │ │ │ │ ├── cal3.png │ │ │ │ │ ├── chkboxes3.png │ │ │ │ │ ├── clear_text2.png │ │ │ │ │ ├── collapse.png │ │ │ │ │ ├── expand.png │ │ │ │ │ ├── flight_arrow.png │ │ │ │ │ ├── geo.png │ │ │ │ │ ├── home.png │ │ │ │ │ ├── info2.png │ │ │ │ │ ├── leftright.png │ │ │ │ │ ├── logo2.png │ │ │ │ │ └── logos │ │ │ │ │ │ ├── AA.png │ │ │ │ │ │ ├── AS.png │ │ │ │ │ │ ├── DL.png │ │ │ │ │ │ └── VX.png │ │ │ │ ├── index.html │ │ │ │ ├── mobileweb-v3-28-6227-21813.css │ │ │ │ ├── scripts │ │ │ │ │ ├── datepickr.js │ │ │ │ │ ├── main.js │ │ │ │ │ └── shopbook.js │ │ │ │ ├── stylesheets │ │ │ │ │ └── circular │ │ │ │ │ │ ├── ASCircularWeb-Bold.woff │ │ │ │ │ │ └── ASCircularWeb-Book.woff │ │ │ │ ├── surrogate │ │ │ │ │ ├── airportLookup.js │ │ │ │ │ └── airports.json │ │ │ │ └── wrapper.html │ │ │ ├── Alaska │ │ │ │ ├── dataset-Alaska.js │ │ │ │ ├── images │ │ │ │ │ ├── aura.png │ │ │ │ │ ├── cal3.png │ │ │ │ │ ├── chkboxes3.png │ │ │ │ │ ├── clear_text2.png │ │ │ │ │ ├── collapse.png │ │ │ │ │ ├── expand.png │ │ │ │ │ ├── flight_arrow.png │ │ │ │ │ ├── geo.png │ │ │ │ │ ├── home.png │ │ │ │ │ ├── info2.png │ │ │ │ │ ├── leftright.png │ │ │ │ │ ├── logo2.png │ │ │ │ │ └── logos │ │ │ │ │ │ ├── AA.png │ │ │ │ │ │ ├── AS.png │ │ │ │ │ │ ├── DL.png │ │ │ │ │ │ └── VX.png │ │ │ │ ├── index.html │ │ │ │ ├── mobileweb-v3-28-6227-21813.css │ │ │ │ ├── original.html │ │ │ │ ├── scripts │ │ │ │ │ ├── datepickr.js │ │ │ │ │ ├── main.js │ │ │ │ │ └── shopbook.js │ │ │ │ ├── stylesheets │ │ │ │ │ └── circular │ │ │ │ │ │ ├── ASCircularWeb-Bold.woff │ │ │ │ │ │ └── ASCircularWeb-Book.woff │ │ │ │ ├── surrogate │ │ │ │ │ ├── airportLookup.js │ │ │ │ │ └── airports.json │ │ │ │ └── wrapper.html │ │ │ └── flight-common │ │ │ │ ├── inject.js │ │ │ │ ├── wrapper.css │ │ │ │ └── wrapper.js │ │ └── miniwob │ │ │ ├── bisect-angle.html │ │ │ ├── book-flight-nodelay.html │ │ │ ├── book-flight.html │ │ │ ├── chase-circle.html │ │ │ ├── choose-date-easy.html │ │ │ ├── choose-date-medium.html │ │ │ ├── choose-date-nodelay.html │ │ │ ├── choose-date.html │ │ │ ├── choose-list.html │ │ │ ├── circle-center.html │ │ │ ├── click-button-sequence.html │ │ │ ├── click-button.html │ │ │ ├── click-checkboxes-large.html │ │ │ ├── click-checkboxes-soft.html │ │ │ ├── click-checkboxes-transfer.html │ │ │ ├── click-checkboxes.html │ │ │ ├── click-collapsible-2-nodelay.html │ │ │ ├── click-collapsible-2.html │ │ │ ├── click-collapsible-nodelay.html │ │ │ ├── click-collapsible.html │ │ │ ├── click-color.html │ │ │ ├── click-dialog-2.html │ │ │ ├── click-dialog.html │ │ │ ├── click-link.html │ │ │ ├── click-menu-2.html │ │ │ ├── click-menu.html │ │ │ ├── click-option.html │ │ │ ├── click-pie-nodelay.html │ │ │ ├── click-pie.html │ │ │ ├── click-scroll-list.html │ │ │ ├── click-shades.html │ │ │ ├── click-shape.html │ │ │ ├── click-tab-2-easy.html │ │ │ ├── click-tab-2-hard.html │ │ │ ├── click-tab-2-medium.html │ │ │ ├── click-tab-2.html │ │ │ ├── click-tab.html │ │ │ ├── click-test-2.html │ │ │ ├── click-test-transfer.html │ │ │ ├── click-test.html │ │ │ ├── click-widget.html │ │ │ ├── copy-paste-2.html │ │ │ ├── copy-paste.html │ │ │ ├── count-shape.html │ │ │ ├── count-sides.html │ │ │ ├── drag-box.html │ │ │ ├── drag-cube.html │ │ │ ├── drag-item.html │ │ │ ├── drag-items-grid.html │ │ │ ├── drag-items.html │ │ │ ├── drag-shapes.html │ │ │ ├── drag-sort-numbers.html │ │ │ ├── email-inbox-delete.html │ │ │ ├── email-inbox-forward-nl-turk.html │ │ │ ├── email-inbox-forward-nl.html │ │ │ ├── email-inbox-forward.html │ │ │ ├── email-inbox-important.html │ │ │ ├── email-inbox-nl-turk.html │ │ │ ├── email-inbox-noscroll.html │ │ │ ├── email-inbox-reply.html │ │ │ ├── email-inbox-star-reply.html │ │ │ ├── email-inbox.html │ │ │ ├── enter-date.html │ │ │ ├── enter-password.html │ │ │ ├── enter-text-2.html │ │ │ ├── enter-text-dynamic.html │ │ │ ├── enter-text.html │ │ │ ├── enter-time.html │ │ │ ├── find-midpoint.html │ │ │ ├── find-word.html │ │ │ ├── focus-text-2.html │ │ │ ├── focus-text.html │ │ │ ├── grid-coordinate.html │ │ │ ├── guess-number.html │ │ │ ├── highlight-text-2.html │ │ │ ├── highlight-text.html │ │ │ ├── identify-shape.html │ │ │ ├── login-user-popup.html │ │ │ ├── login-user.html │ │ │ ├── moving-items.html │ │ │ ├── multi-layouts.html │ │ │ ├── multi-orderings.html │ │ │ ├── navigate-tree.html │ │ │ ├── number-checkboxes.html │ │ │ ├── read-table-2.html │ │ │ ├── read-table.html │ │ │ ├── resize-textarea.html │ │ │ ├── right-angle.html │ │ │ ├── scroll-text-2.html │ │ │ ├── scroll-text.html │ │ │ ├── search-engine.html │ │ │ ├── simon-says.html │ │ │ ├── simple-algebra.html │ │ │ ├── simple-arithmetic.html │ │ │ ├── social-media-all.html │ │ │ ├── social-media-some.html │ │ │ ├── social-media.html │ │ │ ├── terminal.html │ │ │ ├── text-editor.html │ │ │ ├── text-transform.html │ │ │ ├── tic-tac-toe.html │ │ │ ├── unicode-test.html │ │ │ ├── use-autocomplete-nodelay.html │ │ │ ├── use-autocomplete.html │ │ │ ├── use-colorwheel-2.html │ │ │ ├── use-colorwheel.html │ │ │ ├── use-slider-2.html │ │ │ ├── use-slider.html │ │ │ ├── use-spinner.html │ │ │ └── visual-addition.html │ ├── instance.py │ ├── reward.py │ ├── screenshot.py │ ├── state.py │ └── utils.py │ ├── miniwob_env.py │ └── setup.py ├── Chapter07 ├── 3_training_rl_agents_using_remote_sims.py ├── 4_evaluating_rl_agents.py ├── 5_packaging_rl_agents_for_deployment.py ├── Dockerfile ├── README.md ├── sac_agent_base.py ├── sac_agent_runtime.py ├── test_agent_service.py ├── tradegym │ ├── __init__.py │ ├── crypto_trading_env.py │ ├── data │ │ ├── MSFT.csv │ │ └── TSLA.csv │ ├── stock_trading_continuous_env.py │ └── trading_utils.py ├── tradegym_http_client.py └── tradegym_http_server.py ├── Chapter08 ├── 1_multi_gpu_training.py ├── 2_multi_machine_multi_gpu_training.py ├── 3_multi_gpu_ppo_agent.py ├── 4_building_blocks_for_distributed_rl_using_ray.py ├── 5_scaling_deep_rl_training_using_ray_tune_rllib │ ├── .gitignore │ ├── 5.1_training_using_tune_run.py │ ├── 5.2_custom_training_using_tune.py │ └── custom_model.py ├── README.md ├── resnet.py └── sac_agent_base.py ├── Chapter09 ├── 9.1_rl_agent_tflite_deployment │ ├── ddpg_agent_tflite_deploy.py │ └── ppo_agent_tflite_deploy.py ├── 9.2_rl_android_app │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── assets │ │ │ ├── agent │ │ │ │ └── model.tflite │ │ │ ├── css │ │ │ │ └── style.css │ │ │ ├── index.html │ │ │ ├── js │ │ │ │ └── table-tennis.js │ │ │ └── rsc │ │ │ │ └── tt-board.svg │ │ │ ├── ic_launcher-web.png │ │ │ ├── java │ │ │ └── com │ │ │ │ └── tfrlcookbook │ │ │ │ └── rlapp │ │ │ │ ├── MainActivity.java │ │ │ │ └── MyWebViewClient.java │ │ │ └── res │ │ │ ├── layout │ │ │ └── activity_main.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── 9.3_deep_rl_tfjs_deployment │ ├── ddpg_agent_tfjs_deploy.py │ └── ppo_agent_tfjs_deploy.py ├── 9.4_deploying_rl_agent_as_service │ ├── README.md │ └── agent_trainer_saver.py ├── 9.5_cross_platform_packaging │ └── ppo_cross_platform_deploy.py ├── 9.x_rl_agent_runtime_options.md ├── 9.x_rl_table_tennis_web_app │ ├── css │ │ └── style.css │ ├── index.html │ ├── js │ │ └── table-tennis.js │ └── rsc │ │ └── tt-board.svg └── README.md ├── LICENSE ├── README.md ├── index.md └── tfrl-cookbook.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .*.sw? 2 | *~ 3 | _build 4 | .ipynb_checkpoints 5 | __pycache__ 6 | *.h5 7 | .vscode 8 | -------------------------------------------------------------------------------- /Chapter01/01-building-environment-and-reward-mechanism-for-training-rl-agents.md: -------------------------------------------------------------------------------- 1 | # 1.01 Building Environment and Reward mechanism for training RL agents 2 | 3 | This recipe notebook will walk you through the steps to build a learning environment to train RL agents. These steps will help you build custom RL learning environments for your problems that you wish to solve using RL. Implementing a learning environment with a reward mechanism for reinforcement learning. As a concrete example, this recipe will walk through the steps to build a Gridworld RL learning environment. The Gridworld is a simple environment where the world is represented as a grid and each cell in the grid can be referenced using a unique coordinate location. The goal of an agent in this environment is to find it's way to the goal state. A sample environment state of the Gridworld is shown below: 4 | 5 | ![fig-1.1-screenshot-of-the-gridworld-env.png](attachment:fig-1.1-screenshot-of-the-gridworld-env.png) 6 | 7 | The agent's current location is represented by the blue-colored cell in the grid, while the goal cell is colored green and the red-colored cell in the grid represents a bomb/mine/obstacle that the agent is supposed to avoid stepping. 8 | 9 | ```{.python .input n=3} 10 | # Create a sample environment 11 | ``` 12 | 13 | ```{.python .input} 14 | 15 | ``` 16 | -------------------------------------------------------------------------------- /Chapter01/envs/__init__.py: -------------------------------------------------------------------------------- 1 | from gym.envs.registration import register 2 | 3 | register( 4 | id="Gridworld-v0", entry_point="envs.gridworld:GridworldEnv", 5 | ) 6 | -------------------------------------------------------------------------------- /Chapter01/index.md: -------------------------------------------------------------------------------- 1 | # Ch1: Developing Building-blocks for Deep Reinforcement Learning 2 | 3 | ```toc 4 | 01-building-environment-and-reward-mechanism-for-training-rl-agents 5 | 6 | 02-implementing-and-training-RL-agent-from-scratch 7 | ``` 8 | -------------------------------------------------------------------------------- /Chapter02/2_value_based_rl.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Value-based reinforcement learning 3 | # Chapter 2, TensorFlow 2 Reinforcement Learning Cookbook | Praveen Palanisamy 4 | 5 | from pathlib import Path 6 | 7 | import numpy as np 8 | 9 | from envs.maze import MazeEnv 10 | from value_function_utils import visualize_maze_values 11 | 12 | discount = 0.9 13 | iters = 1000 14 | 15 | env = MazeEnv() 16 | state_dim = env.distinct_states 17 | state_values = np.zeros(state_dim) 18 | q_values = np.zeros((state_dim, env.action_space.n)) # Action values 19 | policy = np.zeros(state_dim) 20 | 21 | 22 | def calculate_values(state, action): 23 | """Evaluate Value function for given state and action 24 | 25 | Args: 26 | state (int): Valid (discrete) state in discrete `env.observation_space` 27 | action (int): Valid (discrete) action in `env.action_space` 28 | 29 | Returns: 30 | v_sum: value for given state, action 31 | """ 32 | v_sum = 0 33 | transitions = [] 34 | slip_action = env.slip_action_map[action] 35 | env.set_state(state) 36 | slip_next_state, slip_reward, _ = env.step(slip_action, slip=False) 37 | transitions.append((slip_reward, slip_next_state, env.slip_probability)) 38 | env.set_state(state) 39 | next_state, reward, _ = env.step(action, slip=False) 40 | transitions.append((reward, next_state, 1 - env.slip_probability)) 41 | for reward, next_state, pi in transitions: 42 | v_sum += pi * (reward + discount * state_values[next_state]) 43 | return v_sum 44 | 45 | 46 | # Value Iteration 47 | for i in range(iters): 48 | v_s = np.zeros(state_dim) 49 | for state in range(state_dim): 50 | if env.index_to_coordinate_map[int(state / 8)] == env.goal_pos: 51 | continue 52 | v_max = float("-inf") 53 | for action in range(env.action_space.n): 54 | v_sum = calculate_values(state, action) 55 | v_max = max(v_max, v_sum) 56 | v_s[state] = v_max 57 | state_values = np.copy(v_s) 58 | 59 | for state in range(state_dim): 60 | for action in range(env.action_space.n): 61 | q_values[state, action] = calculate_values(state, action) 62 | 63 | for state in range(state_dim): 64 | policy[state] = np.argmax(q_values[state, :]) 65 | 66 | Path("results").mkdir(exist_ok=True) 67 | np.save("results/q_values", q_values) 68 | np.save("results/optimal_policy", policy) 69 | # print(q_values) 70 | print("Action mapping:[0 - UP; 1 - DOWN; 2 - LEFT; 3 - RIGHT") 71 | print("Optimal actions:") 72 | print(policy) 73 | visualize_maze_values(q_values, env) 74 | -------------------------------------------------------------------------------- /Chapter02/3_temporal_difference_learning.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Temporal Difference (TD) learning 3 | # Chapter 2, TensorFlow 2 Reinforcement Learning Cookbook | Praveen Palanisamy 4 | 5 | import numpy as np 6 | from envs.gridworldv2 import GridworldV2Env 7 | from value_function_utils import visualize_grid_state_values 8 | 9 | 10 | def temporal_difference_learning(env, max_episodes): 11 | grid_state_values = np.zeros((len(env.distinct_states), 1)) 12 | grid_state_values[env.goal_state] = 1 13 | grid_state_values[env.bomb_state] = -1 14 | # v: state-value function 15 | v = grid_state_values 16 | gamma = 0.99 # Discount factor 17 | alpha = 0.01 # learning rate 18 | 19 | for episode in range(max_episodes): 20 | state = env.reset() 21 | done = False 22 | while not done: 23 | action = env.action_space.sample() # random policy 24 | next_state, reward, done = env.step(action) 25 | 26 | # State-value function updates using TD(0) 27 | v[state] += alpha * (reward + gamma * v[next_state] - v[state]) 28 | state = next_state 29 | visualize_grid_state_values(grid_state_values.reshape((3, 4))) 30 | 31 | 32 | if __name__ == "__main__": 33 | max_episodes = 4000 34 | env = GridworldV2Env(step_cost=-0.1, max_ep_length=30) 35 | temporal_difference_learning(env, max_episodes) 36 | -------------------------------------------------------------------------------- /Chapter02/5_sarsa_sarsa_lambda.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # SARSA and epsilon-greedy exploration policy 3 | # Chapter 2, TensorFlow 2 Reinforcement Learning Cookbook | Praveen Palanisamy 4 | 5 | import numpy as np 6 | import random 7 | from value_function_utils import visualize_grid_action_values 8 | from envs.gridworldv2 import GridworldV2Env 9 | 10 | 11 | def sarsa(env, max_episodes): 12 | grid_action_values = np.zeros((len(env.distinct_states), env.action_space.n)) 13 | grid_action_values[env.goal_state] = 1 14 | grid_action_values[env.bomb_state] = -1 15 | gamma = 0.99 # discounting factor 16 | alpha = 0.01 # learning rate 17 | # q: state-action-value function 18 | q = grid_action_values 19 | for episode in range(max_episodes): 20 | step_num = 1 21 | done = False 22 | state = env.reset() 23 | action = greedy_policy(q[state], 1) 24 | while not done: 25 | next_state, reward, done = env.step(action) 26 | step_num += 1 27 | decayed_epsilon = gamma ** step_num # Doesn't have to be gamma 28 | next_action = greedy_policy(q[next_state], decayed_epsilon) 29 | q[state][action] += alpha * ( 30 | reward + gamma * q[next_state][next_action] - q[state][action] 31 | ) 32 | state = next_state 33 | action = next_action 34 | visualize_grid_action_values(grid_action_values) 35 | 36 | 37 | def greedy_policy(q_values, epsilon): 38 | """Epsilon-greedy policy """ 39 | 40 | if random.random() >= epsilon: 41 | return np.argmax(q_values) 42 | else: 43 | return random.randint(0, 3) 44 | 45 | 46 | if __name__ == "__main__": 47 | max_episodes = 4000 48 | env = GridworldV2Env(step_cost=-0.1, max_ep_length=30) 49 | sarsa(env, max_episodes) 50 | -------------------------------------------------------------------------------- /Chapter02/6_q_learning.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Q-learning algorithm and agent 3 | # Chapter 2, TensorFlow 2 Reinforcement Learning Cookbook | Praveen Palanisamy 4 | 5 | import numpy as np 6 | import random 7 | from value_function_utils import visualize_grid_action_values 8 | from envs.gridworldv2 import GridworldV2Env 9 | 10 | 11 | def q_learning(env, max_episodes): 12 | grid_action_values = np.zeros((len(env.distinct_states), env.action_space.n)) 13 | grid_action_values[env.goal_state] = 1 14 | grid_action_values[env.bomb_state] = -1 15 | gamma = 0.99 # discounting factor 16 | alpha = 0.01 # learning rate 17 | # q: state-action-value function 18 | q = grid_action_values 19 | for episode in range(max_episodes): 20 | step_num = 1 21 | done = False 22 | state = env.reset() 23 | while not done: 24 | decayed_epsilon = 1 * gamma ** step_num # Doesn't have to be gamma 25 | action = greedy_policy(q[state], decayed_epsilon) 26 | next_state, reward, done = env.step(action) 27 | 28 | # Q-Learning update 29 | grid_action_values[state][action] += alpha * ( 30 | reward + gamma * max(q[next_state]) - q[state][action] 31 | ) 32 | 33 | step_num += 1 34 | state = next_state 35 | visualize_grid_action_values(grid_action_values) 36 | 37 | 38 | def greedy_policy(q_values, epsilon): 39 | """Epsilon-greedy policy """ 40 | 41 | if random.random() >= epsilon: 42 | return np.argmax(q_values) 43 | else: 44 | return random.randint(0, 3) 45 | 46 | 47 | if __name__ == "__main__": 48 | max_episodes = 4000 49 | env = GridworldV2Env(step_cost=-0.1, max_ep_length=30) 50 | q_learning(env, max_episodes) 51 | -------------------------------------------------------------------------------- /Chapter02/README.md: -------------------------------------------------------------------------------- 1 | ### Chapter 2: Implementing value-based, policy gradients and actor-critic Deep RL algorithms 2 | 3 | - 2.1 Building stochastic environments for training RL agents 4 | 5 | - [2.2 Building value-based Reinforcement Learning agent algorithms](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter02/2_value_based_rl.py) 6 | 7 | - [2.3 Implementing Temporal Difference (TD) Learning](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter02/3_temporal_difference_learning.py) 8 | 9 | - [2.4 Building Monte-Carlo prediction and control for RL](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter02/4_monte_carlo_prediction_and_control_rl.py) 10 | 11 | - [2.5 Implementing SARSA algorithm and SARSA agent](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter02/5_sarsa_sarsa_lambda.py) 12 | 13 | - [2.6 Building a Q-Learning agent](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter02/6_q_learning.py) 14 | 15 | - [2.7 Implementing Policy Gradients (PG) and a PG agent](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter02/7_policy_gradients.py) 16 | 17 | - [2.8 Implementing Actor-Critic Algorithms and agent](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter02/8_actor_critic_agent.py) 18 | -------------------------------------------------------------------------------- /Chapter02/envs/__init__.py: -------------------------------------------------------------------------------- 1 | from gym.envs.registration import register 2 | 3 | register( 4 | id="Maze-v0", entry_point="envs.maze:MazeEnv", 5 | ) 6 | register( 7 | id="Gridworld-v2", entry_point="envs.gridworldv2:GridworldV2Env", 8 | ) 9 | -------------------------------------------------------------------------------- /Chapter03/README.md: -------------------------------------------------------------------------------- 1 | ### Chapter 3: Implementing Advanced (Deep) RL algorithms 2 | 3 | - [3.1 Implementing Deep Q-Learning, DQN and Double-DQN agent](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter03/1_double_dqn.py) 4 | 5 | - [3.2 Implementing Dueling DQN agent](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter03/2_dueling_dqn.py) 6 | 7 | - [3.3 Implementing Double Dueling DQN algorithm and the DDDQN agent](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter03/3_dueling_double_dqn.py) 8 | 9 | - [3.4 Implementing Deep Recurrent Q-Learning algorithm and the DRQN Agent](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter03/4_drqn.py) 10 | 11 | - [3.5 Implementing Asynchronous Advantage Actor-Critic algorithm and the A3C agent](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter03/5_a3c_continuous.py) 12 | 13 | - [3.6 Implementing Proximal Policy Optimization algorithm and the PPO agent](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter03/6_ppo_continuous.py) 14 | 15 | - [3.7 Implementing Deep Deterministic Policy Gradient algorithm and the DDPG agent](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter03/7_ddpg.py) 16 | -------------------------------------------------------------------------------- /Chapter04/README.md: -------------------------------------------------------------------------------- 1 | ### Chapter 4: RL in real-world: Building cryptocurrency trading agents 2 | 3 | - [4.1 Building Bitcoin trading RL platform using real market data](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter04/crypto_trading_env.py) 4 | 5 | - [4.2 Building Ethereum tradingRL platform using price charts](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter04/crypto_trading_visual_env.py) 6 | 7 | - [4.3 Building advanced cryptocurrency trading platform for RL agents](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter04/crypto_trading_visual_continuous_env.py) 8 | 9 | - [4.4 Training cryptocurrency trading bot using RL](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter04/sac_agent.py) 10 | -------------------------------------------------------------------------------- /Chapter05/README.md: -------------------------------------------------------------------------------- 1 | ### Chapter 5: RL in real-world: Building stock/share trading agents 2 | 3 | - [5.1 Building stock-market trading RL platform using real stock-exchange data](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter05/stock_trading_continuous_env.py) 4 | 5 | - [5.2 Building stock-market trading RL platform using price charts](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter05/stock_trading_visual_continuous_env.py) 6 | 7 | - [5.3 Building advanced stock trading RL platform to train agents that trade like human pros](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter05/sac_agent.py) 8 | -------------------------------------------------------------------------------- /Chapter06/README.md: -------------------------------------------------------------------------------- 1 | ### Chapter 6: RL in real-world: Building intelligent agents to complete your To-Dos 2 | 3 | - [6.1 Building learning environments for real-world RL](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/tree/master/Chapter06/webgym) 4 | 5 | - [6.2 Building an RL agent to complete tasks on the web: Call to Action bot](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter06/2_call_to_action_agent.py) 6 | 7 | - [6.3 Building a visual auto-login bot](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter06/3_login_agent.py) 8 | 9 | - [6.4 Training an RL agent to automate flight booking for your travel](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter06/4_flight_booking_agent.py) 10 | 11 | - [6.5 Training an RL agent to manage your emails](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter06/5_important_emails_manager_agent.py) 12 | 13 | - [6.6 Training an RL agent to automate your social-media account management](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter06/6_social_media_like_reply_ddpg_agent.py) 14 | 15 | - [Bonux recipe: Training an RL agent to mute/block users](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter06/7_social_media_mute_user_agent.py) 16 | -------------------------------------------------------------------------------- /Chapter06/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Setup script to install chromium chromedriver for agent's browser interaction 3 | # Chapter 6, TensorFlow 2 Reinforcement Learning Cookbook | Praveen Palanisamy 4 | 5 | sudo apt-get install chromium-chromedriver 6 | -------------------------------------------------------------------------------- /Chapter06/webgym/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # WebGym Visual MiniWoB environment registration script 3 | # Chapter 6, TensorFlow 2 Reinforcement Learning Cookbook | Praveen Palanisamy 4 | 5 | import sys 6 | import os 7 | 8 | from gym.envs.registration import register 9 | 10 | sys.path.append(os.path.dirname(os.path.abspath(__file__))) 11 | 12 | 13 | _AVAILABLE_ENVS = { 14 | "MiniWoBClickButtonVisualEnv-v0": { 15 | "entry_point": "webgym.envs:MiniWoBClickButtonVisualEnv", 16 | "discription": "Click the button on a web page", 17 | }, 18 | "MiniWoBEmailInboxImportantVisualEnv-v0": { 19 | "entry_point": "webgym.envs:MiniWoBEmailInboxImportantVisualEnv", 20 | "discription": "Mark email as important", 21 | }, 22 | "MiniWoBBookFlightVisualEnv-v0": { 23 | "entry_point": "webgym.envs:MiniWoBBookFlightVisualEnv", 24 | "discription": "Book flight", 25 | }, 26 | "MiniWoBSocialMediaMuteUserVisualEnv-v0": { 27 | "entry_point": "webgym.envs:MiniWoBSocialMediaMuteUserVisualEnv", 28 | "discription": "Mute User on Social Media (Twitter-like) webpages", 29 | }, 30 | "MiniWoBSocialMediaReplyVisualEnv-v0": { 31 | "entry_point": "webgym.envs:MiniWoBSocialMediaReplyVisualEnv", 32 | "discription": "Click Reply to users on Social Media (Twitter-like) webpages", 33 | }, 34 | "MiniWoBLoginUserVisualEnv-v0": { 35 | "entry_point": "webgym.envs:MiniWoBLoginUserVisualEnv", 36 | "discription": "Login user", 37 | }, 38 | } 39 | 40 | 41 | for env_id, val in _AVAILABLE_ENVS.items(): 42 | register(id=env_id, entry_point=val.get("entry_point")) 43 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/__init__.py -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/.gitignore: -------------------------------------------------------------------------------- 1 | twistd.pid 2 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_0.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_1.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_2.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_3.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_4.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_5.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_6.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_7.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_8.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/checkbox-numbers/ch_9.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/drag-cube/blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/drag-cube/blank.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/email-inbox/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/email-inbox/delete.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/email-inbox/forward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/email-inbox/forward.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/email-inbox/left-arrow-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/email-inbox/left-arrow-white.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/email-inbox/left-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/email-inbox/left-arrow.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/email-inbox/reply.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/email-inbox/reply.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/email-inbox/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/email-inbox/search.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/email-inbox/send.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/email-inbox/send.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/email-inbox/star-clicked.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/email-inbox/star-clicked.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/email-inbox/star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/email-inbox/star.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/ajax-loader.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/file.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/file.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/folder-closed.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/folder-closed.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/folder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/folder.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/minus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/minus.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/plus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/plus.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-black-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-black-line.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-black.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-black.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-default-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-default-line.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-default.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-default.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-famfamfam-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-famfamfam-line.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-famfamfam.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-famfamfam.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-gray-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-gray-line.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-gray.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-gray.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-red-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-red-line.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-red.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/navigate-tree/images/treeview-red.gif -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/social-media/like-hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/social-media/like-hover.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/social-media/like.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/social-media/like.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/social-media/more-hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/social-media/more-hover.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/social-media/more.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/social-media/more.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/social-media/reply-hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/social-media/reply-hover.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/social-media/reply.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/social-media/reply.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/social-media/retweet-hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/social-media/retweet-hover.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/social-media/retweet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/social-media/retweet.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/social-media/share-hover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/social-media/share-hover.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/social-media/share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/social-media/share.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/tic-tac-toe/o.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/tic-tac-toe/o.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/common/special/tic-tac-toe/x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/common/special/tic-tac-toe/x.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/core/core.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #555; 3 | font-family: Arial; 4 | font-size: 14px; 5 | margin: 0; 6 | padding: 0; 7 | } 8 | 9 | #wrap { 10 | height:210px; 11 | background-color: white; 12 | width:160px; 13 | } 14 | 15 | #query { 16 | background-color: #FF0; 17 | font-size: 10px; 18 | height: 44px; 19 | padding: 3px; 20 | } 21 | 22 | #area { 23 | font-size: 10px; 24 | padding: 2px; 25 | } 26 | 27 | #area input[type=text] { 28 | width: 120px; 29 | } 30 | 31 | #area textarea { 32 | height: 25px; 33 | width: 120px; 34 | } 35 | 36 | #query .bold, #area .bold { font-weight: bold; } 37 | 38 | /* reward display CSS below */ 39 | #reward-display { 40 | font-size: 14px; 41 | height: 210px; 42 | width: 160px; 43 | position: absolute; 44 | left: 165px; 45 | top: 0px; 46 | } 47 | 48 | #reward-display .info { 49 | display: block; 50 | margin: 10px 5px; 51 | } 52 | 53 | #reward-last, #reward-avg, #timer-countdown, #episode-id { 54 | font-weight: bold; 55 | } 56 | 57 | #reward-avg { 58 | display: inline-block; 59 | } 60 | 61 | #area button.secondary-action { 62 | padding: 6px 25px; 63 | } 64 | 65 | /* task cover for synchronization */ 66 | #sync-task-cover { 67 | position: absolute; 68 | left: 0; 69 | top: 0; 70 | width: 160px; 71 | height: 210px; 72 | background-color: #111; 73 | color: #eee; 74 | text-align: center; 75 | line-height: 210px; 76 | font-size: 20px; 77 | cursor: pointer; 78 | z-index: 9999; 79 | } 80 | #sync-task-cover.transparent { 81 | background-color: transparent; 82 | color: transparent; 83 | cursor: not-allowed; 84 | } 85 | 86 | /* canvas for tracking clicks */ 87 | #click-canvas { 88 | position: absolute; 89 | left: 165px; 90 | top: 0px; 91 | background-color: white; 92 | } 93 | /* canvas for visualizing attention */ 94 | #attention-canvas { 95 | position: absolute; 96 | left: 330px; 97 | top: 0px; 98 | background-color: black; 99 | } 100 | 101 | /* Record demonstrations */ 102 | #server-name, #server-reply { 103 | font-size: 80%; 104 | } 105 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/core/jquery-ui/images/ui-icons_444444_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/core/jquery-ui/images/ui-icons_444444_256x240.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/core/jquery-ui/images/ui-icons_555555_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/core/jquery-ui/images/ui-icons_555555_256x240.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/core/jquery-ui/images/ui-icons_777620_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/core/jquery-ui/images/ui-icons_777620_256x240.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/core/jquery-ui/images/ui-icons_777777_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/core/jquery-ui/images/ui-icons_777777_256x240.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/core/jquery-ui/images/ui-icons_cc0000_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/core/jquery-ui/images/ui-icons_cc0000_256x240.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/core/jquery-ui/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/core/jquery-ui/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/AA/apps/common/js/aacomDevice.js: -------------------------------------------------------------------------------- 1 | var $device={mobile:false,tablet:false,desktop:true,touch:false,responsive:false,init:function(){this.desktop=(!this.tablet&&!this.mobile);this.touch=(this.tablet||this.mobile);if(this.tablet){jQuery("html").addClass("is-tablet");}if(this.mobile){jQuery("html").addClass("is-mobile");}if(this.responsive){jQuery("html").addClass("is-responsive");}},viewport:function(){if(this.responsive){var check=function(css){if(jQuery("."+css).length==0){jQuery("body").append('
');}return(jQuery("."+css).css("display")!="none");};if(check("visible-phone")){return"phone";}if(check("visible-tablet")){return"tablet";}}return"desktop";},landscape:function(){return(jQuery(window).height()'+values[i].name+"";}jQuery("select#aa-language-selector").html(options);self.changeAlert();}});});jQuery("#aa-language-selector").change(function(){self.changeAlert();});jQuery("#splashForm").submit(function(){url=jQuery("select#aa-language-selector",this).val();jQuery("#splashSelectedCountry",this).val(self.getParameter(url,"locale"));jQuery("#splashUrl",this).val(self.getParameter(url,"url"));jQuery("#splashGeoRedirect",this).val(self.getParameter(url,"georedirect"));});self.getParameter=function(url,name){return decodeURIComponent((RegExp(name+"=(.+?)(&|$)").exec(url)||[,""])[1]);};self.changeAlert=function(){if(self.getParameter(jQuery("select#aa-language-selector").val(),"locale")!=jQuery("input#currentLocale").val()){jQuery("#locale-change-alert").slideDown();}else{jQuery("#locale-change-alert").hide("fast");}};}; -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/AA/apps/common/js/jquery/aacom/plugins/aaFooterAds.js: -------------------------------------------------------------------------------- 1 | jQuery.aaFooterAds=function(source){var self=this;self.init=function(){jQuery(source).each(function(i,item){adLink=jQuery("#"+item.id+" a");if(item.isFlash){if(!jQuery.flash.available){adLink.append(''+item.altText+'');}else{jQuery(adLink).flash({swf:item.flashSrc,height:item.height,width:item.width,expressInstall:true});}}adLink.attr("title",item.altText);if(item.target.indexOf("http")!=-1){temp=function(){captureExtClickThru(item.target,item.anchorLocation,item.altText,item.repositoryName,item.repositoryId,item.locale,item.isFlash);};item.isFlash?adLink.mouseup(temp):adLink.click(temp);}if(item.openInNewWin=="Y"){temp=function(){window.open(this.href,"","scrollbars=yes,toolbar=yes,resizable=yes,status=yes,location=no,menubar=no,width=700,height=480,top=1,left=385");return false;};item.isFlash?adLink.mouseup(temp):adLink.click(temp);}else{if(item.isFlash){adLink.mouseup(function(){location.href=this.href;});}}});};self.init();}; -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/AA/apps/common/js/jquery/aacom/plugins/aaTextBoxMessage.js: -------------------------------------------------------------------------------- 1 | function aaTextBoxMessage(paramElement,paramMessage){if(paramElement){this.element=paramElement;this.message=((paramMessage)?paramMessage.replace(/^\s+|\s+$/g,""):"aaTextBoxMessage - ATTENTION: caption has not been defined");this.element.aaTextBoxMessage=this;this.element.value=this.message;this.element.onfocus=aaTextBoxMessage.onfocus;this.element.onblur=aaTextBoxMessage.onblur;this.element.aaTextBoxMessage=this;}}aaTextBoxMessage.onfocus=function(){if(this.value.replace(/^\s+|\s+$/g,"")===this.aaTextBoxMessage.message){this.value="";}};aaTextBoxMessage.onblur=function(){if(this.value.replace(/^\s+|\s+$/g,"")===""){this.value=this.aaTextBoxMessage.message;}};jQuery.fn.aaTextBoxMessage=function(paramMessage){var i=0;var obj;for(i;i<\/script>");}}catch(err){}delete_VPNR=createVPNR();delete_VPNR.initDeleteVPNRModal();});createVPNR=function(){var delete_VPNR={aaUtil_delete_VPNR:new aa_Utilities(),btns:[{name:vpnr_okMessage,callback:function forwardLogin(){deleteVirtualPNR();var url=jQuery("#loginURL").val();window.location=url;},cssClass:"btn",closeDialog:true},{name:vpnr_cancelMessage,cssClass:"btn btn-secondary",closeDialog:true}],deleteVPNRModal:function(){var VPNR=jQuery("#virtualPNR").val(),status=jQuery("#status").val();if(VPNR=="true"&&status!="Purchased"){this.aaUtil_delete_VPNR.aaDialog("#modal_deleteVPNRModal").openDialog(jQuery("#loginLogoutLink"));jQuery(window).scrollTop(0);}else{var url=jQuery("#loginURL").val();window.location=url;}},initDeleteVPNRModal:function(){this.aaUtil_delete_VPNR.aaDialog("#modal_deleteVPNRModal",{width:"small",buttons:this.btns,toggleScroll:true});}};return delete_VPNR;};function deleteVPNRModal(){delete_VPNR.deleteVPNRModal();} -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/AA/js/aa/common/aacom-ui-1.0.0.js: -------------------------------------------------------------------------------- 1 | function AAcom(){var args=Array.prototype.slice.call(arguments),callback=args.pop(),modules=(args[0]&&typeof args[0]==="string")?args:args[0],i;if(!(this instanceof AAcom)){return new AAcom(modules,callback);}if(!modules||modules=="*"){modules=[];for(i in AAcom.modules){if(AAcom.modules.hasOwnProperty(i)){modules.push(i);}}}for(i=0;i0){details={url:$form.attr("action"),type:$form.attr("method"),data:(options.dataType==="json")?$form.serializeObject():$form.serialize()};}return details;};var _errorHandler=function(xhr,statusText,settings){if(statusText!=="success"){if(settings.onError!==undefined){settings.onError(xhr,statusText);}else{var $htmlResponse=$j(xhr.responseText);if(statusText==="timeout"||xhr.responseText==="invalidState"||$htmlResponse.find(".js-invalidState").length>0){top.location.href="/invalidState.do";return true;}else{if(statusText==="error"||xhr.responseText==="systemError"||$htmlResponse.find(".js-systemError").length>0){top.location.href="/systemError.do";return true;}}}}return false;};};if(!$j.isFunction($j.fn.serializeObject)){$j.fn.serializeObject=function(){var o={};var a=this.serializeArray();$j.each(a,function(){if(o[this.name]){if(!o[this.name].push){o[this.name]=[o[this.name]];}o[this.name].push(this.value||"");}else{o[this.name]=this.value||"";}});return o;};} -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/AA/js/aa/modules/browserdetect.js: -------------------------------------------------------------------------------- 1 | AAcom.modules.browserdetect=function(AAUI){var BrowserDetect={init:function(){this.browser=this.searchString(this.dataBrowser)||"An unknown browser";this.version=this.searchVersion(navigator.userAgent)||this.searchVersion(navigator.appVersion)||"an unknown version";},searchString:function(data){for(var i=0;i-1)&&(agentStr.indexOf("MSIE 7.0")>-1))||((agentStr.indexOf("Trident/5.0")>-1)&&(agentStr.indexOf("MSIE 7.0")>-1))||((agentStr.indexOf("Trident/4.0")>-1)&&(agentStr.indexOf("MSIE 7.0")>-1))){return true;}}return false;};}; -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/AA/js/aa/modules/commonsetup.js: -------------------------------------------------------------------------------- 1 | AAcom.modules.commonsetup=function(AAUI){/* NOT NEEDED */}; 2 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/AA/js/aa/plugins/noBounce.js: -------------------------------------------------------------------------------- 1 | var noBounce=function(){var module={};var settings={animate:true};var track=[];var velocity={x:0,y:0};var vector={subtraction:function(v1,v2){return{x:v1.x-v2.x,y:v1.y-v2.y};},length:function(v){return Math.sqrt((v.x*v.x)+(v.y*v.y));},unit:function(v){var length=vector.length(v);v.x/=length;v.y/=length;},skalarMult:function(v,s){v.x*=s;v.y*=s;}};var requestAnimFrame=(function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(callback){window.setTimeout(callback,1000/60);};})();function handleTouchStart(evt){var point,touch;touch=evt.changedTouches[0];point={x:touch.clientX,y:touch.clientY,timeStamp:evt.timeStamp};track=[point];}function handleTouchMove(evt){var point,touch;evt.preventDefault();touch=evt.changedTouches[0];point={x:touch.clientX,y:touch.clientY,timeStamp:evt.timeStamp};track.push(point);doScroll();}function handleTouchEnd(evt){if(track.length>2&&settings.animate){velocity=calcVelocity();requestAnimFrame(animate);}}function calcVelocity(){var p1,p2,v,timeDiff,length;p1=track[0];p2=track[track.length-1];timeDiff=p2.timeStamp-p1.timeStamp;v=vector.subtraction(p2,p1);length=vector.length(v);vector.unit(v);vector.skalarMult(v,length/timeDiff*20);return v;}function doScroll(){var p1,p2,x,y;if(track.length>1){p1=track[track.length-1];p2=track[track.length-2];x=p2.x-p1.x;y=p2.y-p1.y;requestAnimFrame(function(){window.scrollBy(x,y);});}}function animate(){scrollBy(-velocity.x,-velocity.y);vector.skalarMult(velocity,0.95);if(vector.length(velocity)>0.2){requestAnimFrame(animate);}}function isElement(o){return(typeof HTMLElement==="object"?o instanceof HTMLElement:o&&typeof o==="object"&&o!==null&&o.nodeType===1&&typeof o.nodeName==="string");}module.init=function(options){if(typeof options.animate==="boolean"){settings.animate=options.animate;}if(isElement(options.element)){settings.element=options.element;}var element=settings.element||document;element.addEventListener("touchstart",handleTouchStart);element.addEventListener("touchmove",handleTouchMove);element.addEventListener("touchend",handleTouchEnd);element.addEventListener("touchcancel",handleTouchEnd);element.addEventListener("touchleave",handleTouchEnd);};return module;}(); -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/AA/js/libs/jquery/ui/1.10/i18n/jquery.ui.datepicker-en-aa.js: -------------------------------------------------------------------------------- 1 | /* Initialization in US English (customized for AA.com) for the datepicker from jQuery UI */ 2 | /* This file should be referred last in the JSP header so US English will be the default */ 3 | /* Ricardo Viana */ 4 | jQuery(function($){ 5 | $.datepicker.regional['en'] = { 6 | closeText: 'Close', 7 | prevText: 'Prev', 8 | nextText: 'Next', 9 | currentText: 'Today', 10 | monthNames: ['January','February','March','April','May','June', 11 | 'July','August','September','October','November','December'], 12 | monthNamesShort: ['Jan','Feb','Mar','Apr','May','Jun', 13 | 'Jul','Aug','Sep','Oct','Nov','Dec'], 14 | dayNames: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'], 15 | dayNamesShort: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'], 16 | dayNamesMin: ['S', 'M', 'T', 'W', 'T', 'F', 'S'], 17 | weekHeader: 'Wk', 18 | dateFormat: 'mm/dd/yy', 19 | firstDay: 0, 20 | isRTL: false, 21 | showMonthAfterYear: false, 22 | yearSuffix: ''}; 23 | $.datepicker.setDefaults($.datepicker.regional['en']); 24 | }); 25 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/AA/surrogate/airportLookup.js: -------------------------------------------------------------------------------- 1 | // Surrogate autocomplete 2 | 3 | /* 4 | Called by: apps/common/js/jquery/aacom/plugins/aaAirportAutoComplete.js 5 | 6 | Important args: 7 | - input.data.searchText: search term 8 | - input.success: callback 9 | 10 | Response examples: home/ajax/airportLookup_* 11 | [{"name":"Baltimore Washington International Airport","code":"BWI","stateCode":"MD","countryCode":"US","countryName":"United States"},...] 12 | */ 13 | $miniwob.surrogateAutocomplete = function (input) { 14 | function match() { 15 | var query = input.data.searchText.toLowerCase().replace(/[^a-z0-9]/, ''); 16 | var results = $miniwob.airports.filter(function (item) { 17 | return (item.code.toLowerCase().includes(query)); 18 | }); 19 | if (!results.length) { 20 | results = $miniwob.airports.filter(function (item) { 21 | var name = (item.name + item.stateCode).toLowerCase().replace(/[^a-z0-9]/, ''); 22 | return name.includes(query); 23 | }); 24 | } 25 | input.success(results); 26 | } 27 | 28 | if (!$miniwob.airports) { 29 | var xhr = new XMLHttpRequest(); 30 | xhr.onreadystatechange = function () { 31 | if (xhr.readyState == 4) { 32 | if (xhr.status == 200) { 33 | $miniwob.airports = JSON.parse(xhr.responseText); 34 | match(); 35 | } else { 36 | console.error('Error loading airports.json'); 37 | } 38 | } 39 | }; 40 | xhr.open('GET', 'surrogate/airports.json'); 41 | xhr.send(); 42 | } else { 43 | match(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/AA/wrapper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | AA 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 27 | 28 | 29 | 30 |
31 |
(Instruction)
32 |
(Raw query)
33 |
(Reward reason)
34 |
35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/aura.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/aura.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/cal3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/cal3.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/chkboxes3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/chkboxes3.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/clear_text2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/clear_text2.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/collapse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/collapse.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/expand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/expand.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/flight_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/flight_arrow.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/geo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/geo.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/home.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/info2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/info2.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/leftright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/leftright.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/logo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/logo2.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/logos/AA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/logos/AA.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/logos/AS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/logos/AS.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/logos/DL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/logos/DL.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/logos/VX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/images/logos/VX.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/stylesheets/circular/ASCircularWeb-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/stylesheets/circular/ASCircularWeb-Bold.woff -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/stylesheets/circular/ASCircularWeb-Book.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/stylesheets/circular/ASCircularWeb-Book.woff -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto-medium/surrogate/airportLookup.js: -------------------------------------------------------------------------------- 1 | // Surrogate autocomplete 2 | 3 | /* 4 | Called by: scripts/main.js 5 | 6 | Important args: 7 | - prefix 8 | - callback 9 | 10 | The response only contains at most 5 entries. 11 | 12 | Response examples: 13 | ["Adak Island, AK (ADK-Adak Island)", "Alexandria, LA (AEX-Alexandria Intl.)", "Brownsville, TX (BRO-South Padre Island Intl.)", "Cleveland, OH (CLE-Hopkins Intl.)", "Grand Forks, ND (GFK-Grand Forks Intl.)"] 14 | 15 | The cache only contains a partial list of possible airports. Will just use that. 16 | */ 17 | $miniwob.surrogateAutocomplete = function (prefix, callback) { 18 | function match() { 19 | var query = prefix.toLowerCase().replace(/[^a-z0-9 ]/, ''); 20 | var results = $miniwob.airports.filter(function (item) { 21 | return (item.toLowerCase().replace(/[^a-z0-9 ]/, '').includes(query)); 22 | }); 23 | callback(results.length ? results.slice(0, 5) : null); 24 | } 25 | 26 | if (!$miniwob.airports) { 27 | var xhr = new XMLHttpRequest(); 28 | xhr.onreadystatechange = function () { 29 | if (xhr.readyState == 4) { 30 | if (xhr.status == 200) { 31 | $miniwob.airports = JSON.parse(xhr.responseText); 32 | match(); 33 | } else { 34 | console.error('Error loading airports.json'); 35 | } 36 | } 37 | }; 38 | xhr.open('GET', 'surrogate/airports.json'); 39 | xhr.send(); 40 | } else { 41 | match(); 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/aura.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/aura.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/cal3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/cal3.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/chkboxes3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/chkboxes3.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/clear_text2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/clear_text2.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/collapse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/collapse.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/expand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/expand.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/flight_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/flight_arrow.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/geo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/geo.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/home.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/info2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/info2.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/leftright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/leftright.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/logo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/logo2.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/logos/AA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/logos/AA.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/logos/AS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/logos/AS.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/logos/DL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/logos/DL.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/logos/VX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/images/logos/VX.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/stylesheets/circular/ASCircularWeb-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/stylesheets/circular/ASCircularWeb-Bold.woff -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/stylesheets/circular/ASCircularWeb-Book.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska-auto/stylesheets/circular/ASCircularWeb-Book.woff -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska-auto/surrogate/airportLookup.js: -------------------------------------------------------------------------------- 1 | // Surrogate autocomplete 2 | 3 | /* 4 | Called by: scripts/main.js 5 | 6 | Important args: 7 | - prefix 8 | - callback 9 | 10 | The response only contains at most 5 entries. 11 | 12 | Response examples: 13 | ["Adak Island, AK (ADK-Adak Island)", "Alexandria, LA (AEX-Alexandria Intl.)", "Brownsville, TX (BRO-South Padre Island Intl.)", "Cleveland, OH (CLE-Hopkins Intl.)", "Grand Forks, ND (GFK-Grand Forks Intl.)"] 14 | 15 | The cache only contains a partial list of possible airports. Will just use that. 16 | */ 17 | $miniwob.surrogateAutocomplete = function (prefix, callback) { 18 | function match() { 19 | var query = prefix.toLowerCase().replace(/[^a-z0-9 ]/, ''); 20 | var results = $miniwob.airports.filter(function (item) { 21 | return (item.toLowerCase().replace(/[^a-z0-9 ]/, '').includes(query)); 22 | }); 23 | callback(results.length ? results.slice(0, 5) : null); 24 | } 25 | 26 | if (!$miniwob.airports) { 27 | var xhr = new XMLHttpRequest(); 28 | xhr.onreadystatechange = function () { 29 | if (xhr.readyState == 4) { 30 | if (xhr.status == 200) { 31 | $miniwob.airports = JSON.parse(xhr.responseText); 32 | match(); 33 | } else { 34 | console.error('Error loading airports.json'); 35 | } 36 | } 37 | }; 38 | xhr.open('GET', 'surrogate/airports.json'); 39 | xhr.send(); 40 | } else { 41 | match(); 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/aura.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/aura.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/cal3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/cal3.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/chkboxes3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/chkboxes3.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/clear_text2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/clear_text2.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/collapse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/collapse.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/expand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/expand.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/flight_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/flight_arrow.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/geo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/geo.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/home.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/info2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/info2.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/leftright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/leftright.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/logo2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/logo2.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/logos/AA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/logos/AA.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/logos/AS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/logos/AS.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/logos/DL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/logos/DL.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/images/logos/VX.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/images/logos/VX.png -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/stylesheets/circular/ASCircularWeb-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/stylesheets/circular/ASCircularWeb-Bold.woff -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/stylesheets/circular/ASCircularWeb-Book.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter06/webgym/miniwob/html/flight/Alaska/stylesheets/circular/ASCircularWeb-Book.woff -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/surrogate/airportLookup.js: -------------------------------------------------------------------------------- 1 | // Surrogate autocomplete 2 | 3 | /* 4 | Called by: scripts/main.js 5 | 6 | Important args: 7 | - prefix 8 | - callback 9 | 10 | The response only contains at most 5 entries. 11 | 12 | Response examples: 13 | ["Adak Island, AK (ADK-Adak Island)", "Alexandria, LA (AEX-Alexandria Intl.)", "Brownsville, TX (BRO-South Padre Island Intl.)", "Cleveland, OH (CLE-Hopkins Intl.)", "Grand Forks, ND (GFK-Grand Forks Intl.)"] 14 | 15 | The cache only contains a partial list of possible airports. Will just use that. 16 | */ 17 | $miniwob.surrogateAutocomplete = function (prefix, callback) { 18 | function match() { 19 | var query = prefix.toLowerCase().replace(/[^a-z0-9 ]/, ''); 20 | var results = $miniwob.airports.filter(function (item) { 21 | return (item.toLowerCase().replace(/[^a-z0-9 ]/, '').includes(query)); 22 | }); 23 | callback(results.length ? results.slice(0, 5) : null); 24 | } 25 | 26 | if (!$miniwob.airports) { 27 | var xhr = new XMLHttpRequest(); 28 | xhr.onreadystatechange = function () { 29 | if (xhr.readyState == 4) { 30 | if (xhr.status == 200) { 31 | $miniwob.airports = JSON.parse(xhr.responseText); 32 | match(); 33 | } else { 34 | console.error('Error loading airports.json'); 35 | } 36 | } 37 | }; 38 | xhr.open('GET', 'surrogate/airports.json'); 39 | xhr.send(); 40 | } else { 41 | match(); 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/Alaska/wrapper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Alaska 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 27 | 28 | 29 | 30 |
31 |
(Instruction)
32 |
(Raw query)
33 |
(Reward reason)
34 |
35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/flight/flight-common/wrapper.css: -------------------------------------------------------------------------------- 1 | /* ################ SIZING ################ */ 2 | 3 | #wrap, #sync-task-cover { 4 | height: 667px; 5 | width: 375px; 6 | } 7 | 8 | #wrap { 9 | overflow-x: auto; 10 | overflow-y: auto; 11 | border: 0; 12 | } 13 | 14 | #click-canvas, #reward-display { 15 | left: 380px; 16 | } 17 | 18 | #query-wrap { 19 | position: absolute; 20 | top: 215px; 21 | left: 380px; 22 | width: 160px; 23 | height: auto; 24 | } 25 | #query { 26 | height: auto; 27 | } 28 | #query-pretty { 29 | background-color: #EFF; 30 | font-size: 12px; 31 | padding: 3px; 32 | } 33 | #query-pretty .mode { 34 | font-weight: bold; 35 | } 36 | #query-pretty table { 37 | border-collapse: collapse; 38 | } 39 | #query-pretty th, #query-pretty td { 40 | border: 1px solid gray; 41 | padding: 2px 5px; 42 | width: 50%; 43 | text-align: left; 44 | } 45 | #reward-reason { 46 | background-color: #FEF; 47 | font-size: 10px; 48 | padding: 3px; 49 | } 50 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/choose-date-easy.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Choose Date Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 | 51 | 52 | 53 |
54 |
55 |
56 |

Date:

57 |
58 | 59 |
60 |
61 | 62 | 63 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/choose-date-medium.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Choose Date Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 | 51 | 52 | 53 |
54 |
55 |
56 |

Date:

57 |
58 | 59 |
60 |
61 | 62 | 63 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/choose-date-nodelay.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Choose Date Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 | 53 | 54 | 55 |
56 |
57 |
58 |

Date:

59 |
60 | 61 |
62 |
63 | 64 | 65 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/choose-date.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Choose Date Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 | 51 | 52 | 53 |
54 |
55 |
56 |

Date:

57 |
58 | 59 |
60 |
61 | 62 | 63 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/choose-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Choose List Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 16 | 17 | 55 | 56 | 57 |
58 |
59 |
60 |
61 |
62 | 63 | 64 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/click-button-sequence.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click Button Sqeuence Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 16 | 47 | 48 | 49 |
50 |
Click button ONE, then click button TWO.
51 |
52 | 53 | 54 |
55 |
56 | 57 | 58 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/click-button.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click Button Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 67 | 68 | 69 |
70 |
71 |
72 |
73 | 74 | 75 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/click-checkboxes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click Checkboxes Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 65 | 66 | 67 |
68 |
69 |
70 |
71 |
72 | 73 |
74 |
75 | 76 | 77 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/click-collapsible-nodelay.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click Collapsible Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 21 | 54 | 55 | 56 |
57 |
58 |
59 |
60 | 61 | 62 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/click-collapsible.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click Collapsible Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 21 | 54 | 55 | 56 |
57 |
58 |
59 |
60 | 61 | 62 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/click-dialog.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click Dialog Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 23 | 24 | 55 | 56 | 57 |
58 |
59 |
60 |
61 | 62 | 63 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/click-link.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click Link Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 70 | 71 | 72 |
73 |
74 |
75 |
76 | 77 | 78 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/click-menu.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click Menu Task 5 | 6 | 7 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 76 | 77 | 78 |
79 |
80 |
81 |
82 | 83 | 84 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/click-option.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click Option Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 18 | 19 | 54 | 55 | 56 |
57 |
58 |
59 |
60 |
61 | 62 |
63 |
64 | 65 | 66 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/click-shape.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click Shape Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 57 | 58 | 59 |
60 |
61 |
62 | 63 |
64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/click-tab.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click Tab Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 | 78 | 79 | 80 |
81 |
82 |
83 |
84 | 85 | 86 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/click-test-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click Test Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 16 | 17 | 34 | 35 | 36 |
37 |
Click button ONE.
38 |
39 | 40 | 41 |
42 |
43 | 44 | 45 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/click-test-transfer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click Test Transfer Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 16 | 17 | 44 | 45 | 46 |
47 |
48 |
49 | 50 | 51 |
52 |
53 | 54 | 55 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/click-test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click Test Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 31 | 32 | 33 |
34 |
Click the button.
35 |
36 | 37 |
38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/drag-cube.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Drag Cube Task 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 45 | 46 | 47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
1
55 |
56 |
57 |
2
58 |
59 |
60 |
3
61 |
62 |
63 |
4
64 |
65 |
66 |
5
67 |
68 |
69 |
6
70 |
71 |
72 |
73 | 74 |
75 |
76 |
77 | 78 | 79 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/enter-date.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Enter Date Task 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 45 | 46 | 47 |
48 |
49 |
50 |
51 | 52 | 53 |
54 |
55 |
56 | 57 | 58 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/enter-password.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Enter Password Task 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 40 | 41 | 42 |
43 |
44 |
45 |
46 |

47 |

48 | 49 |
50 |
51 |
52 | 53 | 54 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/enter-text-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Enter Text Task 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 66 | 67 | 68 |
69 |
70 |
71 |
72 | 73 | 74 |
75 |
76 |
77 | 78 | 79 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/enter-text-dynamic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Enter Dynamic Text Task 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 45 | 46 | 47 |
48 |
49 |
50 |
51 | 52 | 53 |
54 |
55 |
56 | 57 | 58 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/enter-text.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Enter Text Task 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 47 | 48 | 49 |
50 |
51 |
52 |
53 | 54 | 55 |
56 |
57 |
58 | 59 | 60 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/enter-time.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Enter Time Task 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 44 | 45 | 46 |
47 |
48 |
49 |
50 | 51 | 52 |
53 |
54 |
55 | 56 | 57 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/focus-text-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Focus Text Task 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 49 | 50 | 51 |
52 |
53 |
54 | 55 | 56 | 57 |
58 |
59 | 60 | 61 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/focus-text.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Focus Text Task 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 44 | 45 | 46 |
47 |
48 |
49 | 50 |
51 |
52 | 53 | 54 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/guess-number.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Resize Textarea Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 18 | 19 | 60 | 61 | 62 |
63 |
Guess the number between 0-9 and press Submit. Use the feedback below to find the right number.
64 |
65 |
66 |
Waiting for your guess...
67 |
Correct!
68 |
The number is lower than .
69 |
The number is higher than .
70 |
71 |
72 | 73 | 74 |
75 |
76 |
77 | 78 | 79 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/highlight-text.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Highlight Text Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | 65 | 66 | 67 |
68 |
69 |
70 |
71 | 72 | 73 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/login-user.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Login User Task 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 39 | 40 | 41 |
42 |
43 |
44 |
45 |

46 |

47 | 48 |
49 |
50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/scroll-text-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Scroll Text Task 5 | 6 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 59 | 60 | 61 |
62 |
63 |
64 | 65 | 66 |
67 |
68 | 69 | 70 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/scroll-text.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Scroll Text Task 5 | 6 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 46 | 47 | 48 |
49 |
50 |
51 | 52 | 53 | 54 |
55 |
56 | 57 | 58 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/simple-algebra.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Simple Algebra Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 19 | 20 | 60 | 61 | 62 |
63 |
Solve for x and type your answer into the textbox. Press Submit when done.
64 |
65 |
66 |
67 | x = 68 | 69 |
70 | 71 |
72 |
73 | 74 | 75 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/simple-arithmetic.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Simple Math Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 19 | 20 | 56 | 57 | 58 |
59 |
Solve the math problem and type your answer into the textbox. Press submit when done.
60 |
61 |
62 |
63 | 64 |
65 | 66 |
67 |
68 | 69 | 70 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/text-transform.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Text Transform Task 5 | 6 | 7 | 8 | 14 | 15 | 16 | 17 | 18 | 19 | 64 | 65 | 66 |
67 |
Type the text below into the text field and press Submit.
68 |
69 |
70 |
71 | 72 | 73 |
74 |
75 |
76 | 77 | 78 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/unicode-test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Click Button Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 67 | 68 | 69 |
70 |
71 |
72 |
73 | 74 | 75 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/use-autocomplete.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Use Autocomplete Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 22 | 23 | 68 | 69 | 70 |
71 |
72 |
73 | 74 | 75 | 76 |
77 |
78 | 79 | 80 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/use-colorwheel-2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Use Color Wheel Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 19 | 20 | 54 | 55 | 56 |
57 |
58 |
59 | Color:
60 | 61 |
62 |
63 | 64 | 65 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/use-colorwheel.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Use Color Wheel Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 18 | 19 | 45 | 46 | 47 |
48 |
49 |
50 | Color:
51 | 52 |
53 |
54 | 55 | 56 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/use-slider.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Use Slider Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 | 60 | 61 | 62 |
63 |
64 |
65 |
66 |
0
67 | 68 |
69 |
70 | 71 | 72 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/html/miniwob/use-spinner.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Use Spinner Task 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 45 | 46 | 47 |
48 |
49 |
50 | 51 | 52 | 53 |
54 |
55 | 56 | 57 | -------------------------------------------------------------------------------- /Chapter06/webgym/miniwob/reward.py: -------------------------------------------------------------------------------- 1 | """Reward processors 2 | 3 | Each method takes the metadata with the following keys: 4 | - env_reward: MiniWoB official reward 5 | - raw_reward: Raw task reward without time penalty 6 | - done: Whether the task is done 7 | Then it returns a reward (float). 8 | """ 9 | 10 | def get_original_reward(metadata): 11 | return float(metadata['env_reward']) 12 | 13 | def get_raw_reward(metadata): 14 | """Get the raw reward without time penalty. 15 | This is usually 1 for success and -1 for failure, but not always. 16 | """ 17 | return float(metadata['raw_reward']) 18 | 19 | def get_click_checkboxes_hard(metadata): 20 | """(click-checkboxes task) Reward without partial credits. 21 | Give 1 if the raw reward is 1. Otherwise, give -1. 22 | """ 23 | if not metadata['done']: 24 | return 0. 25 | return 1. if metadata['raw_reward'] == 1. else -1. 26 | 27 | def raw_reward_threshold(threshold): 28 | """Return a reward processor that cut off at a threshold.""" 29 | def fn(metadata): 30 | if metadata['raw_reward'] > threshold: 31 | return 1. 32 | elif metadata['raw_reward'] > 0: 33 | return -1 34 | return metadata['raw_reward'] 35 | return fn 36 | 37 | 38 | def get_reward_processor(config): 39 | if config.type == "time_independent": 40 | return get_raw_reward 41 | elif config.type == "time_discounted": 42 | return get_original_reward 43 | elif config.type == "click_checkboxes_hard": 44 | return get_click_checkboxes_hard 45 | else: 46 | raise ValueError( 47 | "{} not a valid reward processor type".format(config.type)) 48 | -------------------------------------------------------------------------------- /Chapter07/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04 2 | # Deploying Deep RL Agents to the cloud 3 | # Chapter 7, TensorFlow2.x Reinforcement Learning Cookbook | Praveen Palanisamy 4 | LABEL maintainer="emailid@domain.tld" 5 | 6 | RUN apt-get install -y wget git make cmake zlib1g-dev && rm -rf /var/lib/apt/lists/* 7 | 8 | ENV PATH="/root/miniconda3/bin:${PATH}" 9 | ARG PATH="/root/miniconda3/bin:${PATH}" 10 | RUN apt-get update 11 | 12 | RUN wget \ 13 | https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \ 14 | && mkdir /root/.conda \ 15 | && bash Miniconda3-latest-Linux-x86_64.sh -b \ 16 | && rm -f Miniconda3-latest-Linux-x86_64.sh 17 | 18 | # conda>4.9.0 is required for `--no-capture-output` 19 | RUN conda update -n base conda 20 | 21 | ADD . /root/tf-rl-cookbook/ch7 22 | 23 | WORKDIR /root/tf-rl-cookbook/ch7 24 | 25 | RUN conda env create -f "tfrl-cookbook.yml" -n "tfrl-cookbook" 26 | 27 | ENTRYPOINT [ "conda", "run", "--no-capture-output", "-n", "tfrl-cookbook", "python" ] 28 | 29 | CMD [ "5_packaging_rl_agents_for_deployment.py" ] -------------------------------------------------------------------------------- /Chapter07/README.md: -------------------------------------------------------------------------------- 1 | ### Chapter 7: Deploying Deep RL agents to the cloud 2 | 3 | - [7.1 Implementing RL agent's runtime components](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter07/sac_agent_runtime.py) 4 | 5 | - 7.2 Building RL environment simulator as a service 6 | 7 | - [Server](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter07/tradegym_http_server.py) 8 | - [Client](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter07/tradegym_http_client.py) 9 | 10 | - [7.3 Training RL agents using remote simulator instances](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter07/3_training_rl_agents_using_remote_sims.py) 11 | 12 | - [7.4 Ealuating/testing RL agents](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter07/4_evaluating_rl_agents.py) 13 | 14 | - [7.5 Packaging RL agents for deployment: A trading bot](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter07/5_packaging_rl_agents_for_deployment.py) 15 | 16 | - 7.6 Deploying RL agents to the cloud: Trading-Bot-as-a-Service 17 | -------------------------------------------------------------------------------- /Chapter07/test_agent_service.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Simple test script for the deployed Trading Bot-as-a-Service 3 | # Chapter 7, TensorFlow 2 Reinforcement Learning Cookbook | Praveen Palanisamy 4 | 5 | 6 | import os 7 | import sys 8 | 9 | import gym 10 | import requests 11 | 12 | sys.path.append(os.path.dirname(os.path.abspath(__file__))) 13 | import tradegym # Register tradegym envs with OpenAI Gym registry 14 | 15 | host_ip = "127.0.0.1" 16 | host_port = 5555 17 | endpoint = "v1/act" 18 | env = gym.make("StockTradingContinuousEnv-v0") 19 | 20 | post_data = {"observation": env.observation_space.sample().tolist()} 21 | res = requests.post(f"http://{host_ip}:{host_port}/{endpoint}", json=post_data) 22 | if res.ok: 23 | print(f"Received Agent action:{res.json()}") 24 | -------------------------------------------------------------------------------- /Chapter07/tradegym/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # TradeGym env registration script 3 | # Chapter 7, TensorFlow 2 Reinforcement Learning Cookbook | Praveen Palanisamy 4 | 5 | import sys 6 | import os 7 | 8 | from gym.envs.registration import register 9 | 10 | sys.path.append(os.path.dirname(os.path.abspath(__file__))) 11 | 12 | 13 | _AVAILABLE_ENVS = { 14 | "CryptoTradingEnv-v0": { 15 | "entry_point": "tradegym.crypto_trading_env:CryptoTradingEnv", 16 | "description": "Crypto Trading RL environment", 17 | }, 18 | "StockTradingContinuousEnv-v0": { 19 | "entry_point": "tradegym.stock_trading_continuous_env:StockTradingContinuousEnv", 20 | "description": "Stock Trading RL environment with continous action space", 21 | }, 22 | } 23 | 24 | 25 | for env_id, val in _AVAILABLE_ENVS.items(): 26 | register(id=env_id, entry_point=val.get("entry_point")) 27 | -------------------------------------------------------------------------------- /Chapter08/2_multi_machine_multi_gpu_training.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Recipe to accelerate custom model training with multi-machine, multi-GPU training 3 | # Chapter 8, TensorFlow 2 Reinforcement Learning Cookbook | Praveen Palanisamy 4 | 5 | import sys 6 | 7 | import tensorflow as tf 8 | from tensorflow import keras 9 | 10 | if "." not in sys.path: 11 | sys.path.insert(0, ".") 12 | import resnet 13 | 14 | ## Uncomment the following lines and fill worker details based on your cluster configuration 15 | # tf_config = { 16 | # "cluster": {"worker": ["1.2.3.4:1111", "localhost:2222"]}, 17 | # "task": {"index": 0, "type": "worker"}, 18 | # } 19 | # os.environ["TF_CONFIG"] = json.dumps(tf_config) 20 | strategy = tf.distribute.experimental.MultiWorkerMirroredStrategy() 21 | 22 | NUM_GPUS = 2 23 | BS_PER_GPU = 128 24 | NUM_EPOCHS = 60 25 | 26 | HEIGHT = 32 27 | WIDTH = 32 28 | NUM_CHANNELS = 3 29 | NUM_CLASSES = 10 30 | NUM_TRAIN_SAMPLES = 50000 31 | 32 | BASE_LEARNING_RATE = 0.1 33 | 34 | 35 | def normalize(x, y): 36 | x = tf.image.per_image_standardization(x) 37 | return x, y 38 | 39 | 40 | def augmentation(x, y): 41 | x = tf.image.resize_with_crop_or_pad(x, HEIGHT + 8, WIDTH + 8) 42 | x = tf.image.random_crop(x, [HEIGHT, WIDTH, NUM_CHANNELS]) 43 | x = tf.image.random_flip_left_right(x) 44 | return x, y 45 | 46 | 47 | (x, y), (x_test, y_test) = keras.datasets.cifar10.load_data() 48 | 49 | train_dataset = tf.data.Dataset.from_tensor_slices((x, y)) 50 | test_dataset = tf.data.Dataset.from_tensor_slices((x_test, y_test)) 51 | 52 | tf.random.set_seed(22) 53 | train_dataset = ( 54 | train_dataset.map(augmentation) 55 | .map(normalize) 56 | .shuffle(NUM_TRAIN_SAMPLES) 57 | .batch(BS_PER_GPU * NUM_GPUS, drop_remainder=True) 58 | ) 59 | test_dataset = test_dataset.map(normalize).batch( 60 | BS_PER_GPU * NUM_GPUS, drop_remainder=True 61 | ) 62 | 63 | 64 | input_shape = (HEIGHT, WIDTH, NUM_CHANNELS) 65 | img_input = tf.keras.layers.Input(shape=input_shape) 66 | opt = keras.optimizers.SGD(learning_rate=0.1, momentum=0.9) 67 | 68 | 69 | with strategy.scope(): 70 | model = resnet.resnet56(img_input=img_input, classes=NUM_CLASSES) 71 | model.compile( 72 | optimizer=opt, 73 | loss="sparse_categorical_crossentropy", 74 | metrics=["sparse_categorical_accuracy"], 75 | ) 76 | model.fit(train_dataset, epochs=NUM_EPOCHS) 77 | -------------------------------------------------------------------------------- /Chapter08/5_scaling_deep_rl_training_using_ray_tune_rllib/.gitignore: -------------------------------------------------------------------------------- 1 | ray_results 2 | logs 3 | -------------------------------------------------------------------------------- /Chapter08/5_scaling_deep_rl_training_using_ray_tune_rllib/5.1_training_using_tune_run.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Large-scale training of PPO agent using Ray Tune 3 | # Chapter 8, TensorFlow 2 Reinforcement Learning Cookbook | Praveen Palanisamy 4 | 5 | import ray 6 | import sys 7 | from ray import tune 8 | from ray.rllib.models import ModelCatalog 9 | 10 | if not "." in sys.path: 11 | sys.path.insert(0, ".") 12 | from custom_model import CustomModel 13 | 14 | # Register custom-model in ModelCatalog 15 | ModelCatalog.register_custom_model("CustomCNN", CustomModel) 16 | 17 | ray.init() 18 | experiment_analysis = tune.run( 19 | "PPO", 20 | config={ 21 | "env": "procgen:procgen-coinrun-v0", 22 | "num_gpus": 0, 23 | "num_workers": 2, 24 | "model": {"custom_model": "CustomCNN"}, 25 | "framework": "tf2", 26 | "log_level": "INFO", 27 | }, 28 | local_dir="ray_results", # store experiment results in this dir 29 | ) 30 | ray.shutdown() -------------------------------------------------------------------------------- /Chapter08/5_scaling_deep_rl_training_using_ray_tune_rllib/5.2_custom_training_using_tune.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Training Deep RL agents with custom models using Ray Tune 3 | # Chapter 8, TensorFlow 2 Reinforcement Learning Cookbook | Praveen Palanisamy 4 | 5 | import sys 6 | 7 | import ray 8 | import ray.rllib.agents.impala as impala 9 | from ray.tune.logger import pretty_print 10 | from ray.rllib.models import ModelCatalog 11 | 12 | if not "." in sys.path: 13 | sys.path.insert(0, ".") 14 | from custom_model import CustomModel 15 | 16 | # Register custom-model in ModelCatalog 17 | ModelCatalog.register_custom_model("CustomCNN", CustomModel) 18 | 19 | ray.init() 20 | config = impala.DEFAULT_CONFIG.copy() 21 | config["num_gpus"] = 0 22 | config["num_workers"] = 1 23 | config["model"]["custom_model"] = "CustomCNN" 24 | config["log_level"] = "INFO" 25 | config["framework"] = "tf2" 26 | trainer = impala.ImpalaTrainer(config=config, env="procgen:procgen-coinrun-v0") 27 | 28 | for step in range(1000): 29 | # Custom training loop 30 | result = trainer.train() 31 | print(pretty_print(result)) 32 | 33 | if step % 100 == 0: 34 | checkpoint = trainer.save() 35 | print("checkpoint saved at", checkpoint) 36 | 37 | # Restore agent from a checkpoint and start a new training run with a different config 38 | # config["lr"] = ray.tune.grid_search([0.01, 0.001])"] 39 | # ray.tune.run(trainer, config=config, restore=checkpoint) 40 | 41 | ray.shutdown() -------------------------------------------------------------------------------- /Chapter08/README.md: -------------------------------------------------------------------------------- 1 | ### Chapter 8: Distributed training for accelerated development of Deep RL agents 2 | 3 | - [8.1 Building distributed deep learning models using TensorFlow 2.x: Multi-GPU training](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter08/1_multi_gpu_training.py) 4 | 5 | - [8.2 Scaling up and out: Multi-machine, multi-GPU training](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter08/2_multi_machine_multi_gpu_training.py) 6 | 7 | - [8.3 Training Deep RL agents at scale: Multi-GPU PPO agent](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter08/3_multi_gpu_ppo_agent.py) 8 | 9 | - [8.4 Building blocks for distributed Deep Reinforcement learning for accelerated training](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter08/4_building_blocks_for_distributed_rl_using_ray.py) 10 | 11 | - [8.5 Large-scale Deep RL agent training using Ray, Tune and RLLib](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/tree/master/Chapter08/5_scaling_deep_rl_training_using_ray_tune_rllib) 12 | -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/.gitignore: -------------------------------------------------------------------------------- 1 | #built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # files for the dex VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # generated files 12 | bin/ 13 | gen/ 14 | 15 | # Local configuration file (sdk path, etc) 16 | local.properties 17 | 18 | # Windows thumbnail db 19 | Thumbs.db 20 | 21 | # OSX files 22 | .DS_Store 23 | 24 | # Android Studio 25 | *.iml 26 | .idea 27 | #.idea/workspace.xml - remove # and delete .idea if it better suit your needs. 28 | .gradle 29 | build/ 30 | .navigation 31 | captures/ 32 | output.json 33 | 34 | # NDK 35 | obj/ 36 | .externalNativeBuild 37 | 38 | # Additional assets 39 | *rsc/tt-board-* -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 29 5 | 6 | defaultConfig { 7 | applicationId "com.tfrlcookbook.rlapp" 8 | minSdkVersion 21 9 | targetSdkVersion 29 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | implementation 'org.tensorflow:tensorflow-lite:+' 24 | } 25 | -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Applications/Utilities/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/src/main/assets/agent/model.tflite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter09/9.2_rl_android_app/app/src/main/assets/agent/model.tflite -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/src/main/assets/css/style.css: -------------------------------------------------------------------------------- 1 | *, 2 | *::before, 3 | *::after { 4 | margin: 0px; 5 | padding: 0px; 6 | box-sizing: border-box; 7 | font-family: sans-serif; 8 | } 9 | 10 | [class*="brand"], 11 | [class*="title"] { 12 | font-family: cursive; 13 | text-align: center; 14 | margin-bottom: 20px; 15 | } 16 | #gameArea { 17 | position: absolute; 18 | left: 50%; 19 | top: 50%; 20 | } 21 | #ttBoard { 22 | position: absolute; 23 | display: block; 24 | margin: 0px auto; 25 | padding: 10px; 26 | width: 100%; 27 | height: 100%; 28 | z-index: 0; 29 | } 30 | #ttPlayArea { 31 | position: absolute; 32 | display: block; 33 | margin: 0px auto; 34 | padding: 40px 20px; 35 | width: 100%; 36 | height: 100%; 37 | z-index: 1; 38 | } 39 | -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/src/main/assets/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | Ch9: Table Tennis 10 | 11 | 12 | 13 | 14 |
15 |

TFRL-Cookbook Ch9: Table Tennis

16 |
17 | 18 |
19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter09/9.2_rl_android_app/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/src/main/java/com/tfrlcookbook/rlapp/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.tfrlcookbook.rlapp; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.app.Activity; 5 | import android.os.Bundle; 6 | import android.webkit.WebSettings; 7 | import android.webkit.WebView; 8 | 9 | public class MainActivity extends Activity { 10 | 11 | private WebView mWebView; 12 | 13 | @Override 14 | @SuppressLint("SetJavaScriptEnabled") 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_main); 18 | mWebView = findViewById(R.id.activity_main_webview); 19 | WebSettings webSettings = mWebView.getSettings(); 20 | webSettings.setJavaScriptEnabled(true); 21 | mWebView.setWebViewClient(new MyWebViewClient()); 22 | 23 | mWebView.loadUrl("file:///android_asset/index.html"); 24 | } 25 | 26 | @Override 27 | public void onBackPressed() { 28 | if(mWebView.canGoBack()) { 29 | mWebView.goBack(); 30 | } else { 31 | super.onBackPressed(); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/src/main/java/com/tfrlcookbook/rlapp/MyWebViewClient.java: -------------------------------------------------------------------------------- 1 | package com.tfrlcookbook.rlapp; 2 | 3 | import android.content.Intent; 4 | import android.net.Uri; 5 | import android.webkit.WebView; 6 | import android.webkit.WebViewClient; 7 | 8 | class MyWebViewClient extends WebViewClient { 9 | 10 | @Override 11 | public boolean shouldOverrideUrlLoading(WebView view, String url) { 12 | String hostname; 13 | 14 | // YOUR HOSTNAME 15 | hostname = "praveenp.com"; 16 | 17 | Uri uri = Uri.parse(url); 18 | if (url.startsWith("file:") || uri.getHost() != null && uri.getHost().endsWith(hostname)) { 19 | return false; 20 | } 21 | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); 22 | view.getContext().startActivity(intent); 23 | return true; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter09/9.2_rl_android_app/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter09/9.2_rl_android_app/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter09/9.2_rl_android_app/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter09/9.2_rl_android_app/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter09/9.2_rl_android_app/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | TFRL-Cookbook RL App 5 | 6 | 7 | -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:4.1.0' 10 | } 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | jcenter() 16 | google() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/91df46508e5672155d9f82f684d0f5d68680ecdf/Chapter09/9.2_rl_android_app/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Oct 13 08:15:32 CEST 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip 7 | -------------------------------------------------------------------------------- /Chapter09/9.2_rl_android_app/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /Chapter09/9.x_rl_agent_runtime_options.md: -------------------------------------------------------------------------------- 1 | # Deep RL Agent runtime options for cross-platform deployments 2 | 3 | | **Runtime** Frameworks:arrow_right: Platform :arrow_down: | **TensorFlow** | **PyTorch** | **ONNX** | **Triton** | **NNEF** | **CoreML** | 4 | | --------------------------------------------------------- | ------------------------- | --------------- | ------------- | ----------------------------------- | -------- | ----------------- | 5 | | Cloud/web-server | TensorFlow TensorFlow.js | PyTorch, Caffe2 | ONNX, ONNX.js | TensorRT, TensorFlow, PyTorch,ONNX, | NNEF | ~ (vapor.codes) | 6 | | Desktop | TensorFlow, TensorFlow.js | PyTorch, Caffe2 | ONNX, ONNX.js | TensorRT, TensorFlow, PyTorch,ONNX, | NNEF | \_ | 7 | | Mobile | TFLite/Firebase | PyTorch Mobile | ONNX, ONNX.js | \_ | NNEF | CoreML (IOS only) | 8 | | Robot/SBCs/IoT-devices | TensorFlow, TensorFlow.js | Caffe2 | ONNX, ONNX.js | TensorRT, TensorFlow, PyTorch,ONNX, | NNEF | ~ (vapor.codes) | 9 | 10 | Other runtime components: 11 | 12 | - The programming language (((C/C++, Python, JavaScript) 13 | - Compilers, interpreters, 14 | - OS (Ubuntu/Linux, OSX, Windows, Android, IOS) 15 | - Hardware (CPU, GPU, TPU, FPGA, ASIC) 16 | - JavaScript Engines (V8, SpiderMoneky, JavaScriptCore); Node.js electron.js 17 | -------------------------------------------------------------------------------- /Chapter09/9.x_rl_table_tennis_web_app/css/style.css: -------------------------------------------------------------------------------- 1 | *, 2 | *::before, 3 | *::after { 4 | margin: 0px; 5 | padding: 0px; 6 | box-sizing: border-box; 7 | font-family: sans-serif; 8 | } 9 | 10 | [class*="brand"], 11 | [class*="title"] { 12 | font-family: cursive; 13 | text-align: center; 14 | margin-bottom: 20px; 15 | } 16 | #gameArea { 17 | position: absolute; 18 | left: 50%; 19 | top: 50%; 20 | } 21 | #ttBoard { 22 | position: absolute; 23 | display: block; 24 | margin: 0px auto; 25 | padding: 10px; 26 | width: 100%; 27 | height: 100%; 28 | z-index: 0; 29 | } 30 | #ttPlayArea { 31 | position: absolute; 32 | display: block; 33 | margin: 0px auto; 34 | padding: 40px 20px; 35 | width: 100%; 36 | height: 100%; 37 | z-index: 1; 38 | } 39 | -------------------------------------------------------------------------------- /Chapter09/9.x_rl_table_tennis_web_app/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | Ch9: Table Tennis 10 | 11 | 12 | 13 | 14 |
15 |

TFRL-Cookbook Ch9: Table Tennis

16 |
17 | 18 |
19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Chapter09/README.md: -------------------------------------------------------------------------------- 1 | ### Chapter 9: Deploying Deep RL agents on multiple platforms 2 | 3 | - 9.0 Runtime options for cross-platform deployments 4 | 5 | - [9.1 Packaging Deep RL agents for mobile and IoT devices using TensorFlow Lite](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/tree/master/Chapter09/9.1_rl_agent_tflite_deployment) 6 | 7 | - [9.2 Deploying RL agents on mobile devices](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/tree/master/Chapter09/9.2_rl_android_app) 8 | 9 | - [9.3 Packaging Deep RL agents for the web and Node.js using TensorFlow.js](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/tree/master/Chapter09/9.3_deep_rl_tfjs_deployment) 10 | 11 | - [9.4 Deploying Deep-RL-Agent-as-a-Service](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/tree/master/Chapter09/9.4_deploying_rl_agent_as_service) 12 | 13 | - [9.5 Packaging Deep RL agents for cross-platform deployments](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/tree/master/Chapter09/9.5_cross_platform_packaging) 14 | - [Bonus Recipe: RL Agent rutime options](https://github.com/PacktPublishing/Tensorflow-2-Reinforcement-Learning-Cookbook/blob/master/Chapter09/9.x_rl_agent_runtime_options.md) 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Praveen Palanisamy and Packt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /index.md: -------------------------------------------------------------------------------- 1 | # TensorFlow 2.x Reinforcement Learning Cookbook 2 | 3 | ```toc 4 | src/ch1-developing-building-blocks-for-deep-rl/index.md 5 | ``` 6 | --------------------------------------------------------------------------------