Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改床位的状态尽量合理,扩充readme,增加了展示snapshot #37

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,58 @@
# VirusBroadcast
## 简介

一个基于java的模拟仿真程序,由于启动的时候时间仓促,数据不足,所以模型和推演过程过于简单,如果有好的想法或者能提供相关数据支持的朋友请提issues。
如果您也是一名java程序员,可以直接修改并给我提交pr,我之前已经启动每日疫情数据的每日抓取工作,希望在疫情结束后有机会通过这些精准的的数据做一个复盘。

2020.2.6:
病毒变异过程是一个不断适应的过程,可以尝试简单的DNN对病毒进行建模,已经开始着手实施。



## 图例

![snapshot1](snapshot/snapshot1.png)

![snapshot2](snapshot/snapshot2.png)



## 开发

当前暂未使用Maven或Gradle进行项目管理,可以直接使用IDEA-C导入项目。

导入方法可以参照 [本帖](https://github.com/KikiLetGo/VirusBroadcast/issues/1)



## 运行

以下方式适用于命令行玩家:

建议最低JDK版本: OpenJDK 8(推荐:AdoptOpenJDK)

```bash
cd src;

javac Main.java;

java Main;
```

注意:Windows下除了配置java环境,还需要设置编码才行,编译命令:

```bash

javac -encoding UTF-8 Main.java // 当前目录生成系列class文件

java Main

```





## License

// TODO
Binary file added snapshot/snapshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added snapshot/snapshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/Hospital.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,14 @@ public Bed pickBed() {
}

/**
* 死亡或痊愈出院空出床位
* 死亡或痊愈出院空出床位
*
* @param bed
* @return
*/
public Bed returnBed(Bed bed) {
//实际上不应该在这里判空。如果传入bed为空说明医院未曾收治。
//判空为了防止程序出错。
if (bed != null) {
bed.setEmpty(true);
}
Expand Down
19 changes: 13 additions & 6 deletions src/Person.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,19 +225,26 @@ public void update() {
//没有床位了,报告需求床位数

} else {
//安置病人
useBed = bed;
//安置病人,病床一定要判空。
//床位也只放一次
state = State.FREEZE;
setX(bed.getX());
setY(bed.getY());
bed.setEmpty(false);
if (useBed == null) {
useBed = bed;
bed.setEmpty(false);
setX(bed.getX());
setY(bed.getY());
}

}
}

//处理病死者
if ((state == State.CONFIRMED || state == State.FREEZE) && MyPanel.worldTime >= dieMoment && dieMoment > 0) {
state = State.DEATH;//患者死亡
Hospital.getInstance().returnBed(useBed);//归还床位
if (useBed != null) {//已有床位引用则说明已经收治,需归还床位
Hospital.getInstance().returnBed(useBed);//归还床位
}

}

//增加一个正态分布用于潜伏期内随机发病时间
Expand Down