DPST1091 24T2 - Programming Fundamentals! 1 - CS FlowersR

部署运行你感兴趣的模型镜像

Java Python DPST1091 24T2 - Programming Fundamentals!

Assignment 1 - CS Flowers

Overview

CS Flower is an action packed turn-based game where you the player, move across the Physics Lawn and cut down all the flowers. However, it's not as easy as it sounds. While you snip away at each of them one by one, the flowers wake up, evolve and retaliate against you. So it is up to you to figure out the best angle of attack against these formidable foes!

Assignment Structure

This assignment will test your ability to create, use and manipulate 2D arrays and structs to solve problems. This will be done through the in-game map that has been implemented as a 2D array of tiles. Each of these tiles are represented by a struct tile , which is outlined below:

struct tile

Purpose:

To store information about the tiles of the map.

Contains:

enum tile_type type

The type of the map tile.

All tile types are found in the enum tile_type definition.

struct flower flower

Represents the enemy flower at this location (if one exists).

struct flower

Purpose:

To store information about a particular enemy flower.

Contains:

enum flower_state state

Represents the state that the enemy flower is in.

The provided enums are quite extensive. Definitions of each are provided below:

enum tile_type

Purpose:

Represent the possible types of a tile.

Possible values:

EMPTY

Represents an empty space.

BUSH

A wall that blocks the movement of the player and enemies.

BRANCH

An interactable object that will create sound when stepped on by the player.

DANGER

A tile that indicates a root will erupt soon.

ROOT

A wall that the enemy can place down.

POLLEN

A tile that kills the player, which the enemy can place down.

SEEDLING

A baby flower that can grow.

FLOWER

An enemy flower.

enum flower_state

Purpose:

Represents the state that the flower is in.

Possible values:

NONE

DORMANT

DISTURBED

AWAKENED

ANXIOUS

ENERGETIC

Game Structure

There are two main phases to the overall game:

Setup Phase

This phase takes care of the initial setup of the map and the game. The setup is as follows:

1. The player is spawned onto the map

2. Various tiles known as foliage are placed onto the map

3. The flowers which act as enemies are spawned onto the DPST1091 24T2 - Programming Fundamentals! Assignment 1 - CS FlowersR map

Gameplay Phase

This phase handles the gameplay, which is split into turns. On each turn, the player, flowers, and the game will manipulate the map. A turn is comprised of the following steps:

1. The Player Step

The player is allowed to make an action like moving around or cutting a flower

2. The Upkeep Step

The upkeep is an intermediary step where you update parts of the map and its tiles

3. The Flower Step

The flowers are all allowed to make an action like attacking or defending against the player

4. The End Step

The final step at the end of a turn in which you determine if the game should end or continue

As you progress through each stage of this assignment, you will be implementing parts of each step.

How To Get Started

In order to get started with CS Flowers, do the following:

1. Create a new folder for your assignment work and move into it.

$ mkdir ass1

$ cd ass1

2. Download the starter code (cs_flowers.c) here or, copy this code to your CSE account using the following command

$ 1091 fetch_activity cs_flowers

1. Run 1091 autotest cs_flowers to make sure you have correctly downloaded the file.

$ 1091 autotest cs_flowers

NOTE:

When running the autotest on the starter code (with no modifications), it is expected to see failed tests. You can use [ctrl + c] to exit the autotests.

1. Read through Stage 1.

2. Spend a few minutes playing with the reference solution -- get a feel for how the assignment works.

$ 1091 cs_flowers

3. Think about your solution, draw some diagrams, write some pseudocode to help you get started.

HINT:

You might also find it helpful to draw diagrams and write pseudocode in later stages, especially stage 3 and stage 4!

1. Start coding!

Reference Solution

To help you understand the proper behaviour of the game, we have provided a reference implementation. If you have any questions about the behaviour of your assignment, you can check by trying it in the reference implementation.

To run the reference implementation, use the following command:

$ 1091 cs_flowers

About the Starter Code

The provided starter code has done some setup for you. This is explained below.

Before the main function, the starter code has:

1. Imported the standard input/output library.

2. Defined some initial #define 's and enums.

3. Defined the struct(s) described above.

In the main function, the starter code:

1. Creates a 2D array of struct tile s called map .

2. Initialises this map with some default values.

3         

您可能感兴趣的与本文相关的镜像

TensorFlow-v2.9

TensorFlow-v2.9

TensorFlow

TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型

<think>好的,我需要帮助用户找到G6K-2P-Y-DC5继电器的接线方法或图示。首先,我应该确认这个继电器的型号是否正确,以及是否有相关的技术文档。 G6K-2P-Y-DC5是欧姆龙(OMRON)的一款表面贴装型微型继电器,通常用于信号切换等低功耗应用。这类继电器的接线方法一般涉及线圈引脚和触点引脚的连接。根据常见的继电器结构,线圈通常有两个引脚,而触点部分可能有多个引脚,具体取决于继电器的类型(如单刀双掷SPDT)。 接下来,用户需要的是具体的接线图或说明。考虑到用户可能没有技术手册,我应该建议他们查阅欧姆龙的官方资料。例如,访问欧姆龙官方网站,搜索该型号的规格书,里面通常会有引脚排列图和接线示例。此外,技术论坛或电子元件分销商的网站也可能提供相关资料。 另外,引用中提到的内容可能与此型号无关,但需要注意是否有相关继电器的通用接线方法可以参考。例如,引用[2]和[3]提到双稳态继电器的测试和单稳态继电器的调整,但G6K-2P-Y-DC5是否是双稳态需要确认。根据我的知识,G6K系列通常是单线圈双稳态或单稳态,需要查阅具体型号的规格。 用户可能需要连接线圈到控制电路(如单片机IO口,如引用[2]中的例子),以及负载到触点。正确的接线需要区分线圈电压(DC5V)和触点额定参数。例如,线圈引脚接驱动电路,触点接被控设备。同时要注意二极管保护,防止反向电动势损坏控制电路。 最后,如果无法找到官方资料,可以建议用户参考类似继电器的接线方法,或者联系供应商获取支持。同时提醒安全操作,确保电压和电流在继电器规格范围内。</think>关于G6K-2P-Y-DC5继电器的接线方法,以下是分步说明: ### 1. 关键参数确认 - **型号解析**:G6K-2P-Y-DC5中: - `2P`:双刀单掷(DPST)触点类型 - `DC5`:线圈驱动电压为5V直流 - **触点容量**:通常为0.5A 125VAC/30VDC[^1] ### 2. 引脚布局(典型SMD封装) ``` ┌───────┐ 1 │● ●│ 8 2 │ │ 7 3 │ │ 6 4 │ │ 5 └───────┘ ``` - **线圈引脚**:引脚1(+)和8(-) - **触点组A**:引脚3(公共端)、2(常开)、4(常闭) - **触点组B**:引脚6(公共端)、5(常开)、7(常闭) ### 3. 接线示例 ```python # 伪代码表示接线逻辑(非实际代码) 线圈连接: VCC(5V) → 电阻/驱动电路 → 引脚1 GND → 引脚8 负载连接: 电源正 → 公共端(引脚3/6) 设备 → 常开触点(引脚2/5) 返回线路 → 电源负 ``` ### 4. 驱动电路建议 - 推荐使用晶体管驱动(如2N3904): ``` MCU_IO → 1kΩ电阻 → 晶体管基极 晶体管发射极 → GND 晶体管集电极 → 继电器引脚8 引脚1 → 5V电源 ``` - **必须并联续流二极管**:在引脚1和8之间反向并联1N4148[^2] ### 5. 注意事项 - 该继电器动作时间约5ms,释放时间约3ms[^3] - 最大切换频率建议不超过10Hz - PCB设计需注意爬电距离≥1mm
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值